Make IDE/linter ignore a seemingly unused import

Viewed 739

At my current work we have an enviroment py file contains the following imports:

from core.entities import * 
from core.entities.hdr import * 
from core.entities.scanner import *

However, all of these imports are seen as "unused" by the ide (Pycharm) and we sometimes experience someone making a commit where these have been removed by the IDE in the process. Is there a way to mark unused imports as not being unused?

2 Answers

Try checking in the "Reformat File" dialog (Ctrl+Alt+Shift+L), uncheck "Optimize imports", if already checked.

Alternatively, you can add `PyUnresolvedReferences':

# noinspection PyUnresolvedReferences
import A

# noinspection PyUnresolvedReferences
import B

Although there are some reported issues with the reference, https://youtrack.jetbrains.com/issue/PY-19837 .

This is the Unresolved references inspections. you can turn it off by going:

Settings > Editor > General > Inspections > python 

then you will see a checkbox in front of it.

Related