Repository navigation
Conversation
…inherited calls `class Repo(Base[int])` emitted no `inherits` edge: the Python heritage handler only accepted `identifier` bases, and a parameterized base parses as a `subscript` whose `value` field is the base. The same class was also marked `python_opaque_bases`, so a `self.m()` in `Repo` never reached `Base.m` in another file, although `Base` is in its MRO exactly as for `class Repo(Base)`. `_python_base_name_node()` now decides both: it unwraps a subscript to its value and accepts an identifier. A subscript of a dotted name, a call or any other expression stays opaque and gets no edge. Generic arguments never become parents. Tests: parameterized, nested and mixed bases plus a dynamic base factory in test_languages.py, and a cross-file `self.m()` through `Base[int]` in test_python_inherited_method_calls.py; both fail without the change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the pull request, @Synvoya. 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.11 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify code review 
Review completed · 11561d4bb6f3
Tip
Merge confidence: 5/5 · Looks safe to merge · 🟠 High impact
No issues reported
Parameterized Python bases now produce inherits edges to the named base, and are no longer marked opaque for inherited-method traversal.
Full summary
Parameterized Python bases now produce inherits edges to the named base, and are no longer marked opaque for inherited-method traversal. The added tests cover inheritance extraction and calls through an imported parameterized base.
Code graph and static checks · 4799 functions depend on this change
Impact & health
Impact — 4799 functions depend on the 1213 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
walk()— 1 callers, 100 callees
Formal checks — 4799 functions this change can affect weren't formally checked in this review. Formal checks are informational only.
Gate & verification
✅ PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 3176 function(s) in the blast radius were not formally verified this run
Test selection
52 of 593 test file(s) selected (9%) via static blast radius.
tests/test_4992_ts_import_types.py— impacttests/test_astro_extraction.py— impacttests/test_build.py— impacttests/test_cjs_module_extension.py— impacttests/test_cpp_alias_member_resolution.py— impacttests/test_cpp_conditional_initializers.py— impacttests/test_cpp_inherited_member_resolution.py— impacttests/test_cpp_nested_and_cli.py— impacttests/test_csharp_extension_calls.py— impacttests/test_csharp_extension_metadata.py— impacttests/test_csharp_extension_resolution.py— impacttests/test_csharp_partial_classes.py— impacttests/test_dart.py— impacttests/test_dart_typedef.py— impacttests/test_dotnet.py— impacttests/test_ejs_extractor.py— impacttests/test_ext_tagged_id_clash.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_java_member_calls.py— impacttests/test_java_nested_type_identity.py— impacttests/test_js_exported_scalar_bindings.py— impacttests/test_js_member_collisions.py— impacttests/test_languages.py— impact, changed-testtests/test_multilang.py— impacttests/test_php_unparsed_casts.py— impacttests/test_python_inherited_method_calls.py— impact, changed-testtests/test_python_injected_factory_calls.py— impacttests/test_python_property_reads.py— impacttests/test_python_pytest_fixture_receivers.py— impacttests/test_python_subscript_type_refs.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_extension_methods.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— impact- … and 2 more
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.
Every flagged function
walk()ingraphify/extractors/engine.py:7916· 1 callers, 100 callees: fans out to 100 callees (efferent coupling)
What does this PR do?
Re-submission of #1815, rebased onto current v8 (340268a), which supersedes it. It is extended for the cross-file inherited-method walk and its
python_opaque_basesmarker (86e3c1d), which landed on v8 after the original PR.class Repo(Base[int])emitted noinheritsedge: the Python heritage handler only acceptedidentifierbases, and a parameterized base parses as asubscriptwhosevaluefield is the base. On current v8 the same class is also markedpython_opaque_bases, soself.m()inReponever reachesBase.min another file, althoughBaseis in its MRO exactly as forclass Repo(Base).A new helper,
_python_base_name_node(), now decides both: it unwraps a subscript to its value and accepts an identifier. A subscript of a dotted name, a call, or any other expression stays opaque and gets no edge. Generic arguments never become parents.Type of change
Verification & Invariants
Invariant: the
inheritsedges and the opaque-bases marker agree. A base gets an edge exactly when the walk may trust it, so the walk neither stops at a base it can see nor follows one it cannot.test_python_parameterized_base_inherits_edge:Base[int],Mixin, Base[list[str]]and a dynamic base factory; no edges tolist,stror the factory.test_a_parameterized_base_is_walked_like_a_bare_one: cross-fileself.m()throughBase[int]. It fails with the edge fix alone (the class was still opaque).test_chains_the_walk_cannot_order_emit_no_edgestill passes:class Generic_(Base, Generic[T])now has two bases, and the walk stops at two or more as before.Limitations:
Generic[T]andProtocol[T]bases now emitinheritsedges toGeneric/Protocolname nodes, the same as a bareProtocolbase already does.mod.Base[T]is still opaque, likemod.Base.Cached Python extractions need a schema bump to pick this up. I left
_AST_CACHE_SCHEMAalone, since recent fixes have it folded into your combined bump; happy to add it here instead.Read the CONTRIBUTING.md guide.
Reproduced the issue and identified the invariant.
Made the smallest fix necessary.
Added a regression test (if bug fix) or isolated boundary test.
Kept the PR description synchronized with the final implementation.
Documented any limitations / unsupported cases explicitly.
How was this tested?
Python 3.11.16 on macOS, environment from
uv sync --all-extras, branch based on v8 340268a.Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (No skill sources touched.)AI disclosure: drafted with help from Claude Code and reviewed before posting; the commit carries a
Co-Authored-Bytrailer.