Skip to content

UP032 complains about format args performing function calls #10258

Closed
@ThiefMaster

Description

x = 'CASE WHEN {0} > {1} THEN {0} ELSE {1} END'.format(process(arg1), process(arg2))

In this case one can assume the format() call is intentional to avoid calling process() more than once per arg.

$ ruff version
ruff 0.3.1

$ ruff check --isolated --select UP032 --preview --no-cache --output-format concise rufftest/ruff_sample.py
rufftest/ruff_sample.py:1:5: UP032 Use f-string instead of `format` call
Found 1 error.

Of course it could be refactored like this, but the rule triggering there feels incorrect.

arg1 = process(arg1)
arg2 = process(arg2)
return f'CASE WHEN {arg1} > {arg2} THEN {arg1} ELSE {arg2} END'

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions