mirror of
https://github.com/github/codeql.git
synced 2025-12-24 20:56:33 +01:00
For those documents with no obvious new home I've pointed the links to the Internet Archive.
41 lines
1.5 KiB
XML
41 lines
1.5 KiB
XML
<!DOCTYPE qhelp PUBLIC
|
|
"-//Semmle//qhelp//EN"
|
|
"qhelp.dtd">
|
|
<qhelp>
|
|
<overview>
|
|
<p>A cyclic import is an <code>import</code> which imports another module
|
|
and that module imports (possibly indirectly) the module which contains the
|
|
<code>import</code> statement.
|
|
If all imports in a cyclic import occur at module level, then a module will be
|
|
imported when it is part way through its initialization. This may rest in
|
|
surprising errors, as parts of the module being imported may not yet exist.
|
|
</p>
|
|
|
|
<p>In addition to the possible errors, 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.
|
|
</p>
|
|
|
|
</overview>
|
|
<recommendation>
|
|
|
|
<p>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.
|
|
</p>
|
|
|
|
|
|
</recommendation>
|
|
<references>
|
|
|
|
|
|
<li>Python Language Reference: <a href="http://docs.python.org/2/reference/simple_stmts.html#import">The import statement</a>.</li>
|
|
<li>Python: <a href="http://docs.python.org/2/tutorial/modules.html">Modules</a>.</li>
|
|
<li> Effbot: <a href="https://web.archive.org/web/20200917011425/https://effbot.org/zone/import-confusion.htm">Import Confusion</a>.</li>
|
|
|
|
|
|
</references>
|
|
</qhelp>
|