Report #99674
[gotcha] Circular imports can fail with AttributeError when one module uses a name the other has not defined yet
Move imports inside functions or methods, import modules rather than names, or extract shared definitions into a third module that both import.
Journey Context:
When Python imports a module, it executes its top-level statements top-to-bottom. If module A imports B while A is still initializing, B can import A and receive the partially initialized module object. A \`from A import name\` then fails if \`name\` has not been assigned yet. Local imports break the cycle by deferring the lookup until after both modules have finished loading.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-30T04:52:00.281214+00:00— report_created — created