mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-11 03:38:07 +00:00
* fix(python): resolve decorator identity like CPython Decorator identity was decided by two different predicates. One read the raw decorator text, so a trailing comment such as `@staticmethod # type: ignore` hid the builtin and turned an explicit first parameter into a fabricated receiver. The other trusted any `staticmethod` spelling, including a module-level rebinding and a `staticmethod(classmethod(f))` stack, which CPython cannot call. Read the decorator expression node only, and recognize a bare builtin descriptor only when the file does not rebind that name. Publish subtype capacity only for a plain function or a single builtin staticmethod or classmethod wrapper. Drop a no-op coverage guard, move the implicit classmethod comment next to the code it describes, and bump the parse cache to v121. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(python): shadow builtin descriptors only by visible bindings The whole-file identifier scan counted plain reads (`staticmethod(f)`), `from builtins import staticmethod`, and bindings that run after the decorator as rebindings. CPython evaluates a class-body decorator with LOAD_NAME when the `def` runs, so none of those change which object the decorator names. Methods decorated with the real builtin lost their subtype call shape, and static methods lost their first parameter in arity metadata. Move decorator identity into builtin-descriptors.ts and count only binding occurrences (assignment and loop targets, walrus, def/class, parameters, import aliases, except/with/match captures, del, type parameters, and wildcard imports) that are visible where the decorator runs: the class body or module before the definition, a repeating enclosing loop, any binding in an enclosing function, and any global/nonlocal rebind. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(python): model global and del like CPython's symbol table `global x` and `nonlocal x` bind nothing; they redirect the declaring function's own bindings of `x` to an outer scope. A bare declaration was treated as an unconditional rebinding, so `@staticmethod` anywhere in the file lost builtin recognition. A module- or class-level `del` restores the outer lookup rather than binding the name. Treat an unconditional `del` that runs after a binding and before the decorator as undoing that binding. A `del` inside control flow may not run, and a `del` inside a function still makes the name local there. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(python): order global rebinds and honor builtins re-exports A function that declares `global staticmethod` and assigns it rebinds the module name only when called, and it cannot be called before the top-level statement that defines it runs. Treat such a rebind as visible only when that statement precedes the decorator, or when the decorator sits in a deferred class body. `nonlocal` rebinds stay visible anywhere in the enclosing function. `from builtins import staticmethod as staticmethod` binds the builtin to its own name, so it no longer counts as shadowing. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * test(python): scope the descriptor-identity CPython claim The wildcard-import case expects the fail-closed resolver verdict, not a CPython outcome, because the imported module's exports are unknown. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(python): resolve descriptor names as LOAD_NAME does Model each binding by its effect on the namespace (Language Reference 4.2.1): an import that binds the `builtins` object itself (plain, aliased to the same name, or `from builtins import *`) restores the builtin, a module- or class-level `del` unbinds so lookup falls through, and any other binding shadows. Resolve the decorator like LOAD_NAME (4.2.2): the class namespace, then module globals, then builtins, each as it stands when the `def` runs. A restoring effect counts only as an unconditional simple statement that runs before the decorator, so an import or `del` under `if`/`try` or a loop stays fail-closed. A helper's `global` delete depends on whether the helper is called, which the resolver does not model, so it keeps the override. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(python): simplify decorator descriptor lookup Derive the descriptor type and name set from one `as const` list, replace indexed non-null assertions with destructuring, build the scope chain without an assertion, and skip the enclosing-function owner lookup when the decorator has no enclosing function. Key the stacked-decorator verdicts by case name so a failure names its case. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(python): resolve enclosing-function and deferred descriptor lookups A class body reads a free name from the innermost enclosing function that binds it (Language Reference 4.2.2). Evaluate that function's namespace the same way as the class and module ones, so an unconditional `from builtins import staticmethod` there resolves to the builtin. Any other binding still shadows, including a local assigned only after the class, which raises NameError rather than falling back to the builtin. A class body inside a function runs whenever that function is called, which can be any time after its top-level statement starts. Read module state at that statement instead of after the whole module, so an earlier `del` restores the builtin, and treat any later module override as possibly visible. 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> |
||
|---|---|---|
| .. | ||
| cli | ||
| config | ||
| core | ||
| lib | ||
| mcp | ||
| server | ||
| storage | ||
| types | ||
| utils | ||