Skip to content

Python get_method_bodies lacks the None-code omission filter (twin of the TS #298 rule) #301

Description

@rahlk

PROBLEM

The TS bulk accessors (#298) ship get_method_bodies with a mechanical omission rule: entries whose code is None are omitted, so every returned value is a real str, documented on both the ABC and the facade. Python's implementations pass c.code straight through with no filter, and the docstrings make no such promise — a Dict[str, str] contract violation whenever a PyCallable carries no source text. Found during #298's final review.

SCOPE BOUNDARY

get_method_bodies on the Python side only — the in-memory backend and the Neo4j backend, plus the two docstring layers. Not the other bulk accessors, and not the TS side, which already has the rule.

GOALS

  • In-memory (cldk/analysis/python/codeanalyzer/codeanalyzer.py): filter on c.code is not None.
  • Neo4j (cldk/analysis/python/neo4j/neo4j_backend.py): add AND c.code IS NOT NULL to the MATCH, index the row directly instead of r.get("code").
  • Document the rule on the Python ABC and the facade, as TS does.
  • Land on both release lines.

CAVEATS AND KNOWN RISKS

  • Latent, not reproduced. It is unconfirmed whether codeanalyzer-python ever actually emits code=None; the fix closes a declared-contract hole either way, but no failing case has been observed.
  • The two backends must agree — fixing only the in-memory path recreates the dual-backend divergence this rule exists to prevent.

DEFINITION OF DONE

  • Every value returned by get_method_bodies is a real str on both backends, with a callable carrying code=None omitted rather than yielding None.
  • Python and TS return the same shape for the same input.
  • Rule stated in the ABC and facade docstrings.

STATUS

Fixed on release/2.0 by #305 (merged). Still open for main — the "both release lines" goal is unmet, and GitHub did not auto-close because #305 did not target the default branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions