Repository navigation
fix(resolver): reject over-deep Python relative imports - #24
Draft
JohnXu22786 wants to merge 3 commits into
Draft
JohnXu22786 wants to merge 3 commits into
JohnXu22786 wants to merge 3 commits into
Conversation
Bound dot-relative traversal to the source package depth so invalid imports remain unresolved and dot-only imports cannot abort indexing.
Keep call resolution from reconstructing an invalid relative import after module resolution correctly rejects it.
Allow valid relative imports from projects whose root is a package while retaining the package-depth boundary for invalid traversal.
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.
What this PR does
Before this PR:
Python relative-import levels were not bounded by the effective package depth. Invalid imports could resolve to root-level files, dot-only forms could raise
ValueErrorand abort indexing, and valid relative imports from a project whose root is itself a package were rejected.After this PR:
Both module resolution and imported-file traversal account for a root
__init__.py, reject levels beyond the effective package depth, and resolve root-level dot-only imports to the package initializer. Regression coverage exercises invalid traversal, indexing safety, imported-file calls, and valid root-package imports.Type of change
fix