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
I have searched GitHub for a duplicate issue and I'm sure this is something new
I have searched Google & StackOverflow for a solution and couldn't find anything
I have read and followed the docs and still think this is a bug
I am confident that the issue is with pydantic (not my code, or another library in the ecosystem like FastAPI or mypy)
Description
This is because _enforce_dict_if_root() checks only for dicts with root key but not for models with root key.
Example Code
frompydanticimportBaseModelclassTest(BaseModel):
__root__: intTest.parse_obj(dict(Test.parse_obj(1))) # works fineTest.parse_obj(Test.parse_obj(1))
# Expected: Test(__root__=1)# Actual: pydantic.error_wrappers.ValidationError: 1 validation error for Test# __root__# value is not a valid integer (type=type_error.integer)
Initial Checks
Description
This is because _enforce_dict_if_root() checks only for dicts with root key but not for models with root key.
Example Code
Python, Pydantic & OS Version
Affected Components
.dict()
and.json()
construct()
, pickling, private attributes, ORM modeThe text was updated successfully, but these errors were encountered: