-
-
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
Add new checker bad-chained-comparison
#7990
Add new checker bad-chained-comparison
#7990
Conversation
This comment has been minimized.
This comment has been minimized.
The new message in primer seems genuine ! Amazing ! |
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 looks pretty good already, thank you !
I think it would be reasonable to enable this by default and not make it an extension. The one primer result appears to be a full-on error and my guess is that most hits would be also be errors. I know we try to avoid false positives, but on the other hand, surfacing latent errors helps to highlight the value of the tool. |
This seems to be a genuine error detected by the new pylint check in pylint-dev/pylint#7990.
I agree, I feel that most hits would most likely be errors. I don't think there are many scenarios that warrant such confusing chained comparisons. But ultimately, it depends on how tolerant we are towards false positives. Any thoughts on this? @Pierre-Sassoulas |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #7990 +/- ##
=======================================
Coverage 95.42% 95.43%
=======================================
Files 176 177 +1
Lines 18521 18545 +24
=======================================
+ Hits 17674 17698 +24
Misses 847 847
|
This comment has been minimized.
This comment has been minimized.
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 agree with @nickdrozd, as evidenced by the primer result this is a great check. It's not that often that we discover a real world bug in the primers with a 0% false positive rate from the start. In fact it never happened before. If we want to make this a default check we just have to move it to pylint/checker
, please keep the code independent :)
I suggested some wording change and a shorter message with more details, let me know what you think. (I did not review the logic again)
tests/functional/ext/bad_chained_comparison/bad_chained_comparison.txt
Outdated
Show resolved
Hide resolved
tests/functional/ext/bad_chained_comparison/bad_chained_comparison.txt
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I think it's a pretty nice checker, great job @zenlyj. Let's wait for another maintainer review, this is a default check after all, mistakes would affect a lot of users. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I have a really hard time to understand the pre-commit error. I can reproduce locally but I can't seem to fix it. |
@Pierre-Sassoulas it seems that the pre-commit error is due to the files having Windows style line breaks. It should be fixed now, sorry for the trouble! Regarding the documentation check fail, is this expected for new documentation pages? |
This comment has been minimized.
This comment has been minimized.
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
π€ Effect of this PR on checked open source code: π€ Effect on sentry:
This comment was generated for commit 05ae84a |
The documentation check is expected to fail as long as it's not merged in main and in the official doc. |
bad-chained-comparison
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.
First check that not only did not have a single primer false positives but even detected a real bug to fix in a very popular well scrutinized project. It already detected and permitted to fix a bug in sentry, which is pretty impressive ! Great checker, amazing job π
Type of Changes
Description
As suggested by the issue, a default checker is added to warn users about potential logical mistakes from a chained comparison consisting of comparisons that belong to different semantic categories/groups. Please take a look at the referenced issue as this implementation is pretty much a 1-1 of the solution suggested there.
Any advice is greatly appreciated!
Closes #6559