-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add check for is comparison with mutable initialisers to rule F632 #8607
Add check for is comparison with mutable initialisers to rule F632 #8607
Conversation
|
Just wondering - what was the original reasoning for not using a |
We should probably gate this change to only apply when preview mode is enabled per the versioning policy as I think it fits into
Note on how to do this in another pull request #8608 (comment) |
Thanks for contributing :) the rest of the implementation looks good to me. I don't have the answer to your question though. |
I thiiink I've added the preview flag. And thanks for the encouraging words! |
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.
Great, thank you!
Summary
Adds an extra check to F632 to check for any
is
comparisons to a mutable initialisers.Implements #8589 .
Example:
The if condition will always evaluate to False because it checks on identity and it's impossible to take the same identity as a hard coded list/set/dict initializer.
Multiple test cases were added to ensure the rule works + doesn't flag false positives + the fix works correctly.