Module Dependencies and Import Cycles

A module dependency graph shows which definitions are needed by others. Cyclic initialization can leave some definitions unavailable when they are first requested.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Trace two imports
  2. Look for a shared lower-level concept

Trace two imports

If reporting imports formatting and formatting imports a top-level name from reporting, the latter may be requested before its definition is ready. A cycle in prerequisites describes the analogous ordering obstacle.

Look for a shared lower-level concept

Both modules might use a record type that can be defined independently in a focused module. Confirm tests import each entry directly. Import behavior identifies initialization beyond definitions.[1]

References

  1. Python Software Foundation, Python Tutorial: Classes ↩