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
[Bug]: INFERRED calls edge links a name imported from a third-party package to a same-named local definition in another file #5229
I have checked the Troubleshooting section in the README
What happened?
What happens
When file A imports a name from a third-party package and file B in the same repository defines its own
function or class with that name, graphify adds an INFERRED calls edge from A's caller to B's
definition. The two are unrelated: A's call resolves to the package, not to B. These edges then appear
under "Surprising Connections" in GRAPH_REPORT.md, where they look like real coupling between modules.
Possibly related: the 4 external_reference_edges the diagnostic reports suggest external names are
recognized in some paths but not in this one.
Steps to reproduce
**Minimal example**`app/migrate.py`:
from sqlalchemy import text
def check(connection):
return connection.execute(text("SELECT 1"))
`tools/convert.py`:
def text(graph, subject, predicate):
"""An RDF literal's text."""
...
Result: `check()` --calls-->`text()` [INFERRED], app/migrate.py → tools/convert.pyThe same happens with classes: a file doing `from rdflib import Graph` and calling `Graph()` was linkedto an unrelated `@dataclass class Graph` defined in another module of the repo.**Expected**No edge. A name bound by `from <package> import <name>`in the calling file resolves to that package; a same-named definition elsewhere in the repository should not be a candidate unless the caller imports it from that module. If resolution is uncertain, AMBIGUOUS would be better than INFERRED.**Why it matters**In our graph of about 3,000 nodes, two of the top five "Surprising Connections" were edges of this kind, in each of three builds. Because the report ranks them as surprising, they draw review time first.
Error output or graph output
Result: `check()` --calls--> `text()` [INFERRED], app/migrate.py → tools/convert.py
The same happens with classes: a file doing `from rdflib import Graph` and calling `Graph()` was linked to an unrelated `@dataclass class Graph` defined in another module of the repo.
I reproduced this on v8 at aaafbb4 and have a focused local fix. It constrains direct-call fallback for top-level from ... import ... bindings to the imported symbol and module, including aliases, while preserving valid internal calls.
The 13 regression cases cover function/class imports, aliases, relative paths, warm caches and incremental resolution. They pass on Python 3.10, 3.13 and 3.14; nine fail without the fix. I'll link a PR here once it is ready.
Activity
github-actions commentedon Nov 15, 2026
Thanks for opening this issue, @straz. 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.
Arav-Arun commentedon Nov 15, 2026
I reproduced this on v8 at aaafbb4 and have a focused local fix. It constrains direct-call fallback for top-level
from ... import ...bindings to the imported symbol and module, including aliases, while preserving valid internal calls.The 13 regression cases cover function/class imports, aliases, relative paths, warm caches and incremental resolution. They pass on Python 3.10, 3.13 and 3.14; nine fail without the fix. I'll link a PR here once it is ready.
chore(release): fold AST schema 51 and changelog for the #5367..#5364 …
fix(python): constrain cross-file calls to explicit import bindings