Repository navigation
Conversation
…d-referenced (Graphify-Labs#4334) A type hint like `w: Widget` before `class Widget` in widget.py minted a bare 'widget' stub, which collides with the file node id once paths are made relative, so the file node vanished and Widget ended up containing itself. Point that reference at the local class id instead. Co-Authored-By: Grok Bot
|
Thanks for the pull request, @Mpasha17. 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. |
There was a problem hiding this comment.
Graphify reviewed this change.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 2 advisory finding(s) below merit a look before merge.
Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 not verified).
Formal verification. PR-changed functions: 0/1 verified (0 proven, 0 may-equivalent, 0 distinguished) · 1 not verified (1 unsupported).
Not verified on this run: \_extract\_generic (unsupported).
Graphify review — findings
Fixes forward references to a class named after its own file (e.g. Widget in widget.py). These used to emit a cross-file stub whose id collided with the file node and swallowed it. _extract_generic now resolves such a name to the namespaced local id of the class defined later in the same file, so the file node keeps its contains edges and importers still resolve imports_from to the file.
Worth a look
- File-stem collision always rewrites the reference to a local id, even when the name is imported from another module —
graphify/extractors/engine.py:4847· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
- Forward-ref id built from current namespace_stack instead of the class's actual scope —
graphify/extractors/engine.py:4852· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 845 functions depend on the 292 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, 35 callees (high)extract_js()— 90 callers, 6 callees (high)extract_xaml()— 19 callers, 17 callees (high)extract_objc()— 25 callers, 10 callees (high)extract_php()— 37 callers, 5 callees (high)extract_cpp()— 36 callers, 5 callees (high)extract_julia()— 19 callers, 8 callees (high)extract_svelte()— 14 callers, 8 callees (high)- …and 2 more
Verification — 845 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: 741 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
33 of 368 test file(s) selected (9%) via static blast radius.
tests/test_astro_extraction.py— impacttests/test_build.py— impacttests/test_cjs_module_extension.py— impacttests/test_cpp_nested_and_cli.py— impacttests/test_dotnet.py— impacttests/test_extract.py— impacttests/test_extract_php_closures.py— impacttests/test_import_extension_resolution.py— impacttests/test_indirect_call_block_scoped_shadow.py— impacttests/test_indirect_dispatch.py— impacttests/test_indirect_dispatch_assign_return.py— impacttests/test_indirect_dispatch_getattr.py— impacttests/test_js_exported_scalar_bindings.py— impacttests/test_languages.py— impacttests/test_multilang.py— impacttests/test_php_unparsed_casts.py— impacttests/test_python_forward_ref_file_id.py— impact, changed-testtests/test_python_inherited_method_calls.py— impacttests/test_python_underscore_resolution.py— impacttests/test_rationale.py— impacttests/test_ruby_resolution.py— impacttests/test_scala_context_bounds.py— impacttests/test_scala_given_instances.py— impacttests/test_scala_self_type.py— impacttests/test_scala_top_level_binding.py— impacttests/test_scala_type_definition.py— impacttests/test_svelte_extraction.py— impacttests/test_swift_computed_properties.py— impacttests/test_swift_protocol_requirements.py— impacttests/test_trailing_newline_not_a_syntax_error.py— impacttests/test_ts_new_expression_calls.py— impacttests/test_typescript_module_extensions.py— impacttests/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.
Docs that may be stale (advisory)
CHANGELOG.md§ 0.9.76 (2026-10-04) (lines 142-160): references changed symbolsuseCHANGELOG.md§ 0.9.75 (2026-10-04) (lines 161-181): references changed symbolsuseCHANGELOG.md§ 0.9.63 (2026-09-16) (lines 324-331): references changed symbolsuseCHANGELOG.md§ 0.9.62 (2026-09-15) (lines 332-350): references changed symbolsWidgetCHANGELOG.md§ 0.9.58 (2026-09-10) (lines 374-391): references changed symbolsuseCHANGELOG.md§ 0.9.46 (2026-08-17) (lines 547-563): references changed symbolsuseCHANGELOG.md§ 0.9.41 (2026-08-12) (lines 612-627): references changed symbolsuseCHANGELOG.md§ 0.9.38 (2026-08-09) (lines 651-659): references changed symbolsmakeCHANGELOG.md§ 0.9.31 (2026-07-30) (lines 714-724): references changed symbolsmakeCHANGELOG.md§ 0.9.17 (2026-07-16) (lines 871-900): references changed symbolsuse
…and 10 more.
Formal verification
Could not verify: Could not verify \_extract\_generic.
The verifier did not have enough to check \_extract\_generic, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: parameter `config` is annotated `LanguageConfig` — outside the synthesizable primitive/collection set
|
Checked both live with
So neither is a regression compared to v8. Happy to tighten it if you've got a case that comes out worse. |
|
Thanks @Mpasha17! The single-file case (#4334) is fixed correctly. One thing before this can land: the guard fires on any referenced name whose bare slug equals the file stem — including a same-named class that's imported into the file rather than defined in it. For a file in a subdirectory that does Could you gate the redirect on the name actually being a local definition (e.g. only redirect when the qualified id ends up in |
|
I tested this too and hit the same imported-class case. One more for the new check: if there's no |
…raphify-Labs#4334) Keep v8's sourceless stub and resolve after the walk: rewrite to the local id only when that id is a class defined in this file. An imported name (e.g. pkg/widget.py doing `from .base import Widget`) or a same-id function like `def widget()` now falls through to the cross-file rewire exactly as on v8. Co-Authored-By: Grok Bot
|
Thanks for catching this! Changed it the way you suggested: Thanks @smngvlkz for the |
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]>
|
Shipped in v0.9.88, just released to PyPI as |
Fixes #4334
What changed
In
_extract_generic(graphify/extractors/engine.py), a forward reference likew: Widgetbeforeclass Widgetinwidget.pyminted a barewidgetstub, which is the same id the file node gets once paths are made relative, so the file node got swallowed andWidgetended up "containing" itself andHelper. Now the stub is still emitted exactly as before, but after the walk, if the name turns out to be a class defined in this file, references get rewired to that class and the stub is dropped. Anything else (an importedWidget, or adef widget()with the same id) is left on v8's sourceless-stub path for the cross-file rewire.How I tested it
tests/test_python_forward_ref_file_id.py: the issue repro (single file + with an importer),pkg/widget.pyimportingWidgetfrom.base(no dangling edges,use()links tobase.Widget), and adef widget()with no class (no reference to the function).graphify update .(freshgraphify-out) before and after:widget.pynode,Widget contains Widget/Helper,app imports_from Widget, noHelper.make -> drawcallwidget.pynode is back and contains both classes,app.pyimports_from the file,.make() calls .draw()shows uppkg/widget.py+from .base import Widgetand thedef widget()case both give the same graph as v8.ruff checkclean. Full suite on py3.10/3.12/3.13/3.14: the only failures (test_dm_*and 7test_securitysafe_fetch/validate_url tests) fail the same way on v8 too.One note: in the 2-file repro the file node's id comes out as
widget_py_widgetrather thanwidget. That's becauseapp.py's ownWidgetstub still collides, and v8 already does exactly the same thing even without the forward ref, so I left it alone here.I used an AI assistant (Grok Bot) to help write this; I reviewed and tested the change myself.