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

Unused imports trigger even if included in __all__. #80

Closed
bdice opened this issue Jun 29, 2023 · 2 comments · Fixed by #88
Closed

Unused imports trigger even if included in __all__. #80

bdice opened this issue Jun 29, 2023 · 2 comments · Fixed by #88
Labels
bug Something isn't working

Comments

@bdice
Copy link

bdice commented Jun 29, 2023

For flake8, an import is considered "used" if it appears in a module's __all__. It seems that cython-lint is unaware of __all__ when considering which imports are used or unused.

Example:

# file.pyx
import numpy

__all__ = ["numpy"]
$ cython-lint file.pyx
file.pyx:1:8: 'numpy' imported but unused

Rename the above to file.py -- flake8 is clean.
Renaming the above to file.py and remove __all__:

$ flake8 file.py
file.py:1:1: F401 'numpy' imported but unused
@MarcoGorelli MarcoGorelli added the bug Something isn't working label Jun 29, 2023
@MarcoGorelli
Copy link
Owner

yup, thanks for the report!

@MarcoGorelli
Copy link
Owner

finally done, sorry this took a while

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

Successfully merging a pull request may close this issue.

2 participants