Given this scenario:
b.py
:
import A # A is unused here
c.py
:
from b import A # A is used here
PyCharm complains in b.py
that import A
is an unused import and Optimize imports deletes it, breaking import in c.py
.
I know these chained imports are not a good practice (although you may use it to implement a facade module), but is it me or is it a PyCharm fail?
unused import means you imported something that you never used...
Code Inspection: Unused importReports a redundant import statement. This is usually the case if the imported symbols are not used in the source file. To avoid side-effects, consider using bare import import 'packageName' instead of the regular one.
You can actually use the PyUnresolvedReferences
marker to deactivate the inspection for your import statement:
# noinspection PyUnresolvedReferences import A
Reference: PyCharm bug PY-2240
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With