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! |
…632`) (#12049) ## Summary See: astral-sh/ruff#8607. Rare but uncontroversial.
Summary
Adds an extra check to F632 to check for any
iscomparisons 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.