ID: py/cyclic-import Kind: problem Security severity: Severity: recommendation Precision: high Tags: - reliability - maintainability - modularity Query suites: - python-security-and-quality.qls
A cyclic import is an
import which imports another module and that module imports (possibly indirectly) the module which contains the
Cyclic imports indicate that two modules are circularly dependent. This means that the modules cannot be tested independently, and it makes it harder to understand the architecture of the system.
The cycle may be broken by removing any one import. If only one function or method requires the import, then consider moving that to the other module and deleting the import. If the two modules are more intimately connected, then move the inter-dependent parts into a third module and have both the original modules import that.