Skip to content

References to names from a module that is star-imported resolve to the module symbol, not the definition #247

Open

Description

@ottawa-dan

Summary

When a module does from a import *, every reference in that module to a name defined in a is emitted with the module symbol (a/__init__:) instead of the symbol of the function or variable. This happens even when the same name is also imported explicitly on the next line. Consumers that build call or reference graphs from the index lose all symbol-level edges into a from that file; only the file-level link survives.

Repro

a.py

X = 1
def f():
    return 1

star.py

from a import *
from a import f
def g():
    return f() + X

plain.py

from a import f, X
def g():
    return f() + X
scip-python index --project-name t --project-version 1

Occurrences on the return f() + X line (symbol suffix shown):

file f X
plain.py a/f(). a/X.
star.py a/__init__: a/__init__:

Expected

star.py references resolve to a/f(). and a/X., as in plain.py.

Impact seen on a real project

In a project whose modules each start with from core import * followed by explicit imports, 12 of 20 sampled direct cross-file calls into core were recorded against core/__init__:. In one such file, 115 occurrences pointed at the module symbol and 7 at a specific symbol. A project without star imports scored 20 of 20 on the same check.

Environment

@sourcegraph/scip-python@0.6.8 via npx, Node 22.22.0, Linux x86_64.

Activity

  1. linear-code commented on Nov 15, 2026

    @linear-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions