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

False negative on unused import of nested modules #9622

Open
draustin opened this issue Dec 23, 2024 · 0 comments
Open

False negative on unused import of nested modules #9622

draustin opened this issue Dec 23, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@draustin
Copy link

Pyright does not report all unused imports of modules inside a package.

I have a namespace package package with three modules:
Image

unused-import-false-negative.py only contains import statements.

import package.module1 # Pylance reports that "package.module1" is not accessed
import package.module2 # No error reported.
import package.module3 # No error reported.

I would expect all three imports to be reported as unused.

Also, if I refer to package.module2 or package.module3, then the unused import error package.module1 goes away (i.e. Pyright/Pylance reports zero errors).

I got the same results after adding an __init__.py to package.

I get the same results using Pylance v2024.12.100 (pre-release) in VS Code and Pyright 1.1.391 on the command line.

@draustin draustin added the bug Something isn't working label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant