-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix useless-return false negatives #9492
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
Codecov ReportAll modified and coverable lines are covered by tests β
Additional details and impacted files@@ Coverage Diff @@
## main #9492 +/- ##
==========================================
- Coverage 95.83% 95.82% -0.01%
==========================================
Files 173 173
Lines 18808 18811 +3
==========================================
+ Hits 18024 18026 +2
- Misses 784 785 +1
|
This comment has been minimized.
This comment has been minimized.
DanielNoord
left a comment
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.
The primer run looks good as well!
Nice and simple change π Let's add some more tests though!
| return | ||
|
|
||
|
|
||
| def function5(parameter): # [useless-return] |
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'd like to see some cases where there is actual code after these excepts and if ... else statements to make sure we are not raising false positives.
Pierre-Sassoulas
left a comment
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.
Looking good ! I'm wondering what happens if there's a if/return construct in the middle of a for or while loop. (Then we should not raise because the return isn't useless afaiu). Could we add the same test cases but inside a loop ?
Returns inside try or if/else conditions were not being detected as useless. Said nodes are now checked for return statements to ensure their last component is not a useless return as well. Closes pylint-dev#9449.
This useless return was discovered after improving the useless-return checker. It has been removed to fix the warning.
220cf1b to
3f4349f
Compare
This comment has been minimized.
This comment has been minimized.
3f4349f to
43ddc01
Compare
This comment has been minimized.
This comment has been minimized.
|
I added some more tests. Is this what you had in mind? Or am I missing some other cases? |
Pierre-Sassoulas
left a comment
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 for adding the test case, I was thinking of something like this (in fact most of your test cases could do in a loop context)
Test suite has been improved with more tests to verify no bugs have been introduced by the recent changes to the checker.
43ddc01 to
579b41a
Compare
DanielNoord
left a comment
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! LGTM!
|
Great change ! |
Type of Changes
Description
Returns inside try or if/else conditions were not being detected as useless. Said nodes are now checked for return statements to ensure their last component is not a useless return as well.
Closes #9449.