-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
No warning for unused import in __init__.py
#10162
Comments
by default
alternatively specify in your pylintrc file:
|
Thanks, it never occurred to me that this would be deliberate behaviour! I found the documentation for the flag, but for those of us whose primary interaction with Pylint is via errors in our IDE (in my case, VS Codium), it would be nice if it could be documented in the warning's page (I checked https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/unused-import.html and found no mention), along with a rationale (I don't understand why this happens, it has merely confused and then annoyed me!). Also, particular thanks for your quick and helpful reply @zenlyj. |
- Explained why __init__.py files may have unused imports by design. - Linked to the config option that overrides this behavior Fixes pylint-dev#10162
Much appreciated, many thanks! I'm sure future me, having forgotten all of this, will benefit from the documentation. |
Bug description
In a directory
tmp
I put the following code as__init__.py
:Pylint 3.3.3 reports no problems with this code:
This is odd, as I have an unused import.
If I copy the same code to
test.py
and rerun pylint, I get the expected error:$ pylint test.py ************* Module tmp.test test.py:2:0: W0611: Unused import sys (unused-import) ----------------------------------- Your code has been rated at 0.00/10
Configuration
Command used
Pylint output
Expected behavior
Pylint version
OS / Environment
Ubuntu 24.04
Additional dependencies
The text was updated successfully, but these errors were encountered: