relate: b235f924 --BUILDS_ON--> 30d490e1

This commit is contained in:
Cal Corum 2026-02-25 16:44:42 -06:00
parent 8d22bece68
commit da76f32dae
3 changed files with 26 additions and 2 deletions

View File

@ -6,7 +6,13 @@ tags: [python, refactoring, architecture, imports, paper-dynasty]
importance: 0.7
confidence: 0.8
created: "2026-02-25T22:44:36.786104+00:00"
updated: "2026-02-25T22:44:36.786104+00:00"
updated: "2026-02-25T22:44:42.053812+00:00"
relations:
- target: b235f924-b532-40cd-be39-4fb765938add
type: BUILDS_ON
direction: incoming
strength: 0.8
edge_id: c7805bed-d50e-4016-b518-c0be2094d687
---
## Decision\nWhen moving code to a new module location, do NOT add re-exports in the original file for backwards compatibility.\n\n## Rationale\nRe-exports (e.g. adding `from batters.models import BattingCardRatingsModel` in the old `calcs_batter.py`) create ongoing tech debt and obscure true import paths, making future refactoring harder.\n\n## Practice\nFind every call site and update the import directly to point to the new location.\n\n## Applied In (paper-dynasty/card-creation)\nAfter extracting to `batters/models.py` and `pitchers/models.py`, these files were updated:\n- `batters/card_builder.py` — updated import to `batters.models`\n- `pitchers/card_builder.py` — updated import to `pitchers.models`\n- `tests/test_batter_calcs.py` — updated `bp_singles`, `wh_singles` imports from `calcs_batter``batters.models`\n\n## Discovery tip\nA full-repo grep for the old module path (e.g. `from batters.calcs_batter import`) catches all call sites before you finalise the refactor.

View File

@ -0,0 +1,13 @@
---
id: c7805bed-d50e-4016-b518-c0be2094d687
type: BUILDS_ON
from_id: b235f924-b532-40cd-be39-4fb765938add
from_title: "Break circular imports by extracting shared models to models.py"
to_id: 30d490e1-5ae8-4db8-a238-8973a09f99d1
to_title: "No re-exports when refactoring imports — update call sites directly"
strength: 0.8
created: "2026-02-25T22:44:42.053812+00:00"
updated: "2026-02-25T22:44:42.053812+00:00"
---
The no-re-exports decision is the correct follow-through step after breaking circular imports via models.py extraction

View File

@ -6,13 +6,18 @@ tags: [python, circular-imports, architecture, refactoring, paper-dynasty]
importance: 0.8
confidence: 0.8
created: "2026-02-25T22:44:18.326495+00:00"
updated: "2026-02-25T22:44:41.938081+00:00"
updated: "2026-02-25T22:44:42.053812+00:00"
relations:
- target: 9c7873fa-2c4e-4058-a315-cefb3c02788a
type: BUILDS_ON
direction: outgoing
strength: 0.8
edge_id: 45342806-cdc6-478e-aa38-4294045aafe8
- target: 30d490e1-5ae8-4db8-a238-8973a09f99d1
type: BUILDS_ON
direction: outgoing
strength: 0.8
edge_id: c7805bed-d50e-4016-b518-c0be2094d687
---
## Problem\nTwo modules mutually importing from each other (A imports from B, B imports from A) creates circular import errors.\n\n## Solution\nExtract the shared types/classes into a third dedicated `models.py`. Both A and B then import from `models.py`, breaking the cycle.\n\n## Applied In\npaper-dynasty/card-creation (feature/fullcard-migration branch):\n- `batters/calcs_batter.py` and `batters/card_builder.py` both needed `BattingCardRatingsModel`\n- Extracted it to `batters/models.py`\n- Same pattern applied for `pitchers/models.py`\n\n## Result\n- Eliminates lazy/function-body imports (which are an anti-pattern workaround)\n- Clean module-level imports throughout\n- No circular dependency