Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dscorbett opened this issue Sep 20, 2024 · 0 comments · Fixed by #13613
Closed

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

dscorbett opened this issue Sep 20, 2024 · 0 comments · Fixed by #13613
Labels
bug Something isn't working fixes Related to suggested fixes for violations help wanted Contributions especially welcome

Comments

@dscorbett
Copy link

dscorbett commented Sep 20, 2024

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
@AlexWaygood AlexWaygood added bug Something isn't working fixes Related to suggested fixes for violations help wanted Contributions especially welcome labels Sep 21, 2024
zanieb added a commit that referenced this issue Oct 3, 2024
@zanieb zanieb closed this as completed in 99e4566 Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixes Related to suggested fixes for violations help wanted Contributions especially welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants