Repository navigation
Description
graphifyy==0.9.68 (uv tool), Python 3.11, macOS. AST only (--code-only --no-cluster), no LLM.
Summary
In a monorepo, a team often scans only its own subfolder. Python imports in that subfolder are still absolute from the repo root, so they carry a prefix that does not exist under the scan root. The imports_from edge then targets a dotted-name id that matches no node, the receiver is never bound to the local module, and every mod.func() call through it loses its calls edge.
The files are byte-identical in both runs below. Only the scan root changes.
Minimal reproducer
Company/__init__.py (empty)
Company/Apps/__init__.py (empty)
Company/Apps/Jobs/__init__.py (empty)
Company/Apps/Jobs/Team/__init__.py (empty)
Company/Apps/Jobs/Team/lib/__init__.py (empty)
Company/Apps/Jobs/Team/app/__init__.py (empty)
Company/Apps/Jobs/Team/lib/delivery.py
Company/Apps/Jobs/Team/app/main.py
# Company/Apps/Jobs/Team/lib/delivery.py
def deliver(files):
return len(files)# Company/Apps/Jobs/Team/app/main.py
from Company.Apps.Jobs.Team.lib import delivery
def run():
return delivery.deliver(["a"])Scan from the import root: works
cd <root> && graphify extract . --code-only --no-clusterimports_from: company_apps_jobs_team_lib_init, company_apps_jobs_team_lib_delivery
calls: company_apps_jobs_team_app_main_run -> company_apps_jobs_team_lib_delivery_deliver
Scan from the team subfolder: no calls edge
cd <root>/Company/Apps/Jobs/Team && graphify extract . --code-only --no-clusterimports_from: company_apps_jobs_team_lib (no node with this id)
calls: (none)
Expected
With Team/ as the scan root, Company.Apps.Jobs.Team.lib should resolve to the local lib/ package, and run() should get calls -> lib_delivery_deliver.
Why this is not a duplicate
- Python: _import_python's absolute import arm skips the path resolution the relative arm does, so package __init__.py nodes lose their in-edges #3723, fixed in 0.9.67, resolves absolute package imports within the scan root. Here the dotted name has a prefix above the scan root, so that fix never matches.
- Python:
from <pkg> import <submodule>binds to the package__init__.pyand drops the submodule + allmod.attr()calls when the importer is outside the package tree #3272 isfrom pkg import submodulebinding to__init__.pywhen the importer is outside the package tree. This repro uses a plain module, not a submodule of a package, and still fails. On the real repo both happen together:lib/delivery/is a package whose__init__.pyre-exportsdeliver. - Python: three independent causes drop
mod.func()calls edges — 177/177 unresolved on a real repo (explains #2428 §3's unexplained 42%) #2447 cause A is the same family (id derived from the module name, not the path) for plainimport mod. This one isimport_from_statement.
Real impact
On a private repo, scanning one team's 349-file subfolder gave 0 incoming calls edges for a shared helper that is called from 4 automation files. That is the impact analysis case the scope was chosen for. In the reproducer, scanning from the import root restores the edge. On the real repo that means indexing the whole monorepo, which is what the subfolder scan was avoiding.
Suggestion
Either one would work for this layout:
- Probe the dotted name after stripping leading components until the rest resolves under the scan root, when the stripped prefix matches the scan root's own path relative to a parent that has
__init__.pyfiles up the chain. - An explicit option, for example
--python-root <dir>or a.graphifyconfig key, that tells the resolver which directory absolute imports are relative to.
Option 2 is smaller and has no guessing.
Activity
fix(python): resolve nested scan-root imports via namespace projection (
fix(python): resolve nested scan-root imports via namespace projection (
fix(python): resolve nested scan-root imports via namespace projection (
safishamsi commentedon Sep 27, 2026
Fixed in v0.9.70 (now on PyPI) by #3867 — thanks @nikhilsaxena04.
Release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.70