fix(python): preserve boolean const discriminators in RPC codegen - #2162
Closed
syf2211 wants to merge 1 commit into
Closed
fix(python): preserve boolean const discriminators in RPC codegen#2162syf2211 wants to merge 1 commit into
syf2211 wants to merge 1 commit into
Conversation
Boolean JSON schema const values were coerced to strings during Python codegen, breaking match dispatchers for SessionListEntry and QueuedCommandResult. Preserve bool consts and emit True/False patterns and ClassVar[bool] defaults, matching the Go generator behavior. Fixes github#2122
Contributor
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 free
to 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.
Summary
Fix Python RPC codegen so JSON boolean
constdiscriminator values are preserved instead of being coerced to strings. This restores decoding forSessionListEntry(isRemote) andQueuedCommandResult(handled).Motivation
sessions.list()raisedValueErrorfor any non-empty session list because the generated dispatcher matchedcase "true":/case "false":against Pythonboolvalues.QueuedCommandHandled.to_dict()also serializedhandledas the string"true"instead of JSON booleantrue.Fixes #2122
Changes
PyDiscriminatorValuehelpers inscripts/codegen/python.tsto emitTrue/Falsematch patterns andClassVar[bool]defaultspython/copilot/generated/rpc.pySessionList.from_dictTests
Result: 3 passed
Notes
JSON.stringifypath preserved)