gauge-sh / tach

A Python tool to enforce dependencies, using modular architecture 🌎 Open source 🐍 Installable via pip πŸ”§ Able to be adopted incrementally - ⚑ Implemented with no runtime impact ♾️ Interoperable with your existing systems πŸ¦€ Written in rust
https://gauge.sh
MIT License
1.16k stars 36 forks source link

Fix handling relative imports at import depth > 1 #373

Closed emdoyle closed 1 month ago

emdoyle commented 1 month ago

During investigation of #370 , I discovered that imports of the form from .. import module were being treated as if they were external imports, even though the package above was within a source root.

This is because the import visitor incorrectly assumed that a missing 'module' from an import AST node indicated a 'within-package' import, without handling parent traversal.

This PR fixes this issue and adds a regression test.