Skip to content

Commit e0b5a70

Browse files
committed
fix: resolve Python dotted imports in dependency analyzer
Bug: imports like 'starlette.exceptions' were treated as external because early return checked for '/' but not '.' in import path Fix: only treat single-word imports (os, json) as external Allow dotted imports to reach resolution logic that converts 'starlette.exceptions' → 'starlette/exceptions.py'
1 parent 0298ea4 commit e0b5a70

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

backend/services/dependency_analyzer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,11 @@ def _resolve_import_to_file(
227227
) -> str:
228228
"""Resolve an import to an actual file in the repo"""
229229

230-
# External dependency check
231-
if not import_path.startswith('.') and not import_path.startswith('/'):
232-
# Might still be internal for Python packages
233-
if '/' not in import_path:
234-
return None
230+
# Skip obvious external packages (stdlib, third-party without dots)
231+
# But allow dotted imports like 'starlette.exceptions' to be resolved below
232+
if not import_path.startswith('.') and '.' not in import_path and '/' not in import_path:
233+
# Single-word imports (os, sys, json) are always external
234+
return None
235235

236236
source_path = Path(source_file)
237237
source_dir = source_path.parent

0 commit comments

Comments
 (0)