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: calls on module-level class instances get no calls edge (g = Svc(); def f(): g.m()), incl. lowercase class rebound to instance #4970
A method call on a class instance created at module scope gets no calls edge when it's made inside a function. This covers a plain singleton (g = Svc()) and a lowercase class rebound to its own instance (svc = svc(app), a common Flask-style pattern). It's the Python version of #3101 (Pascal) and #1698 (Kotlin).
On a ~1,300-file production backend this drops most calls into core service classes: 102 such rebinds across 57 files. A core write method showed 0 callers where grep finds 8+, and the top-degree nodes came out as schema base classes.
Actual calls edges: only c() -> Svc and c() -> .create(). a() and b() get nothing.
Likely cause (reading v8)
_python_local_class_bindings (extractors/engine.py) collects bindings only from a function's own params and locals. Module-scope assignments never set receiver_type.
With no receiver_type, _resolve_python_member_calls (extract.py ~5331–5364) falls back to two branches. The class branch requires receiver[:1].isupper(), so a lowercase class never takes it. The module branch only matches imported modules. Both miss.
An X = X(...) rebind would also hit the "import + constructor" poisoning rule.
Suggested fix
Collect module-scope name = ClassName(...) bindings and let functions inherit them unless they shadow the name locally. Treat X = X(...), where the right-hand X resolves to exactly one class, as an instance of that class. Emit these edges as INFERRED, like the existing typed-receiver branch.
Activity
github-actions commentedon Nov 3, 2026
Thanks for opening this issue, @shounaksarkar. 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.
fix(extract): resolve Python module instance method calls