Skip to content

Python function-local imports can produce calls to unrelated same-named functions #5421

Open

Description

@melhusl-hs

Reproduction

With Graphify v0.9.118, extract this Python module:

def main():
    pass

def caller():
    from absent_external_package import main
    main()

The extracted graph includes a caller → main call edge to the function defined in this file. Python instead binds main in caller to the imported symbol, so that local function is not its target.

A related relative-import case also leaks the binding into unrelated functions: when caller imports target from .helper, another function calling this module's own target can receive an extra edge to helper.target.

Expected behavior

Resolve function-local imports only within their lexical scope, and do not guess a same-named local or corpus target when the imported module is outside the scanned corpus. Preserve genuine calls to the local function and resolvable relative imports.

Evidence

Reproduced against release v0.9.118 (commit 5ce8fceff41d1b636f872b6206b917ec2af7ac54) with a synthetic corpus. The open function-parameter fix #5419 does not cover this import-binding case.

Activity

  1. github-actions commented on Nov 23, 2026

    @github-actions

    Thanks for opening this issue, @melhusl-hs. 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.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions