Uh oh!
There was an error while loading. Please reload this page.
Omit None-code callables from Python get_method_bodies - #305
Merged
Conversation
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 #3014 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the Python half of the bulk-accessor parity gap found during #298's review.
Problem
The TypeScript bulk accessors ship
get_method_bodieswith a mechanical omission rule: a callable whosecodeisNoneis left out, so every value in the returnedDict[str, str]is a realstr. Python passedcodestraight through, so aPyCallablewith no source text yielded aNonevalue — a violation of the declaredDict[str, str]contract.Change
Aligns Python upward to the TS rule, in both backends:
codeanalyzer.py) — filter onc.code is not None, matching the TS loop.neo4j_backend.py) — addAND c.code IS NOT NULLto theMATCHand index the row directly instead ofr.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
stris 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