Inspectopedia 2025.2 Help

Unused imports

Reports unused import statements in Python code.

This inspection detects import statements that are not used in the code and can be safely removed. Removing unused imports helps to keep the code clean and reduces the risk of name conflicts.

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

-PyUnresolvedReferences
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Python

Example:

import os # Unused import import sys # Used import from math import pi # Unused import print(sys.version)

The inspection provides a quick fix to optimize imports, which removes all unused import statements.

Note that some imports might be used indirectly (e.g., for side effects) and should not be removed. You can suppress this inspection for specific imports if they are needed for side effects.

Inspection ID: PyUnusedImportsInspection

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection -PyUnresolvedReferences

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

CLion 2025.2, DataSpell 2025.2, PyCharm 2025.2,

Can be installed with plugin:

Python Community Edition, 252.26661.0

Last modified: 18 September 2025