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:
ed
2026-06-26 14:06:03 -04:00
parent 426ba343dd
commit 9e07fac1db
29 changed files with 4706 additions and 140 deletions
+8 -8
View File
@@ -11,8 +11,8 @@ class MockEmbeddingProvider(BaseEmbeddingProvider):
@pytest.fixture
def mock_rag_config():
vs_config = models.VectorStoreConfig(provider='mock', collection_name='test')
return models.RAGConfig(enabled=True, vector_store=vs_config, embedding_provider='gemini')
vs_config = VectorStoreConfig(provider='mock', collection_name='test')
return RAGConfig(enabled=True, vector_store=vs_config, embedding_provider='gemini')
def test_rag_engine_init_mock(mock_rag_config):
engine = RAGEngine(mock_rag_config)
@@ -38,8 +38,8 @@ def test_rag_engine_chroma(mock_get_chroma, mock_embed):
mock_client.get_or_create_collection.return_value = mock_collection
mock_chroma.PersistentClient.return_value = mock_client
vs_config = models.VectorStoreConfig(provider='chroma', collection_name='test')
config = models.RAGConfig(enabled=True, vector_store=vs_config, embedding_provider='local')
vs_config = VectorStoreConfig(provider='chroma', collection_name='test')
config = RAGConfig(enabled=True, vector_store=vs_config, embedding_provider='local')
with patch('src.rag_engine._get_sentence_transformers') as mock_st:
mock_st.return_value = MagicMock()
@@ -97,8 +97,8 @@ def test_rag_collection_dim_mismatch_recreates_collection(mock_get_chroma, mock_
mock_client.get_or_create_collection.return_value = mock_collection
mock_chroma.PersistentClient.return_value = mock_client
vs_config = models.VectorStoreConfig(provider='chroma', collection_name='test')
config = models.RAGConfig(enabled=True, vector_store=vs_config, embedding_provider='local')
vs_config = VectorStoreConfig(provider='chroma', collection_name='test')
config = RAGConfig(enabled=True, vector_store=vs_config, embedding_provider='local')
with patch('src.rag_engine._get_sentence_transformers') as mock_st:
mock_st.return_value = MagicMock()
@@ -136,8 +136,8 @@ def test_rag_collection_dim_match_preserves_collection(mock_get_chroma, mock_emb
mock_client.get_or_create_collection.return_value = mock_collection
mock_chroma.PersistentClient.return_value = mock_client
vs_config = models.VectorStoreConfig(provider='chroma', collection_name='test')
config = models.RAGConfig(enabled=True, vector_store=vs_config, embedding_provider='local')
vs_config = VectorStoreConfig(provider='chroma', collection_name='test')
config = RAGConfig(enabled=True, vector_store=vs_config, embedding_provider='local')
with patch('src.rag_engine._get_sentence_transformers') as mock_st:
mock_st.return_value = MagicMock()