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.01k stars 35 forks source link

Dependencies not generated correctly when external import have same name as file in <root> #262

Closed sparshg closed 3 weeks ago

sparshg commented 3 weeks ago
Confirm Your Modules                                                                      │
│└── -> manim ∨                                                                           │
│    └── [Source Root] manim ∨                                                            │
│        ├── __main__.py                                                                  │
│        ├── [Module] _config ∨                                                           │
│        │   ├── cli_colors.py                                                            │
│        │   ├── logger_utils.py                                                          │
│        │   └── utils.py                                                                 │
│        ├── typing.py
>>> tach report manim/_config/utils.py

[ Dependency Report for 'manim/_config/utils.py' ]
-------------------------------
[ Dependencies of 'manim/_config/utils.py' ]
manim/_config/utils.py[L25]: Import 'typing.TYPE_CHECKING'
manim/_config/utils.py[L25]: Import 'typing.Any'
...

Tach is detecting manim/_config/utils.py to depend on manim/typing.py instead of builtin typing module, hence generating wrong dependencies.

emdoyle commented 3 weeks ago

Should the source root be one level above in your first quote? When I interpret that config, I would actually expect for that typing.py file to shadow the stdlib typing module. If that file is actually being imported as manim.typing, then I'd expect the source root to be on the outer manim folder.

sparshg commented 3 weeks ago

True, the source should have been one level up, working as expected