Skip to content

fix(extract): stop Python property-accessor decorators minting stub nodes - #4385

Closed
rajatnagda45 wants to merge 1 commit into
Graphify-Labs:v8from
rajatnagda45:fix/python-property-accessor-decorators
Closed

rajatnagda45 wants to merge 1 commit into
Graphify-Labs:v8from
rajatnagda45:fix/python-property-accessor-decorators

Conversation

@rajatnagda45

Copy link
Copy Markdown
Contributor

Fixes #4380.

Problem

The Python decorator-reference pass (#2154) runs ensure_named_node on a decorator's head symbol. For the property-descriptor protocol @x.setter / @x.getter / @x.deleter, the head symbol is setter/getter/deleter — not a corpus symbol — so every property with a setter/deleter (or a @x.getter redefinition) fabricates a sourceless stub node and a false references (context=decorator) edge onto it. Same provenance pollution the builtin-decorator noise list already guards against for @property.

Implementation

_python_is_property already recognizes the .getter form for read-semantics. The decorator-edge loop now mirrors it: before resolving a decorator's head symbol it checks the decorator expression text and skips any .setter/.getter/.deleter accessor. Imported decorators reached through an attribute (@app.route) are unaffected.

Verification

New regression test (tests/test_python_decorators.py::test_property_accessor_decorators_emit_no_edge_or_stub) asserts no decorator edge and no sourceless stub for a property with setter and deleter accessors; it fails on pre-fix v8 and passes with the fix.

Commands run:

  • uv run pytest tests/ (7516 passed, 15 skipped; test_security.py needs live DNS and the built-wheel test needs a wheel, both excluded locally)
  • uv run ruff check . (clean)
  • uv run pyright graphify/extractors/engine.py (34 errors, unchanged from v8 baseline — 0 added)

Limitations

Only the attribute-form accessor protocol (@<name>.setter etc.) is skipped; a decorator imported under the bare names is not affected.

…odes

`@x.setter` / `@x.getter` / `@x.deleter` are the property-descriptor
protocol, not references to corpus symbols named setter/getter/deleter.
The Python decorator-edge pass (Graphify-Labs#2154) ran `ensure_named_node` on the
decorator's head symbol, so every property with a setter/deleter/getter
redefinition fabricated a sourceless stub node and a false `references`
(context=decorator) edge onto it — the same provenance pollution the
builtin-decorator noise list already guards against for `@property`.

`_python_is_property` already recognizes the `.getter` form for the
read-semantics; the decorator-edge path now mirrors it and skips any
`.setter`/`.getter`/`.deleter` decorator. Imported decorators reached
through an attribute (`@app.route`) are unaffected.

Regression test asserts no decorator edge and no sourceless stub for a
property with setter and deleter accessors.
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @rajatnagda45. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic.

@github-actions github-actions Bot added the contributor Pull request from a returning community contributor label Oct 12, 2026

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify reviewed this change.

No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.

Not checked: tests were not run; no formal proof of the changed code.


Graphify review — findings

Skips Python @x.setter, @x.getter and @x.deleter decorators in _extract_generic, matching _python_is_property. They no longer emit decorator edges or mint sourceless setter/getter/deleter stubs, which collapsed into a cross-file god node. A new test checks that a property with setter and deleter produces no decorator edges and no stubs without a source file.

No blocking issues surfaced. 2 lower-confidence candidates did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 887 functions depend on the 321 functions this change touches.

Health — grade A; 10 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):

  • _extract_generic() — 19 callers, 38 callees (high)
  • extract_js() — 90 callers, 7 callees (high)
  • extract_xaml() — 19 callers, 17 callees (high)
  • extract_objc() — 25 callers, 10 callees (high)
  • extract_php() — 38 callers, 5 callees (high)
  • extract_cpp() — 37 callers, 5 callees (high)
  • extract_julia() — 22 callers, 8 callees (high)
  • extract_svelte() — 14 callers, 8 callees (high)
  • …and 2 more

Verification — 887 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 776 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

35 of 390 test file(s) selected (9%) via static blast radius.

  • tests/test_astro_extraction.py — impact
  • tests/test_build.py — impact
  • tests/test_cjs_module_extension.py — impact
  • tests/test_cpp_nested_and_cli.py — impact
  • tests/test_csharp_partial_classes.py — impact
  • tests/test_dotnet.py — impact
  • tests/test_extract.py — impact
  • tests/test_extract_php_closures.py — impact
  • tests/test_import_extension_resolution.py — impact
  • tests/test_indirect_call_block_scoped_shadow.py — impact
  • tests/test_indirect_dispatch.py — impact
  • tests/test_indirect_dispatch_assign_return.py — impact
  • tests/test_indirect_dispatch_getattr.py — impact
  • tests/test_js_exported_scalar_bindings.py — impact
  • tests/test_languages.py — impact
  • tests/test_multilang.py — impact
  • tests/test_php_unparsed_casts.py — impact
  • tests/test_python_decorators.py — impact, changed-test
  • tests/test_python_inherited_method_calls.py — impact
  • tests/test_python_property_reads.py — impact
  • tests/test_python_underscore_resolution.py — impact
  • tests/test_rationale.py — impact
  • tests/test_ruby_resolution.py — impact
  • tests/test_scala_context_bounds.py — impact
  • tests/test_scala_given_instances.py — impact
  • tests/test_scala_self_type.py — impact
  • tests/test_scala_top_level_binding.py — impact
  • tests/test_scala_type_definition.py — impact
  • tests/test_svelte_extraction.py — impact
  • tests/test_swift_computed_properties.py — impact
  • tests/test_swift_protocol_requirements.py — impact
  • tests/test_trailing_newline_not_a_syntax_error.py — impact
  • tests/test_ts_new_expression_calls.py — impact
  • tests/test_typescript_module_extensions.py — impact
  • tests/test_vue_extraction.py — impact

Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.

safishamsi added a commit that referenced this pull request Oct 12, 2026
Python property-accessor decorators and `Self` (#4385, #4386), Swift
`Self` (#4387), Go generic type params (#4388), the Python forward
type-hint file-node fix (#4343), PowerShell dot-source paths (#4369),
and the C# verbatim-interpolated-string recovery (#3612) all change AST
extraction output, so warm caches must re-extract.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.88, just released to PyPI as graphifyy 0.9.88. Landed via an authorship-preserving cherry-pick (your commit keeps your name and counts on your contributor graph), which is why GitHub marks this closed rather than merged. Thanks @rajatnagda45!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor Pull request from a returning community contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: @x.setter/@x.getter/@x.deleter mint a sourceless stub node and a false decorator edge

2 participants