diff --git a/graph/decisions/no-re-exports-when-refactoring-imports-update-call-sites-dir-30d490.md b/graph/decisions/no-re-exports-when-refactoring-imports-update-call-sites-dir-30d490.md index 4bf5590cd0c..3ec47ed7817 100644 --- a/graph/decisions/no-re-exports-when-refactoring-imports-update-call-sites-dir-30d490.md +++ b/graph/decisions/no-re-exports-when-refactoring-imports-update-call-sites-dir-30d490.md @@ -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. diff --git a/graph/edges/break-circular-imports-by-extr--BUILDS_ON--no-re-exports-when-refactoring-c7805b.md b/graph/edges/break-circular-imports-by-extr--BUILDS_ON--no-re-exports-when-refactoring-c7805b.md new file mode 100644 index 00000000000..1709be7985e --- /dev/null +++ b/graph/edges/break-circular-imports-by-extr--BUILDS_ON--no-re-exports-when-refactoring-c7805b.md @@ -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 diff --git a/graph/solutions/break-circular-imports-by-extracting-shared-models-to-models-b235f9.md b/graph/solutions/break-circular-imports-by-extracting-shared-models-to-models-b235f9.md index 58177bccee2..3d33cd46ae8 100644 --- a/graph/solutions/break-circular-imports-by-extracting-shared-models-to-models-b235f9.md +++ b/graph/solutions/break-circular-imports-by-extracting-shared-models-to-models-b235f9.md @@ -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