Warning of 'Unused import statement' even though module is used ???


I have some code like

import config
dbDriver = config.lims.database.driver
connectFunc[dbDriver](config.auth.oracle.lims, config.lims.database.verbose)

from models import *

where 'config' is marked as 'unused import statement' and is greyed out even though it is used very obviously. However through the general import from models the 'config' module gets imported again (which PyCharm probably detects), maybe that is the reason.

But: config is needed before the import of 'models', so 'Unused import' is not really right ... (and it fooled me to remove the import statement which caused by tests to fail of course ...)

I've had the problem in PyCharm 3.1, 3.3 and also now after the upgrade to 3.4.1 (OS X and Linux).

Possible bug?

1 comment
Comment actions Permalink

I'm experiencing a similar issue.

For example, the class MyClass is used in file my_file.py.

Refactor MyClass and move it to another file other_file.py.

Now my_file.py is still using MyClass, but the import of other_file.py

I tried File -> Invalidate Caches and Restart. PyCharm version 2016.2.3


Please sign in to leave a comment.