Skip to content

fix(extract): resolve Python module instance method calls - #4972

Closed
Shubham-Padkonde wants to merge 1 commit into
Graphify-Labs:v8from
Shubham-Padkonde:fix/python-module-instance-calls
Closed

Shubham-Padkonde wants to merge 1 commit into
Graphify-Labs:v8from
Shubham-Padkonde:fix/python-module-instance-calls

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor

What does this PR do?

Graphify was missing method calls on instances created at module level. I fixed it while avoiding wrong matches for reassigned or shadowed names and ran the tests, lint and type checks.

Fixes #4970

Type of change

  • Bug fix

Verification & Invariants

The following implementation and validation notes were recorded with OpenAI Codex; the description above is my own wording.

Direct module-level constructor bindings retain their receiver class for calls inside functions. Inferred edges stay INFERRED. Shadowed, rebound, conditional or dynamically mutated bindings remain unresolved. Qualified constructors and decorated classes are outside this pass. AST cache schema 37 invalidates entries without the new instance marker. Cold/warm extraction is covered by regression tests.

How was this tested?

Commands run:

uv run pytest tests
uv run ruff check .
uv run pyright --pythonpath .venv/Scripts/python.exe

Recorded Windows validation:

  • 250 focused Python extraction tests pass.
  • Three new positive regressions fail on the original code.
  • Full suite: 9,414 passed, 24 failed, 165 skipped, one expected failure. All 24 failures also reproduce on unchanged upstream.
  • Ruff passes.
  • Pyright reports 694 diagnostics, matching unchanged upstream; this is not a clean type-check run.
  • Graph update and diff checks pass.

No generated skill sources were changed. No API keys or local graph data are included. Material AI implementation assistance is disclosed in the commit's Co-Authored-By trailer.

Recognize direct constructor bindings at module scope while rejecting shadowed, rebound and uncertain receivers. Preserve inferred provenance and invalidate old AST cache entries.

Fixes Graphify-Labs#4970

Co-Authored-By: OpenAI Codex <[email protected]>
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Thanks for the pull request, @Shubham-Padkonde. 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.

@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; formal verification proved 0 of 3 changed function(s) (3 not verified).

Formal verification. PR-changed functions: 0/3 verified (0 proven, 0 may-equivalent, 0 distinguished) · 3 not verified (2 vacuous, 1 unsupported).

Not verified on this run: \_resolve\_python\_member\_calls (vacuous: never exercised), \_extract\_generic (unsupported), \_python\_receiver\_shadow\_checker (vacuous: never exercised).


Graphify review — findings

Adds Python resolution of member calls through direct module-level constructor assignments (g = Service()), so g.method() inside a function links to the class's method. It covers imported aliases and lowercase classes rebound to their instance, but only when the constructor is declared or imported before the assignment and resolves by exact spelling to one visible class. Local shadowing, other module bindings, conditional assignments, dynamic namespace mutation, qualified constructors and decorated classes leave the call unresolved. Resolved edges stay INFERRED. Bumps the AST cache schema to 37, so cached Python extractions without the instance marker re-run.

No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 4974 functions depend on the 859 functions this change touches.

Health — this change adds coupling hotspots:

  • worse: extract() — 1117 callers, 66 callees
  • worse: _extract_generic() — 20 callers, 54 callees

Verification — 4974 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: 4310 function(s) in the blast radius were not formally verified this run

Test selection

Test selection

502 of 502 test file(s) selected (100%) via static blast radius.

Escalated to a full run for safety — the selection is not trustworthy on its own (see below). CI should run the whole suite.

  • tests/pi.test.ts — full-run-safety
  • tests/test_4874_jvm_resolution.py — impact, full-run-safety
  • tests/test_4909_reference_binding_scale.py — full-run-safety
  • tests/test_affected_cli.py — full-run-safety
  • tests/test_affected_defines.py — full-run-safety
  • tests/test_affected_member_seed.py — full-run-safety
  • tests/test_affected_overrides.py — impact, full-run-safety
  • tests/test_affected_path_file_node.py — full-run-safety
  • tests/test_affected_seed_reference_forms.py — full-run-safety
  • tests/test_agents_platform.py — full-run-safety
  • tests/test_alias_folding.py — impact, full-run-safety
  • tests/test_analyze.py — impact, full-run-safety
  • tests/test_anthropic_custom_endpoint.py — full-run-safety
  • tests/test_antigravity_install.py — full-run-safety
  • tests/test_apm_fallback_version.py — full-run-safety
  • tests/test_architecture_doc.py — full-run-safety
  • tests/test_astro_extraction.py — impact, full-run-safety
  • tests/test_astro_import_ids.py — impact, full-run-safety
  • tests/test_atomic_canvas_export.py — full-run-safety
  • tests/test_atomic_version_stamp.py — full-run-safety
  • tests/test_atomic_writes.py — full-run-safety
  • tests/test_backend_env_isolation.py — full-run-safety
  • tests/test_backend_extras.py — full-run-safety
  • tests/test_backend_opt_in.py — full-run-safety
  • tests/test_benchmark.py — full-run-safety
  • tests/test_benchmark_raw_graph.py — full-run-safety
  • tests/test_benchmark_real_query.py — full-run-safety
  • tests/test_binary_media_words.py — impact, full-run-safety
  • tests/test_blade_extractor.py — impact, full-run-safety
  • tests/test_build.py — impact, full-run-safety
  • tests/test_build_located_semantic_identity.py — impact, full-run-safety
  • tests/test_build_merge_dedup_scope.py — impact, full-run-safety
  • tests/test_build_merge_hyperedges_and_prune.py — impact, full-run-safety
  • tests/test_build_merge_shrink_guard.py — impact, full-run-safety
  • tests/test_builtin_global_type_refs.py — impact, full-run-safety
  • tests/test_c_include_resolution.py — impact, full-run-safety
  • tests/test_cache.py — impact, full-run-safety
  • tests/test_cache_long_paths.py — impact, full-run-safety
  • tests/test_cache_stale_import_target.py — impact, full-run-safety
  • tests/test_cache_windows_case_4925.py — impact, full-run-safety
  • tests/test_callflow_html.py — full-run-safety
  • tests/test_cargo_introspect.py — full-run-safety
  • tests/test_cargo_missing_manifest.py — full-run-safety
  • tests/test_carried_hyperedge_remap.py — impact, full-run-safety
  • tests/test_case_only_decl_ids_4904.py — impact, full-run-safety
  • tests/test_case_sensitive_resolution.py — impact, full-run-safety
  • tests/test_charmap_encoding.py — impact, full-run-safety
  • tests/test_chunking.py — impact, full-run-safety
  • tests/test_cjs_module_extension.py — impact, full-run-safety
  • tests/test_claude_cli_backend.py — full-run-safety
  • … and 452 more

non-code file(s) changed (ARCHITECTURE.md) → running the full suite for safety (a code graph can't see config/fixture/data deps)

changed code file(s) with no mapped test (ARCHITECTURE.md) — a coverage gap or a missing link — running the full suite rather than only the selected tests

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.

Formal verification

Could not verify: Could not verify \_resolve\_python\_member\_calls.

The verifier did not have enough to check \_resolve\_python\_member\_calls, 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: non-vacuity: domain too small (only 1 distinct inputs exercised, need 3) — 'no divergence' would be near-vacuous

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

Could not verify: Could not verify \_python\_receiver\_shadow\_checker.

The verifier did not have enough to check \_python\_receiver\_shadow\_checker, 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: not verifiable: all 228 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly AttributeError — names the real obstacle, not a sampling gap)

· 2 more finding(s) on lines outside this diff (see the check run).

safishamsi added a commit that referenced this pull request Nov 3, 2026
… extractor fixes

#4985, #4972, #4956 (#4935) and the Go cluster #4966/#4853/#4934 each change
per-file extractor output; fold them into one schema-37 entry (#4956 shipped
without its own bump) so warm caches re-run the affected extractions.

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

Copy link
Copy Markdown
Member

Landed in 0.9.102 (published to PyPI), cherry-picked with your authorship preserved. Fixes #4970. Thanks @Shubham-Padkonde.

@safishamsi safishamsi closed this Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: calls on module-level class instances get no calls edge (g = Svc(); def f(): g.m()), incl. lowercase class rebound to instance

2 participants