Private
Public Access
refactor(consumers): replace 'models.<moved_class>' with direct imports
Per post_module_taxonomy_de_cruft_20260627 Phase 2 (FR7 continued).
The previous migration commit (8f11340b) handled the
'from src.models import X' pattern (85 sites). This commit handles
the 'models.<moved_class>' attribute access pattern (44 sites in 20
files), which the __getattr__ shim previously supported.
The migration was performed by the one-time script
scripts/tier2/artifacts/post_module_taxonomy_de_cruft_20260627/migrate_models_attr.py
which:
1. For each 'models.<moved_class>' reference, replaces it with the
bare class name (e.g., 'models.MCPConfiguration' -> 'MCPConfiguration')
2. Adds the import 'from src.<destination> import <moved_class>' at
the top of the file (deduplicated if the import already exists)
3. Skips moved classes that the file already imports directly
The migration script inserts the import after the 'from __future__
import annotations' line if present; otherwise it adds the import
to the destination module's existing import block. Two files
required manual fixes because the script's regex didn't handle them:
- src/rag_engine.py: uses 'from src import models' (not 'from
src.models import X'); the class is accessed
via 'models.RAGConfig'. Replaced with a
direct 'from src.mcp_client import RAGConfig'
import and removed the 'from src import models'.
- tests/test_project_context_20260627.py: uses the parens-style
multi-line 'from src.models import (X, Y, Z)'.
Replaced with the parens-style direct import.
After this commit:
- 'models.MCPConfiguration', 'models.FileItem', 'models.Ticket', etc.
no longer work in src/ and tests/ (the AttributeError raises
because models.py no longer has the __getattr__ entries for
moved classes)
- All consumer files have direct imports of the moved classes
Total: 44 'models.<moved_class>' references rewritten across 20 files.
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
Phase 1 of metadata_promotion_20260624.
|
||||
|
||||
Verifies:
|
||||
1. self.active_tickets load boundaries convert dicts to models.Ticket
|
||||
2. conductor_tech_lead.topological_sort returns list[models.Ticket]
|
||||
1. self.active_tickets load boundaries convert dicts to Ticket
|
||||
2. conductor_tech_lead.topological_sort returns list[Ticket]
|
||||
3. gui_2.py consumer sites use direct field access (not .get())
|
||||
4. app_controller.py consumer sites use direct field access (not .get())
|
||||
"""
|
||||
@@ -15,11 +15,11 @@ from src.mma import Ticket
|
||||
|
||||
class TestActiveTicketsType:
|
||||
def test_active_tickets_annotation_is_list_of_ticket(self) -> None:
|
||||
"""self.active_tickets type hint must be list[models.Ticket], not list[Metadata]."""
|
||||
"""self.active_tickets type hint must be list[Ticket], not list[Metadata]."""
|
||||
from src.app_controller import AppController
|
||||
src_text = inspect.getsource(AppController.__init__)
|
||||
assert "list[models.Ticket]" in src_text, (
|
||||
"AppController.__init__ must declare self.active_tickets: list[models.Ticket]"
|
||||
assert "list[Ticket]" in src_text, (
|
||||
"AppController.__init__ must declare self.active_tickets: list[Ticket]"
|
||||
)
|
||||
assert "list[Metadata]" not in src_text.split("self.active_tickets")[1].split("\n")[0], (
|
||||
"AppController.__init__ must NOT declare self.active_tickets: list[Metadata]"
|
||||
@@ -28,7 +28,7 @@ class TestActiveTicketsType:
|
||||
|
||||
class TestActiveTicketsLoadBoundaries:
|
||||
def test_load_at_data_converts_dicts_to_tickets(self) -> None:
|
||||
"""_deserialize_active_track_result boundary must wrap dicts as models.Ticket."""
|
||||
"""_deserialize_active_track_result boundary must wrap dicts as Ticket."""
|
||||
from src.app_controller import AppController
|
||||
with patch.object(AppController, "load_config", return_value={
|
||||
'ai': {'provider': 'gemini', 'model': 'gemini-2.5-flash-lite'},
|
||||
@@ -56,7 +56,7 @@ class TestActiveTicketsLoadBoundaries:
|
||||
)
|
||||
|
||||
def test_load_active_tickets_beads_branch_converts_dicts_to_tickets(self) -> None:
|
||||
"""_load_active_tickets (beads branch) must wrap bead dicts as models.Ticket."""
|
||||
"""_load_active_tickets (beads branch) must wrap bead dicts as Ticket."""
|
||||
from src.app_controller import AppController
|
||||
from src.mma import Ticket
|
||||
ctrl = AppController.__new__(AppController)
|
||||
@@ -79,7 +79,7 @@ class TestActiveTicketsLoadBoundaries:
|
||||
|
||||
class TestTopologicalSortReturnsTicketList:
|
||||
def test_topological_sort_returns_ticket_instances(self) -> None:
|
||||
"""conductor_tech_lead.topological_sort must return list[models.Ticket]."""
|
||||
"""conductor_tech_lead.topological_sort must return list[Ticket]."""
|
||||
from src import conductor_tech_lead
|
||||
sig = inspect.signature(conductor_tech_lead.topological_sort)
|
||||
assert sig.return_annotation is not inspect.Signature.empty
|
||||
|
||||
Reference in New Issue
Block a user