Skip to content

RUF046 fix is wrong when a newline appears before a call expression’s opening parenthesis #15263

@dscorbett

Description

@dscorbett

#15230 categorized Subscript and Call as having their own brackets, but because their brackets do not surround the entire expressions, this was not a safe categorization for the purpose of unnecessary-cast-to-int (RUF046). The fix can change program behavior in Ruff 0.8.6.

$ cat ruf046.py
x = int(round
(1))
print(x)

$ python ruf046.py
1

$ ruff check --isolated --preview --select RUF046 ruf046.py --fix
Found 1 error (1 fixed, 0 remaining).

$ cat ruf046.py
x = round
(1)
print(x)

$ python ruf046.py
<built-in function round>

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfixesRelated to suggested fixes for violationshelp wantedContributions especially welcomepreviewRelated to preview mode features

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions