MarcoGorelli / cython-lint

Lint Cython files
MIT License
68 stars 11 forks source link

Ignore unused imports #79

Open bdice opened 1 year ago

bdice commented 1 year ago

In flake8, users can ignore F401 to avoid warning about unused imports. I tried cython-lint --ignore F401 but it seems to do nothing. From the source of cython-lint, it doesn't seem like there is a way to disable this check right now. https://github.com/MarcoGorelli/cython-lint/blob/0afd5462e02db4a1f10442ca3111bb22c757ca7b/cython_lint/cython_lint.py#L744

bdice commented 1 year ago

Ideally users would be able to ignore import and cimport statements separately -- in the cases I'm considering, I'd like to detect unused cimport statements but ignore unused import statements.

MarcoGorelli commented 1 year ago

good idea - interested in submitting a pr?

bdice commented 1 year ago

It seems like cython-lint might need a way to ignore violations raised by cython-lint itself (as opposed to pycodestyle) which seems like it could be a lot of scope. That would require naming a code for existing violations, unless you want to do something like add a flag for every violation (e.g. --ignore-unused-imports, --ignore-unused-cimports). What do you think is the best course of action?

MarcoGorelli commented 1 year ago

either sounds good!

just fyi for now I'd expect that # no-cython-lint would work, but a cli argument to turn off this globally sounds useful