-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[contextmanager-generator-missing-cleanup][new feature] Warn about @contextlib.contextmanager without try/finally in generator functions #9133
Conversation
created new _BasicChecker inheriting class registered this new linter like the rest in __init__.py
original example case included a slightly modified positive case 2 negative cases where exception is handled properly
Checks that contextmanager decorated functions that are generators handle GeneratorExit cleanly
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 your contribution, a lot of work went into this clearly. Would you mind adding a good/bad example in https://github.com/pylint-dev/pylint/tree/main/doc/data/messages too ? It's not enforced yet but we're close to being fully documented :)
Changed the detection logic of a bad generator function to test whether there was attempt at cleanup code
removed extra pylint disables from heading of test cases
output files got updated due to newlines above
This comment has been minimized.
This comment has been minimized.
…ng_cleanup' error
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9133 +/- ##
==========================================
+ Coverage 95.76% 95.83% +0.07%
==========================================
Files 173 174 +1
Lines 18665 18887 +222
==========================================
+ Hits 17874 18101 +227
+ Misses 791 786 -5
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Does this need reviews or do you need to polish some things still @rhyn0 ? I would be glad to have this in 3.2.0 😄 |
From what I can tell it's very close:
Happy to give the whole thing a once-over when those are in 👍 |
This comment has been minimized.
This comment has been minimized.
Failing ReadTheDocs error seems to be the following
Not sure if I need to change this here |
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.
Looking forward to merging this shortly. Just some minor feedback.
doc/data/messages/c/contextmanager-generator-missing-cleanup/details.rst
Show resolved
Hide resolved
doc/data/messages/c/contextmanager-generator-missing-cleanup/details.rst
Outdated
Show resolved
Hide resolved
Good call, let's not block your work on that. If it hasn't been fixed on main yet, please open an issue! |
🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉 This comment was generated for commit 3bd7132 |
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 new check @rhyn0!
Type of Changes
Description
Add a checker for
contextlib.contextmanager
decorated generator functions that don't have cleanup handling for GeneratorExit.Closes #2832