Skip to content

fix: parse python relative import shorthand#10

Merged
thegdsks merged 1 commit intoglincker:masterfrom
atharvasingh7007:fix/python-relative-import-shorthand
Apr 11, 2026
Merged

fix: parse python relative import shorthand#10
thegdsks merged 1 commit intoglincker:masterfrom
atharvasingh7007:fix/python-relative-import-shorthand

Conversation

@atharvasingh7007
Copy link
Copy Markdown
Contributor

Summary

  • parse Python shorthand relative imports like from . import models and from .. import utils as ".models" and "..utils"
  • add parser coverage for shorthand relative imports
  • add graph coverage showing those parsed imports resolve to internal module edges

Root cause

import_from_statement only recorded the module_name field. For shorthand relative imports, tree-sitter exposes that field as just . or .., so Stacklit dropped the imported module name and stored bare relative markers in info.Imports. That meant stacklit.json and DEPENDENCIES.md missed valid internal edges for common Python package layouts.

Impact

Python projects that use from . import module or from .. import package now produce correct dependency edges without any CLI or schema changes.

Validation

  • go test ./...
  • go build -o stacklit.exe ./cmd/stacklit
  • manual sanity run on a temporary Python package using from . import models and from .. import shared

@atharvasingh7007 atharvasingh7007 marked this pull request as ready for review April 11, 2026 20:59
Copy link
Copy Markdown
Member

@thegdsks thegdsks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, nice catch on the shorthand form. Thanks for the contribution.

@thegdsks thegdsks added bug Something isn't working community External contributor parser Import/export parsing logic python Python language support labels Apr 11, 2026
@thegdsks thegdsks merged commit dd9c6bf into glincker:master Apr 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working community External contributor parser Import/export parsing logic python Python language support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants