Skip to content

Resolve call receivers through declared and inferred types - #728

Open
jaywyawhare wants to merge 1 commit into
hydra-db:fix/resolve-self-importsfrom
jaywyawhare:feat/resolve-receiver-types
Open

jaywyawhare wants to merge 1 commit into
hydra-db:fix/resolve-self-importsfrom
jaywyawhare:feat/resolve-receiver-types

Conversation

@jaywyawhare

@jaywyawhare jaywyawhare commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Resolve variable.method() calls whose receiver type is plain from the code: constructors, declared return types, annotations, typed attributes and class fields, call results, and short typed chains, with member lookup through bases and mixins. Ambiguous receivers still resolve to nothing, and precision holds on every corpus root. Stacked on #727.

Implementation details

Decisions

  • Variables and attributes resolve through declared types (which win over later unknown reassignments), annotated self.x: T attributes, properties and getters by return type, TS private #fields, both arms of a conditional, walrus bindings, arrow and function expression return types, Final[...] and ClassVar[...], and quoted types such as list["Text"].
  • Generic bases (Base[int]), export { X as Y } aliases, and TS type aliases are followed for member lookup. new Foo().bar() and Foo(x).run() chains resolve.
  • Imports track whether a name is used as a type or a value, so a typed const beside a same-named interface resolves through the const's type.
  • Unions, untyped parameters, disagreeing untyped assignments, and contextually typed callback parameters still resolve to nothing.
  • A shared fixture, tests/fixtures/code-types, has exact-edge tests in both SDKs and a code_types conformance case.
  • benchmarks/code/README.md results are rerun with run_corpus.py --self; notes for fixed causes are removed and the rest rewritten.

Results on the pinned corpus (precision / recall, %, after #727 then here)

Root After #727 Here
hono 99.8 / 75.1 99.8 / 94.3
zod 100 / 85.9 100 / 92.5
rich 99.9 / 94.5 100.0 / 96.7
aiohttp 100 / 90.5 100 / 95.3
sanic 100 / 90.9 100 / 93.4
typer 100 / 96.0 100 / 97.1
typescript/src 100 / 95.7 100 / 97.9
fp-ts 100 / 99.0 100 / 99.8

requests, ky, and src/selfgraph are unchanged. Strict precision dips slightly in sanic and aiohttp because of new calls through declared abstract types and blueprint mixins that Jedi finds no in-root target for; there are no new disagreements.

Validation

  • The new tests fail on base and pass here.
  • scripts/precheck.py passes (498 changed lines, clean trial merge).
  • Full suites on Kuzu pass: Python 1,788 passed, TypeScript 1,467 passed. Ruff, lint, and typecheck pass.

Limits

No flow-sensitive narrowing, destructured names, classes built by a function call, or conditional imports. hono's router.match stays a reference difference: the checker follows a function assigned to a class field, the resolver the declared Router interface. rich keeps one subclass-override pick.

Linked issue

Closes #726

AI Assistance

AI tools helped write and test parts of this. I reviewed and ran every change.

Checklist

  • Implements an issue a maintainer has /approved.
  • Small and scoped to that issue.
  • New errors have a code and hint, the same on API, CLI, and MCP in both SDKs (see AGENTS.md). No new codes.
  • Breaking changes described below, or none.

Breaking changes

None. Some calls that resolved to nothing now get a CALLS or CONSTRUCTS edge, and zod-style calls now link to the value instead of the same-named type.


Run Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@arrry-hydraDB arrry-hydraDB added feature New capability area: parity Python vs TypeScript, conformance effort: M Several files, both SDKs labels Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: parity Python vs TypeScript, conformance effort: M Several files, both SDKs feature New capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants