#2074·codegraph

Method values on untyped Python module globals still produce no callers edge (follow-up to #1820)

Author: JosefAschauerCreated Sep 28, 2026Updated Sep 28, 2026

Follow-up to #1820 (fixed on main by #2034 + #2040, not yet released).

Problem

#2034 resolves a method value's receiver through type and import scope. A receiver that is a module global without a static type still produces no edge. A common Python pattern is a module-level singleton that a configuration function rebinds to one of several backends:

python
# settings.py
docStoreConn = None

def init_settings():
    global docStoreConn
    if engine == "elasticsearch":
        docStoreConn = rag.utils.es_conn.ESConnection()
    elif engine == "qdrant":
        from rag.utils import qdrant_conn as qdrant_conn_module
        docStoreConn = qdrant_conn_module.QdrantConnection()
    ...
python
# consumer.py
from common import settings

async def gc(...):
    await thread_pool_exec(settings.docStoreConn.delete_payload_fields, ...)

codegraph callers delete_payload_fields reports no caller for gc, on either the backend method or the base-class declaration. The receiver settings.docStoreConn resolves through the import to a variable node, which is not a class, so the member is never looked up. The unique-name fallback doesn't apply either, because several classes define the method.

Minimal repro

base.py      class DocStoreConnection:
                 def delete_payload_fields(self, pid, keys): raise NotImplementedError("stub")
qdrant.py    from base import DocStoreConnection
             class QdrantConnection(DocStoreConnection):
                 def delete_payload_fields(self, pid, keys): return True
settings.py  docStoreConn = None
             def init_engine(engine):
                 global docStoreConn
                 if engine == "qdrant":
                     from qdrant import QdrantConnection
                     docStoreConn = QdrantConnection()
worker.py    from concurrent.futures import ThreadPoolExecutor
             from base import DocStoreConnection
             import settings
             class Worker:
                 def __init__(self, store: DocStoreConnection): self.store = store
                 def gc_typed(self, pool: ThreadPoolExecutor):
                     return pool.submit(self.store.delete_payload_fields, "p1", ["k"])
             def gc_untyped(pool: ThreadPoolExecutor):
                 return pool.submit(settings.docStoreConn.delete_payload_fields, "p1", ["k"])

On main @ 7506dbf, codegraph callers delete_payload_fields lists gc_typed [references] and nothing for gc_untyped.

Expected

The global's type is the set of classes its module assigns to it, either at module scope or inside a function that declares it global. With one backend, the edge should go to that backend's method. With several backends, it should go to the nearest declaration they all inherit, which is what a base-typed receiver already does. If any assignment is opaque (a factory call, a conditional expression), the type stays unknown and no edge is created, as today.

Related, not addressed here

Callers of an override don't include calls made through a base-typed receiver. In the repro above, QdrantConnection::delete_payload_fields shows 0 callers even though gc_typed's edge lands on DocStoreConnection::delete_payload_fields. This is a query-time dispatch question (should callers/impact of an override also include the callers of the method it overrides?), and I'm leaving it separate.