Repository navigation
python: a method handed over as a value reaches its target (#1832) - #1968
Open
swapnilpaliwal-sd wants to merge 1 commit into
Open
swapnilpaliwal-sd wants to merge 1 commit into
swapnilpaliwal-sd wants to merge 1 commit into
Conversation
swapnilpaliwal-sd
requested review from
JaredHLZhang,
Whua689 and
suyashpaliwal26
as code owners
October 15, 2026 07:18
A bound or unbound method or a function named as a VALUE and not called (executor.submit(self._work, x), Thread(target=svc.run), sorted(xs, key=self.rank), [h.on_event], partial(svc.cancel, oid), view_func= views.index, return self._handle) had no caller in the Python graph, so impact OrderService.cancel did not name the function that queued it and path said the two were independent. The engine already resolved what each of these expressions denotes; it dropped the answer because no call wrapped it. call-edge-generation/method-reference.dl emits it as a call_chain_edge with kind METHOD_REFERENCE and tier callback_registered, the tier the other front ends use for a function handed over, so answers say "handed over as a value" and never "calls it". Only what is resolved: a typed receiver through the MRO, a class's unbound method, a scoped name, a module member. Refused: an untyped receiver (stays as unresolved as thing.cancel() is), a flowed value (a parameter, a name or attribute assigned from an expression), a property read, a decorator application, the argument of a one-dunder builtin (str(f)), and a comparison operand. Measured on three open-source Python projects used for tuning: 3-4% more resolved caller->callee pairs, and 20 of 20 sampled new edges right after the guards (17 of 20 before the flowed-value guard). On three held-out projects, graded blind by a reviewer who did not tune it: 39 of 40 sampled new edges right (Wilson 95% interval 0.87-1.00). The one miss is a function handed to an unregistration call; the only repeated wrong shape left is a function passed to inspect.signature, about 1% of the new edges. The engine goldens gain only reference rows; the torture oracle scorecard is unchanged. Refs #1832
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1978
Part of #1832.
A bound or unbound method or a function named as a VALUE and not called
(executor.submit(self._work, x), Thread(target=svc.run), sorted(xs,
key=self.rank), [h.on_event], partial(svc.cancel, oid), view_func=
views.index, return self._handle) had no caller in the Python graph, so
impact OrderService.cancel did not name the function that queued it and
path said the two were independent. The engine already resolved what each
of these expressions denotes; it dropped the answer because no call
wrapped it.
call-edge-generation/method-reference.dl emits it as a call_chain_edge
with kind METHOD_REFERENCE and tier callback_registered, the tier the
other front ends use for a function handed over, so answers say "handed
over as a value" and never "calls it". Only what is resolved: a typed
receiver through the MRO, a class's unbound method, a scoped name, a
module member. Refused: an untyped receiver (stays as unresolved as
thing.cancel() is), a flowed value (a parameter, a name or attribute
assigned from an expression), a property read, a decorator application,
the argument of a one-dunder builtin (str(f)), and a comparison operand.
Measured on three open-source Python projects used for tuning: 3-4% more
resolved caller->callee pairs, and 20 of 20 sampled new edges right after the
guards (17 of 20 before the flowed-value guard). On three held-out projects,
graded blind by a reviewer who did not tune it: 39 of 40 sampled new edges
right (Wilson 95% interval 0.87-1.00). The one miss is a function handed to an
unregistration call; the only repeated wrong shape left is a function passed
to inspect.signature, about 1% of the new edges. The engine goldens gain only reference rows; the
torture oracle scorecard is unchanged.
Tests:
tests/cases/python/method-reference-reaches-its-target, 17 checks: every shape above aspath/impact, and--testsreaching the target through a test that drives the executor. Controls: an untyped receiver, a same-named method on an unrelated class, the method's name in a string,__name__,str(f), andf is gdo not link. On the base 3 of 17 pass (the controls), now 17 of 17.graph/test/python/run-tests.sh): 43/43. The goldens gain only METHOD_REFERENCE rows, all reviewed.tests/fastpath.py --lang python8/8.tests/run.py --lang python462/462.Follow-up, not in this change: treat
inspect.signature/getfullargspecarguments anddisconnect(...)arguments as reads, not handovers.