Fix output_verbosity Literal to accept int values for unittest tester - #733
Merged
david-yz-liu merged 4 commits intoJul 2, 2026
Conversation
donny-wong
marked this pull request as ready for review
June 28, 2026 14:44
Naragod
approved these changes
Jun 28, 2026
david-yz-liu
approved these changes
Jul 2, 2026
david-yz-liu
left a comment
Contributor
There was a problem hiding this comment.
Thanks, @donny-wong!
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.
Problem
output_verbosityinPyTestData(shared by the pytest and unittest testers) was typed as a string-onlyLiteral. The unittest tester uses integer verbosity levels (0/1/2, matching Python'sunittest), and the MarkUs form already emits these ints — the manually patched JSON Schema enum allowed them. But the Struct type did not, so msgspec would reject an int-valuedoutput_verbosityon decode.We don't currently decode tester configs with msgspec (we read them as plain dicts), so nothing is breaking today. This aligns the type with the data and the already-patched schema so we're ready if/when we adopt msgspec decoding.
Fix
Adding the ints as a single mixed
Literal[..., 0, 1, 2]isn't viable:msgspec.json.schema_componentssorts Literal values to build the enum, and sorting mixedint/strraisesTypeError: '<' not supported between instances of 'int' and 'str', breaking schema generation. Sooutput_verbosityis now a union of two same-typed Literals:pythonLiteral["", "short", "auto", "long", "no", "line", "native"] | Literal[0, 1, 2]msgspec emits this as an
anyOfof two enums. Insettings(), the old hardcoded enum patch is replaced with a step that flattens thatanyOfinto a single flatenum, which is the shape the form (rjsf) expects. The allowed values now live in the type and drive both validation and the generated schema, rather than a separately maintained hardcoded list.