Skip to content

fix(resolver): reject over-deep Python relative imports - #24

Draft
JohnXu22786 wants to merge 3 commits into
mainfrom
fix/reject-invalid-python-relative-import
Draft

JohnXu22786 wants to merge 3 commits into
mainfrom
fix/reject-invalid-python-relative-import

Conversation

@JohnXu22786

@JohnXu22786 JohnXu22786 commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

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 ValueError and 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

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.
@JohnXu22786 JohnXu22786 reopened this Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant