Misleading linting error

When importing a module twice and using the module inside a function, the linting says that the first import statement is unused, which is quite confusing. Instead of telling me that the first one is unused, it would be better if it told me that the second one is redefining a previous import.



Thank you for the report!

We inherit this behaviour from PyCharm, and I found a known related bug-report in their tracker:
PY-32329 false positive ā€˜unused import statementā€™

But since the behaviour could be different for *.ipynb and *.py files, I reported a separate ticket for Jupyter:
PY-47504 False positive ā€œunused import statementā€ in ipynb file

Feel free to upvote and follow this tickets.

1 Like