-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
C2801 False positive when __setitem__
appears in a lambda
#8769
Comments
This comment was marked as resolved.
This comment was marked as resolved.
Ouch, sorry, that was your original report. I see now: >>> lamb = lambda x: x[1] = 2
File "<stdin>", line 1
lamb = lambda x: x[1] = 2
^^^^^^^^^^^^^^
SyntaxError: cannot assign to lambda Thanks for the report! |
__setitem__
appears in a lambda
Hey, I'd like to take a stab at this 🙂 First time contributing to pylint, so looking for some advice. I think I have an idea on how to modify
Do I need to prove using the official Python grammar, that intermediate nodes (something1,2,3 etc.) would still make this C2801 exception valid? Having a hard time considering all the sheer possibilities of exceptions of this exceptions. Hope I'm making sense, thanks! |
Sounds great (but "all" might be hard to reach :) ). There's probably already functional tests with a lot of cases, search for
Theoretically yes as long as astroid is not properly typed, but let's start by opening a merge request and seeing how it goes in the primer (new code run on major open source projects). We generally only deal with what is usually used in python not code that is correct python but actually never used by anyone. |
Be sure to evaluate if you can use existing utils like Thanks for the help! |
OP here. I think the fix shouldn’t exclude just any dunder method, but only those with side effects. In the Python world, those are probably those that return |
Bug description
I have a function that accepts a lambda as follows:
pylint generates an error:
But assignment isn’t valid in a lambda, so, the suggestion is incorrect.
Configuration
No response
Command used
Pylint output
Expected behavior
No error.
Pylint version
OS / Environment
No response
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: