claude-memory/graph/solutions/circular-import-fix-move-shared-utilities-to-standalone-modu-1c7958.md
Cal Corum b140d4d82a migrate: 313 memories from MemoryGraph
- 313 new markdown files created
- 30 relationships embedded
- 313 entries indexed
- State initialized with usage data
2026-02-13 11:11:48 -06:00

1.2 KiB

id type title tags importance confidence created updated relations
1c795804-d2bd-4ace-8de8-aea4819424f0 solution Circular import fix: move shared utilities to standalone module
python
circular-import
architecture
fix
paper-dynasty
discord-bot
0.85 0.8 2026-02-04T15:53:22.670768+00:00 2026-02-04T15:53:22.670768+00:00
target type direction strength
5d8e1ff5-3354-4cfa-ab63-bf96b5ce1e01 CAUSES incoming 0.5

When two modules import from each other, create a standalone module for shared utilities. In Paper Dynasty, utilities/dropdown.py and command_logic/logic_gameplay.py had circular imports after adding play lock functions. Solution: Created play_lock.py as standalone module containing release_play_lock() and safe_play_lock(). Both modules now import from play_lock.py. This pattern works for any circular dependency - extract the shared code into a third module that neither original module imports from. Error manifests at runtime as 'cannot import name X from partially initialized module Y (most likely due to a circular import)'. Ruff/linters won't catch this - only runtime execution or tools like pylint with cyclic-import check will detect it.