-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[flake8-simplify
] add fix safety section (SIM210
)
#18100
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
[flake8-simplify
] add fix safety section (SIM210
)
#18100
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.
Thanks! I think this time we do need a note about comments.
/// return a proper Boolean. While the fix will try to wrap non-boolean values in a call to bool, | ||
/// custom implementations of comparison functions like `__eq__` can avoid the bool call and still | ||
/// lead to altered behavior. | ||
/// |
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.
This one actually does drop comments 😆 : https://play.ruff.rs/a415e7a8-c951-4ed8-af98-a0ebcbc41a40
but only in the case of multi-line if-expressions, which were easiest for me to cause with implicitly-concatenated strings, so it might be pretty rare.
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.
I will update ;)
I admit that I was lazy and i didn't check
Added ;-) |
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 PR add the `fix safety` section for rule `SIM210` (astral-sh#15584 ) It is a little cheating, as the Fix safety section is copy/pasted by astral-sh#18086 as the problem is the same. ### Unsafe Fix Example ```python class Foo(): def __eq__(self, other): return 0 def foo(): return True if Foo() == 0 else False def foo_fix(): return Foo() == 0 print(foo()) # False print(foo_fix()) # 0 ```
The PR add the
fix safety
section for ruleSIM210
(#15584 )It is a little cheating, as the Fix safety section is copy/pasted by #18086 as the problem is the same.
Unsafe Fix Example