Skip to content

Omit None-code callables from Python get_method_bodies - #305

Merged
rahlk merged 1 commit into
release/2.0from
fix/issue-301-python-none-code-filter
Aug 3, 2026
Merged

Omit None-code callables from Python get_method_bodies#305
rahlk merged 1 commit into
release/2.0from
fix/issue-301-python-none-code-filter

Conversation

@rahlk

@rahlkrahlk commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Fixes the Python half of the bulk-accessor parity gap found during #298's review.

Problem

The TypeScript bulk accessors ship get_method_bodies with a mechanical omission rule: a callable whose code is None is left out, so every value in the returned Dict[str, str] is a real str. Python passed code straight through, so a PyCallable with no source text yielded a None value — a violation of the declared Dict[str, str] contract.

Change

Aligns Python upward to the TS rule, in both backends:

  • in-memory (codeanalyzer.py) — filter on c.code is not None, matching the TS loop.
  • Neo4j (neo4j_backend.py) — add AND c.code IS NOT NULL to the MATCH and index the row directly instead of r.get("code"), mirroring the TS Cypher exactly.

Both docstring layers (the ABC and the facade) now document the rule, as the TS side already does — the promise that every returned value is a real str is part of the contract, not an implementation detail.

Verification

tests/analysis/python/test_python_bulk_accessors.py — 5 passed. (Running a single file trips the 50% global coverage gate at 40%; that's an artifact of the partial run, not a failure.)

Closes#301

The TypeScript bulk accessors (#298) ship get_method_bodies with a
mechanical omission rule: a callable whose `code` is None is left out, so
every value in the returned Dict[str, str] is a real str. The Python
implementations passed `code` straight through, so a PyCallable with no
source text yielded a None value -- a violation of the declared
Dict[str, str] contract.
Align Python upward to the TS rule in both backends:
- in-memory (codeanalyzer.py): filter on `c.code is not None`
- Neo4j (neo4j_backend.py): add `AND c.code IS NOT NULL` to the MATCH and
index the row directly instead of `r.get("code")`, mirroring the TS
Cypher exactly
Document the rule on the Python ABC and the facade docstring, as the TS
side already does -- the promise that every value is a real str is part of
the contract, not an implementation detail.
Refs #301
@rahlk
rahlk merged commit f6a6d59 into release/2.0Aug 3, 2026
@rahlk
rahlk deleted the fix/issue-301-python-none-code-filter branch August 3, 2026 17:03
Sign up for freeto 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.

1 participant

@rahlk