-
Couldn't load subscription status.
- Fork 1.6k
[pyflakes] Fix false positive for __class__ in lambda expressions within class definitions (F821)
#20564
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
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! The tests look good, but what do you think about moving the new code to visit_expr to mirror the function version a bit more closely?
|
Yeah, that approach makes sense to me. Thanks for the review! |
|
Hmm, it looks like there are some new false positives in the ecosystem report. I was hoping it was something simple with the scope popping, which is why I pushed a commit, but that didn't end up helping. We're flagging a case like this with F401: import uuid
class C:
uuid = lambda: str(uuid.uuid4())and I don't fully understand why. We'll need to figure it out before we can merge this, though. Would you mind taking a look? |
Refactors the handling of implicit __class__ scopes in lambdas to only add the DunderClassCell scope when a lambda is nested within a class, not just any lambda. Adds a test case to ensure lambdas referencing module-level variables are not incorrectly flagged as F821.
|
The issue was that the I fixed it by moving the scope logic from |
|
Ah okay, I guess my earlier suggestion about moving it to |
Summary
Fixes #20562