Skip to content

Fix for reimplemented-operator (FURB118) should be marked unsafe #13421

Closed
@dscorbett

Description

@dscorbett

The fix for reimplemented-operator (FURB118) should be marked unsafe because the code could rely on the parameter names. Compare unnecessary-lambda (PLW0108), whose fix is already marked unsafe for that reason. There are some cases where it can be proved that the function is never called with keyword arguments so the fix is safe, but in general that is not possible.

$ ruff --version
ruff 0.6.6
$ cat furb118.py
add = lambda x, y: x + y
print(add(x=1, y=2))
$ python furb118.py
3
$ ruff check --isolated --preview --select FURB118 furb118.py --fix
Found 1 error (1 fixed, 0 remaining).
$ python furb118.py 2>&1 | tail -n 3
    print(add(x=1, y=2))
          ^^^^^^^^^^^^^
TypeError: _operator.add() takes no keyword arguments

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixesRelated to suggested fixes for violationshelp wantedContributions especially welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions