Skip to content

[Bug]: INFERRED calls edge links a name imported from a third-party package to a same-named local definition in another file #5229

Closed

Description

@straz

Pre-flight checks

  • 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.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.

**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.

Graphify version

graphifyy 0.9.109 (Python, AST extraction)

Operating System

macOS

Python Version

3.12

Installation Method

uv tool install (recommended)

Additional Environment Details

No response

Additional context

No response

Activity

  1. added
    bug
    on Nov 15, 2026
  2. github-actions commented on Nov 15, 2026

    @github-actions

    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.

  3. Arav-Arun commented on Nov 15, 2026

    @Arav-Arun
    Contributor

    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.

  4. added a commit that references this issue on Nov 21, 2026
    2387b2f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions