-
-
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
Detect open() calls without with operator #3413
Comments
I'd be willing to work on this. @Pierre-Sassoulas let me know what you think. |
Yes, nice refactoring message name :) ! I assigned you to the issue, thank you ! |
* Implement consider-using-with check * Fix or disable consider-using-with in codebase * Fix ticket number in ChangeLog * Move functional test for ``open()`` into separate testfile and exclude this test from running with PyPy Co-authored-by: Pierre Sassoulas <[email protected]>
Thanks for the great addition! Unfortunately I'm not seeing it trigger on my end. $ cat tmp.py
open('test.txt')
$ pylint tmp.py
************* Module tmp
tmp.py:1:0: C0304: Final newline missing (missing-final-newline)
tmp.py:1:0: C0114: Missing module docstring (missing-module-docstring)
----------------------------------------------------------------------
Your code has been rated at -10.00/10 (previous run: -10.00/10, +0.00)
$ pylint --version
pylint 2.8.2
astroid 2.5.6
Python 3.9.4 (default, Apr 9 2021, 09:32:38)
[Clang 10.0.0 ]``` |
That is because you did not assign the return value to anything. |
But isn't file will not be closed in case of |
Yes, it would remain open. |
@DudeNr33 should i reopen this issue? |
@hippo91 as this issue is already referenced as "closed" in previous release notes, I'd say no. |
It'll be great to have check that will catch call to open() made without with operator. Probably check should work for other resource-allocating library calls.
The text was updated successfully, but these errors were encountered: