Skip to content

Commit 25a93e3

Browse files
committed
fix: remove hardcoded src prefix from package imports
The handler discovery and dependency resolver were using hardcoded 'src.application', 'src.domain', 'src.infrastructure' paths which don't exist when the package is installed via pip. When installed, the package structure is: - application/ (not src.application) - domain/ - infrastructure/ This caused handler discovery to fail with 'No matches found for pattern: src' when running the CLI from an installed package. Changes: - HandlerDiscoveryService: Changed default base_package from 'src.application' to 'application' (line 96) - HandlerDiscoveryService: Fixed fallback discovery path (line 339) - DependencyResolver: Removed 'src.' prefix from fallback import locations (lines 356-358) Fixes CLI import errors when package is installed via pip install.
1 parent e94ebb3 commit 25a93e3

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/infrastructure/di/components/dependency_resolver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,9 @@ def _resolve_string_annotation(self, annotation: str, context_class: type) -> ty
353353
# Last resort: try to import from common locations
354354
for module_name in [
355355
"typing",
356-
"src.domain",
357-
"src.application",
358-
"src.infrastructure",
356+
"domain",
357+
"application",
358+
"infrastructure",
359359
]:
360360
try:
361361
module_obj = __import__(module_name, fromlist=[annotation])

src/infrastructure/di/handler_discovery.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def _resolve_cache_path_fallback(self) -> str:
9393
os.makedirs(cache_dir, exist_ok=True)
9494
return os.path.join(cache_dir, "handler_discovery.json")
9595

96-
def discover_and_register_handlers(self, base_package: str = "src.application") -> None:
96+
def discover_and_register_handlers(self, base_package: str = "application") -> None:
9797
"""
9898
Discover all handlers and register them with the DI container.
9999
Uses caching to improve performance on subsequent runs.
@@ -336,7 +336,7 @@ def _register_handlers_from_cache(self, cached_handlers: dict[str, Any]) -> None
336336
def _fallback_to_full_discovery(self) -> None:
337337
"""Fall back to full discovery if cache loading fails."""
338338
logger.info("Falling back to full handler discovery")
339-
self._discover_handlers("src.application")
339+
self._discover_handlers("application")
340340
self._register_handlers()
341341

342342
def _get_source_file_mtimes(self, base_package: str) -> dict[str, float]:

0 commit comments

Comments
 (0)