feat(parser): Python module-aware import resolution#1
Merged
Conversation
Python dependency detection was broken because imports were resolved by global name lookup only, causing three failures: `import X` never matched module nodes, `from X import Y` had false positives from same-named symbols in other files, and external package imports were silently dropped. Fix by adding module path metadata to Python import relations, then using file-path-constrained resolution in the indexer. External imports now create virtual nodes under an `<external>` pseudo-file so dependency_graph can report them. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
import Xresolution: Resolves module-level imports (import myutils) to the target file's<module>node via dotted-path-to-file-path mappingfrom X import Yconstraint: Constrains symbol lookup to the resolved module's file, eliminating false positives from same-named symbols in other filesexternal_modulenodes under an<external>pseudo-file for unresolved imports (os, flask, etc.), making them visible independency_graphTest plan
test_build_python_module_map— module path mapping (incl.__init__.py, suffix matching)test_python_from_import_resolution—from myapp.utils import helpercross-file edgetest_python_import_module_resolution—import myutilsmodule-level edgetest_python_external_import_creates_virtual_nodes— external imports create<external>nodestest_python_mixed_internal_external_imports— mixed internal + external in one file🤖 Generated with Claude Code