GitNexus/gitnexus/test/unit/scope-resolution/python
Gergő Magyar aa0f41e853
fix(python): model restoring helper calls in decorator identity (#3415)
* fix(python): model restoring helper calls in decorator identity (#3414)

A bare module-level call to a same-file helper whose every global
binding of a descriptor name is an unconditional del or builtins import
now restores the builtin at the call site, matching CPython. A nonlocal
rebind nested in the enclosing function now shadows an owned builtins
import, closing a false builtin. Unprovable call orders stay fail-closed
and are pinned against CPython 3.11.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(review): apply review findings

Close three false-builtin paths the review found: a match-pattern
capture now counts as a binding (at any scope, including inside a
restoring helper), a call before the helper's def no longer counts as a
restore, and the helper-name uniqueness check sees match captures.
Pin the helper rejections (conditional restore, async, early and nested
return, wildcard import) against CPython 3.11.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(cache): bump parse-cache schema to v122 for #3414

Python decorator identity verdicts changed, so warm v121 ParsedFiles
would replay stale receiver bindings.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(python): require an argument-free call to a helper with no required parameters

A call that fails to bind the helper's parameters raises TypeError
before the body runs, so it proves no restore. Keep such calls
fail-closed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(python): count only real captures and module bindings for decorator identity

Match value patterns, class names and keyword keys read a name rather
than capture it, so they no longer shadow a builtin descriptor. A local
of the same name as a restoring helper no longer disqualifies the
module-level helper; only a module binding or a global rebind does.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(python): state the fail-closed contract of the descriptor identity table

`false` means the resolver does not prove the builtin, not that CPython
shadows it. Cases where CPython keeps the builtin but the resolver fails
closed carry a comment saying so.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-29 12:37:27 +01:00
..
cached-tree-parity.test.ts feat(python): scope-based call resolution + registry-primary flip + perf + generalization (RFC #909 Ring 3) (#980) 2026-04-21 15:50:00 +01:00
python-builtin-descriptors.test.ts fix(python): model restoring helper calls in decorator identity (#3415) 2026-09-29 12:37:27 +01:00
python-captures-golden.test.ts fix(python): resolve mixin self calls to subtype implementations (#3390) 2026-09-28 09:42:56 +05:30
python-constructor-field-bindings.test.ts fix(python): resolve calls through constructor-injected fields (#2628) 2026-07-22 16:32:53 +01:00
python-fixtures.test.ts fix(resolution): label fallback guesses and preserve export visibility (#3190) 2026-09-10 11:38:19 +01:00
python-generic-annotation-reduction.test.ts fix(resolution): resolve calls through a generic-typed field receiver in every language (#2833) (#2855) 2026-08-07 17:14:13 +01:00
python-hooks.test.ts fix(python): resolve mixin self calls to subtype implementations (#3390) 2026-09-28 09:42:56 +05:30
python-import-probe-count.test.ts perf(import-resolvers): index every scanning resolver, consolidate the memo, gate every registered language (#2911) 2026-08-10 17:22:51 +01:00
python-import-target-parity.test.ts fix(python): resolve classes through module imports (#2770) 2026-08-01 06:02:47 +01:00
python-importer-ancestors.test.ts perf(import-resolvers): index every scanning resolver, consolidate the memo, gate every registered language (#2911) 2026-08-10 17:22:51 +01:00
python-module-namespace-construction.test.ts fix(python): resolve calls through an unaliased dotted namespace import (#2826) (#2828) 2026-08-05 11:35:27 +01:00
python-subtype-dispatch.test.ts fix(python): resolve decorator identity like CPython (#3411) 2026-09-29 08:12:52 +00:00