You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/jamie/.virtualenvs/tempenv-74cd74727d61/lib/python3.7/site-packages/pydantic/schema.py", line 185, in schema
flat_models = get_flat_models_from_models(models)
File "/Users/jamie/.virtualenvs/tempenv-74cd74727d61/lib/python3.7/site-packages/pydantic/schema.py", line 437, in get_flat_models_from_models
flat_models |= get_flat_models_from_model(model)
File "/Users/jamie/.virtualenvs/tempenv-74cd74727d61/lib/python3.7/site-packages/pydantic/schema.py", line 378, in get_flat_models_from_model
fields = cast(Sequence[Field], model.__fields__.values())
AttributeError: type object 'Model' has no attribute '__fields__'
The same code using BaseModel instead of the @dataclass works fine.
With the dataclass, Model.__pydantic_model__.schema() also works.
The text was updated successfully, but these errors were encountered:
That's not how the schema function is designed to work. Did you find somewhere in the docs that suggested that?
Ah, apologies, I must've misunderstood. I mostly just expected dataclasses to work similarly to things that inherit from BaseModel and don't think I read that schema() supports them.
I'd like to make a PR but honestly I'm not sure when I will have the time, so feel free to close if you want.
no problem. Would definitely be better if schema() worked with dataclasses as it does with models, so I'll leave this open and fix it when I get a chance if no one else does before.
Bug
Please complete:
import sys; print(sys.version)
: 3.7.4import pydantic; print(pydantic.VERSION)
: 0.32.2, as well as master as of 7901711Where possible please include a self contained code snippet describing your bug:
This produces an error message like:
The same code using
BaseModel
instead of the@dataclass
works fine.With the
dataclass
,Model.__pydantic_model__.schema()
also works.The text was updated successfully, but these errors were encountered: