MarcoGorelli / cython-lint

Lint Cython files
MIT License
68 stars 11 forks source link

Unused imports trigger even if included in __all__. #80

Closed bdice closed 8 months ago

bdice commented 1 year ago

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 commented 1 year ago

yup, thanks for the report!

MarcoGorelli commented 8 months ago

finally done, sorry this took a while