Skip to content

Fix circular model dependencies and improve schema organization#54

Merged
cmsato09 merged 8 commits into
developmentfrom
2025-07-03-model-reorganize
Jul 8, 2025
Merged

Fix circular model dependencies and improve schema organization#54
cmsato09 merged 8 commits into
developmentfrom
2025-07-03-model-reorganize

Conversation

@cmsato09
Copy link
Copy Markdown
Owner

@cmsato09 cmsato09 commented Jul 8, 2025

Key changes include:

  • Resolved Circular Import Issues: Addressed PydanticUndefinedAnnotation errors that prevented the application from loading due to circular dependencies between monster and skill models. This was primarily fixed by moving API-facing schema models (e.g., MonsterDetailRead, SkillUpgradeRead) into a new src/app/models/dqm1/schemas.py file.
  • Isolating the MonsterSkillLink association table into its own src/app/models/dqm1/associations.py file. This breaks the runtime dependency deadlock between monster.py and skill.py.

cmsato09 added 8 commits July 3, 2025 17:32
- MonsterFamily related models in src/app/models/dqm1/models/monster.py moved to separate file within the same directory
- Moved MonsterFamilyRead related models from monster_family.py to schemas.py
- Moved MonsterDetailRead related models from monster.py
- Moved SkillRead related models from skill.py
- Prevents circular import problem between model files that import each
  other
- Removed MonsterDetailRead related models to schemas.py
- Moved MonsterSkillLink to associations.py
- Moved MonsterFamilyRead class to models/dqm1/schemas.py file
- Moved SkillRead related classes to schemas.py
- Updated import statements
A circular dependency between the `monster` and `skill` models was
causing `PydanticUndefinedAnnotation` and `NoInspectionAvailable`
errors during application startup and testing.

This occurred because the `MonsterSkillLink` association model was
defined in `monster.py` but was needed at runtime by `skill.py`,
creating an import deadlock.

This commit resolves the issue by moving `MonsterSkillLink` to its
own dedicated file, `src/app/models/dqm1/associations.py`. This
breaks the import cycle, as both `monster` and `skill` models can
now safely import the association table from a neutral location.
- Due to changes to model files, import statements using those models
  were changed to reflect it
@cmsato09 cmsato09 merged commit 8c7ea9f into development Jul 8, 2025
12 checks passed
@cmsato09 cmsato09 deleted the 2025-07-03-model-reorganize branch July 8, 2025 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant