Skip to content

[Feature]: Python: self.m() / super().m() / cls.m() get no calls edge when m is defined on a base class in another file #4221

Closed

Description

@rohit-jsfreaky

Problem or use case

The in-file pass (_self_call_target) walks base classes declared in the same file, so this works:

class Base:
    def m(self): ...

class C(Base):
    def run(self):
        return self.m()      # C.run -> Base.m  (same file: edge)

When the base class is imported from another module, the call gets no edge at all:

# flask/app.py
from .sansio.app import App

class Flask(App):
    def __init__(self, ...):
        super().__init__(...)            # no edge to App.__init__
        self.add_url_rule(...)           # no edge to App.add_url_rule (defined on App)

    def handle_exception(self, e):
        handler = self._find_error_handler(...)   # no edge to App._find_error_handler

That is the normal shape of any project that splits a base class into its own module, so affected App._find_error_handler misses its callers in subclasses. Measured against jedi on 0.9.80, Flask has 162 / 243 real call pairs (66.7%), the lowest of httpx / click / flask, and inherited calls are a large part of the gap.

Proposed solution

In _resolve_python_member_calls, for a self.m(), cls.m() or bare super().m() raw call the in-file pass could not bind, walk the caller's class up its inherits edges and bind the first class that owns m (nearest first, as in the MRO). Fail closed, no edge, when the order is not certain:

  • a class with two or more bases (MRO across files is not modelled),
  • a base the edge list cannot show (mod.Base, Generic[T], a call; only bare-name bases become inherits edges),
  • a base outside the corpus, or a self-loop base,
  • the caller's own base is neither defined in nor imported by the caller's file,
  • super(Cls, obj).m() with arguments (its MRO starts after Cls, not after the caller's class).

Alternatives considered

  • Bind self.m() to any method named m in the corpus: the god-node collision the shared pass skips on purpose.
  • Model the full C3 MRO across files: possible, but multiple inheritance across modules is rare in practice and much harder to get exactly right; single inheritance covers the cases measured.

Area

Extraction or language support

Are you willing to submit a PR?

Yes, I can work on this

Compatibility / behavior impact

  • Adds calls edges only (EXTRACTED, the same rule the in-file base walk already uses). No node id or existing edge changes.
  • Python class nodes with a base that is not a bare name get metadata.python_opaque_bases: true; that key is forwarded on changed-files rebuilds like ruby_lookup_unsafe.
  • Raw calls gain _python_super_args for super(...) with arguments. AST cache schema 6 -> 7.
  • A changed-files rebuild gives the same edges as a full build (tested both ways).

Additional context

PR right after this issue. 0.9.80 (6478eb7), Windows 11, Python 3.12.12.

Activity

  1. added
    enhancement
    on Oct 8, 2026
  2. github-actions commented on Oct 8, 2026

    @github-actions

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

  3. safishamsi commented on Oct 8, 2026

    @safishamsi
    Member

    Fixed by #4222 (thanks @rohit-jsfreaky), shipped in v0.9.81. Closing as resolved.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions