8000 Simplify `GenerateJsonSchema.literal_schema()` implementation (#11321) · pydantic/pydantic@14d14b0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 14d14b0

Browse files
Simplify GenerateJsonSchema.literal_schema() implementation (#11321)
1 parent 6a5b640 commit 14d14b0

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

pydantic/json_schema.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -782,9 +782,7 @@ def literal_schema(self, schema: core_schema.LiteralSchema) -> JsonSchemaValue:
782782
Returns:
783783
The generated JSON schema.
784784
"""
785-
expected = [v.value if isinstance(v, Enum) else v for v in schema['expected']]
786-
# jsonify the expected values
787-
expected = [to_jsonable_python(v) for v in expected]
785+
expected = [to_jsonable_python(v.value if isinstance(v, Enum) else v) for v in schema['expected']]
788786

789787
result: dict[str, Any] = {}
790788
if len(expected) == 1:

0 commit comments

Comments
 (0)
0