You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Import builder resolves bare to a same-stem local module (captures stdlib) #4261
graphify's import-graph builder resolves a bare import <name> to a local module that shares the same stem, which captures stdlib imports as if they pointed at local files.
Repro
In a repo with a file at pipeline/common/logging.py (any module whose stem collides with a stdlib top-level name), a bare import logging anywhere in the tree is recorded as an edge whose target resolves to that local pipeline/common/logging.py, not to stdlib logging.
Measured on one real corpus before we worked around it:
logging: 853 edges landed on pipeline/common/logging.py
types: 60 edges → pipeline/common/types.py
io: 9 edges → pipeline/common/io.py
total 922 fabricated stdlib→local edges
Why it's wrong
A bare import resolves from sys.path, so a module nested under the repo root can never be its target. The result is a fabricated import cycle and logging.py becoming the graph's top hub.
Suggested fix
Prefer a real path/package match over a bare-stem match when resolving an import target. The local workaround we currently carry is a post-extraction filter (filter_stdlib_name_collision_edges), which we'd like to delete once upstream resolves bare-stem imports correctly.
Reported by a downstream consumer of the graphify CLI (pipx graphifyy).
Fixed in 0.9.84 (now on PyPI). A bare import logging is no longer captured by a loose same-named module (scripts/logging.py) in a non-package directory; it resolves to the stdlib module. The guard uses a vendored, deterministic stdlib-name set (not the host's live sys.stdlib_module_names, so extraction stays reproducible across machines and interpreter versions) and is applied at the module resolver, the sibling-repoint pass, and the build-time stem-alias index. A deliberate package shadow (logging/__init__.py) still resolves. Thanks, @waynegault.
Activity
github-actions commentedon Oct 9, 2026
Thanks for opening this issue, @waynegault. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
fix(python): stop a stdlib-named loose module from capturing a bare i…
docs(changelog): fold #4039/#4261/#4269/#4247/#4262 into 0.9.84
safishamsi commentedon Oct 10, 2026
Fixed in 0.9.84 (now on PyPI). A bare
import loggingis no longer captured by a loose same-named module (scripts/logging.py) in a non-package directory; it resolves to the stdlib module. The guard uses a vendored, deterministic stdlib-name set (not the host's livesys.stdlib_module_names, so extraction stays reproducible across machines and interpreter versions) and is applied at the module resolver, the sibling-repoint pass, and the build-time stem-alias index. A deliberate package shadow (logging/__init__.py) still resolves. Thanks, @waynegault.fix(c): resolve directory-qualified angle includes and keep standard …