Skip to content
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

Fix false-positive with contextmanager missing cleanup #9654

Merged
merged 4 commits into from
May 20, 2024

Conversation

cdce8p
Copy link
Member

@cdce8p cdce8p commented May 19, 2024

Type of Changes

Type
βœ“ πŸ› Bug fix

Description

An attempt at fixing the false-positives with the contextmanager-generator-missing-cleanup check where no cleanup happens after a singular yield.

Closes #9625

Copy link

codecov bot commented May 19, 2024

Codecov Report

All modified and coverable lines are covered by tests βœ…

Project coverage is 95.84%. Comparing base (fbc1ed3) to head (509eb93).
Report is 163 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #9654   +/-   ##
=======================================
  Coverage   95.84%   95.84%           
=======================================
  Files         174      174           
  Lines       18896    18915   +19     
=======================================
+ Hits        18110    18129   +19     
  Misses        786      786           
Files Coverage Ξ”
pylint/checkers/base/function_checker.py 93.10% <100.00%> (-6.90%) ⬇️

... and 9 files with indirect coverage changes

This comment has been minimized.

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to document the known false positives from #9625 (comment) in dΓ©tails.rst ?

@cdce8p
Copy link
Member Author

cdce8p commented May 20, 2024

We might want to document the known false positives from #9625 (comment) in details.rst ?

Done. I've also updated the error node to use the with_node instead of the FuncDef. While technically this might be a small breaking change, I think this improves the error message especially for long generator functions with multiple if blocks.

@cdce8p cdce8p force-pushed the false-positive-contextmanager-cleanup branch from 814d0d4 to 509eb93 Compare May 20, 2024 06:14
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

πŸ€– According to the primer, this change has no effect on the checked open source code. πŸ€–πŸŽ‰

This comment was generated for commit 509eb93

@cdce8p cdce8p merged commit 5a01bc1 into pylint-dev:main May 20, 2024
44 checks passed
@cdce8p cdce8p deleted the false-positive-contextmanager-cleanup branch May 20, 2024 06:31
github-actions bot pushed a commit that referenced this pull request May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport maintenance/3.3.x False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
2 participants