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

Consider using with no assign #4476

Merged

Conversation

DudeNr33
Copy link
Collaborator

Steps

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

Description

As noted in this comment the consider-using-with message was not triggered if a call like open() was used outside an assignment expression.
So while this triggered the message:

filehandle = open("foo")

this did not:

open("foo")

This is because calls returning context managers were only checked for in the visit_assign method.
The logic was fixed.
Some new findings in the code base now emerged, which were fixed (or suppressed, for the functional test files).

Type of Changes

Type
🐛 Bug fix

Related Issue

None.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.009%) to 91.712% when pulling 84cb34d on DudeNr33:consider-using-with-no-assign into 318f1af on PyCQA:master.

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.

Looks pretty clean, thank you. It also detected two more problems in pylint which is a good sign !

@Pierre-Sassoulas Pierre-Sassoulas added Checkers Related to a checker Enhancement ✨ Improvement to a component labels May 16, 2021
@Pierre-Sassoulas Pierre-Sassoulas merged commit 18ef7ba into pylint-dev:master May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Checkers Related to a checker Enhancement ✨ Improvement to a component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants