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
Python: self.x() on an instance attribute links to an unrelated module-level function x #2958
self.x(), where x is an instance attribute holding a callable, links by exact name to a module-level function x anywhere in the project, even in an unrelated file.
create_app in examples/factory.py (resolvedBy: exact-match) ✗
none: it calls whatever was passed in
Reproduced on main at 2577601, with CODEGRAPH_KERNEL=0 and with the native kernel. Linux/WSL2, Node 22.23.2.
Where it shows up. I checked every Python calls edge against jedi's goto-definition and found two cases in flask (d086db8). The first is the core of its CLI: ScriptInfo.load_app in src/flask/cli.py:342 calls self.create_app() (assigned in __init__, line 316), and it links to examples/celery/src/task_app/__init__.py's create_app. So the example app shows up as a callee of Flask's app loading. In the second, self.app(environ, start_response) in tests/test_basic.py:299 links to the app pytest fixture in tests/conftest.py.
Expected. A call with a self./cls. receiver names a member of the instance or class: a method in the class or its bases, or an attribute. It should never fall through to a same-named module-level function in another file. 2577601 made such calls prefer the caller's own class member when one exists; this is the case where none does, and the bare-name match still answers.
Re-checked on main at 60b0d7a (2026-10-29): still reproduces as described.
Two more shapes, found by diffing codegraph's call edges against scip-python:
The target can be a module-level variable, not only a function, in a module the caller never imports. In a PyTorch model, self.out = nn.Linear(h, V) is set in __init__, and forward calls self.out(...). That call links to out = (games.filter(...)), a module-level variable in an unrelated script (labs/nn-nfl-lab/export_features.py:15).
The attribute can be bound by tuple unpacking in setUp. A test binds self.repo, self.run = _git_repo(...) and then calls self.run("git", "add", "-A"). The call links to a free function run in a harness module the test doesn't import.
Minimal form:
# other/features.pydefout(x):
returnx# lab/model.pyclassLayer:
def__call__(self, x):
returnxclassMLP:
def__init__(self):
self.out=Layer()
defforward(self, x):
returnself.out(x) # links to other/features.py: out (exact-match)
I filed this again by mistake as #3039, which is now closed as a duplicate of this issue.
Activity
inth3shadows commentedon Oct 29, 2026
Re-checked on
mainat 60b0d7a (2026-10-29): still reproduces as described.Two more shapes, found by diffing codegraph's call edges against
scip-python:self.out = nn.Linear(h, V)is set in__init__, andforwardcallsself.out(...). That call links toout = (games.filter(...)), a module-level variable in an unrelated script (labs/nn-nfl-lab/export_features.py:15).setUp. A test bindsself.repo, self.run = _git_repo(...)and then callsself.run("git", "add", "-A"). The call links to a free functionrunin a harness module the test doesn't import.Minimal form:
I filed this again by mistake as #3039, which is now closed as a duplicate of this issue.
self.attr(...)on an instance attribute links an unrelated, un-imported module function of the same name #3039 as a duplicate of this issue