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

Issue 4430 false positive consider-using-with R1732 #4453

Merged

Conversation

DudeNr33
Copy link
Collaborator

@DudeNr33 DudeNr33 commented May 9, 2021

Steps

  • Add a ChangeLog entry describing what your PR does.
  • Write a good description on what the PR does.

Description

consider-using-with was triggered when the resource allocating operation was performed inside a custom context manager.
This is a false positive and reported in #4430.

This PR changes the behavior so that the message is suppressed if the call or assignment is made inside __enter__ or inside a function decorated with @contextlib.contextmanager.

This PR does not address the proposed warning of #4430, which should trigger if a resource is allocated in __enter__ but not released afterwards in __exit__. This should be tracked with a new enhancement issue.

Type of Changes

Type
βœ“ πŸ› Bug fix

Related Issue

Closes #4430

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.

Thanks ! Small changes, great tests, good job :)

@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code Enhancement ✨ Improvement to a component labels May 9, 2021
@coveralls
Copy link

Coverage Status

Coverage increased (+0.003%) to 91.699% when pulling 969b0ae on DudeNr33:issue-4430-false-positive-r1732 into 9528500 on PyCQA:master.

@Pierre-Sassoulas Pierre-Sassoulas merged commit f9df028 into pylint-dev:master May 9, 2021
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.8.3 milestone May 9, 2021
@DudeNr33 DudeNr33 deleted the issue-4430-false-positive-r1732 branch May 9, 2021 19:11
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.8.3, 2.9.0 May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive R1732 consider-using-with
3 participants