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
Dataclasses with FrozenSet members fail upon declaration. #745
Comments
This is not a bug, but a feature request to support the typing type We should also improve the error handling to explain what's going on.
PR welcome, but probably won't be merged until v1.1. |
Fixes pydantic#745 Add a better error message for fields with types from the typing module that are not directly supported by Pydantic. Previously, it caused a cryptic assertion failure.
Fixes pydantic#745 Add a better error message for fields with types from the typing module that are not directly supported by Pydantic. Previously, it caused a cryptic assertion failure.
Also provide an example of their usage. Fixes pydantic#745
djpetti commentedAug 13, 2019
•
edited
Feature Request
Please complete:
import sys; print(sys.version)
: 3.7.3import pydantic; print(pydantic.VERSION)
: 0.32.1When creating a pydantic dataclass that has a
FrozenSet
member, initialization fails in the@dataclass
decorator.For example,
will fail with an assertion error:
Looking in the
pydantic
source code, it looks like this has to do with how it determines the type of the field. Specifically, the issue is thatFrozenSet
, somewhat counter-intuitively, does not appear to be a subtype ofSet
:It looks like this if-else block has to be amended with a specific case for
FrozenSet
.The text was updated successfully, but these errors were encountered: