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
Support "Field()" on dataclasses #470
Comments
I think |
Probably related to this, you can't export a schema with dataclasses. from pydantic.schema import schema
from pydantic.dataclasses import dataclass
@dataclass
class Foo:
a: str = None
@dataclass
class Bar:
b: Foo
name: str
top_level_schema = schema([Foo, Bar])
print(top_level_schema)
|
You should use the underlying pydantic model: top_level_schema = schema([Foo.__pydantic_model__, Bar.__pydantic_model__]) it's not yet in the documentation but I found it here in a few issues. |
A related (maybe the same?) issue on using Schema with dataclasses if anyone's working on it: default value isn't used, instead you get the Schema instance.
|
Similar issue, again shouldn't be that hard to fix if someone wants to work on it. |
Bug
When using
pydantic.Schema
in combination with optionalWhen calling it with all the arguments filled it works as expected
The text was updated successfully, but these errors were encountered: