-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
add checker for return in finally #8440
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 checker for return in finally #8440
Conversation
6208ffc
to
f895b59
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #8440 +/- ##
==========================================
+ Coverage 95.82% 95.90% +0.08%
==========================================
Files 173 174 +1
Lines 18375 18370 -5
==========================================
+ Hits 17607 17618 +11
+ Misses 768 752 -16
|
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.
Thank you for working on this, it looks pretty good already !
I'm not too happy with those examples. The problem is, that pylint should probably not make recommendations on how to fix it. The only real suggestion this checker could offer, would be "the I added this checker to the Other than that, let me know if I should improve the wording or anything else really. The fact that this new checker only produces one more message in all the checked repos is a good sign in my opinion. I'm not sure if the usage of yield in finally in pycopg2 is a legitimate one? |
It's a very good sign when there's only one new message raised and it's hard to tell if it's a false positive :) |
f895b59
to
44c8026
Compare
710fadc
to
9f17956
Compare
After looking at the generated docs, I thought adding comments to the bad example might be a bit more helpful. |
9f17956
to
9235647
Compare
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 like the embedded comment in the doc
The primer is showing one hit that looks like a false positive: def _exit_gen(self) -> PQGen[None]:
"""
Exit current pipeline by sending a Sync and fetch back all remaining results.
"""
try:
self._enqueue_sync()
yield from self._communicate_gen()
finally:
# No need to force flush since we emitted a sync just before.
yield from self._fetch_gen(flush=False) That function yields at least one item in any case, and possibly more. But I don't see any bug there. I think the warning should only trigger if there is a |
I'm trying to understand why this So I'm still not convinced that this is actually a false positive. 😕 |
I'm not sure why it's like that. It's not skipping bare-except because it doesn't actually catch anything. So if there's an exception in Barring side effects, I can't think of a good reason to do it this way. So maybe it isn't a false positive. But I could be wrong. |
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.
Thanks for this!
Agree with @nickdrozd we should just deal with return
. I don't think yield
is really a problem in finally
. I'd be happy to merge this if just affecting return
.
a1d3404
to
c1f74d8
Compare
Ok, I see that including Thanks for chiming in! This PR has bothered me for weeks. But I totally agree now, that this should only look at |
8b48836
to
408e985
Compare
This comment has been minimized.
This comment has been minimized.
The doc fail is due to a bug that was fixed on main :) |
408e985
to
8a342b4
Compare
This comment has been minimized.
This comment has been minimized.
8a342b4
to
32213e9
Compare
🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉 This comment was generated for commit 32213e9 |
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 for the contribution!
Great new check, thank you ! |
Type of Changes
Description
Closes #8260