Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core_schema.union_schema (and possibly others) create schemas with incorrect types #427

Closed
dmontagu opened this issue Mar 9, 2023 · 1 comment · Fixed by #431
Closed
Assignees
Labels
bug Something isn't working

Comments

@dmontagu
Copy link
Collaborator

dmontagu commented Mar 9, 2023

Despite this type annotation:

choices: Required[List[CoreSchema]]

Using the core_schema.union_schema produces a schema with type(schema['choices']) is tuple:

from pydantic_core import core_schema

schema = core_schema.union_schema(core_schema.int_schema(), core_schema.str_schema())
print(schema['choices'])
# ({'type': 'int'}, {'type': 'str'})

I haven't checked, but I wouldn't be surprised if this behavior was consistent across other functions using the *args syntax to accept multiple items.

@adriangb
Copy link
Member

I saw this once before and couldn’t figure out why it was happening. Glad you spotted it! I’ll make a PR, hopefully tonight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants