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
fromtypingimportLiteral, UnionfrompydanticimportBaseModel, conintclassA(BaseModel):
tag: Literal["a"]
classB(BaseModel):
tag: Literal["b"]
x: conint(ge=0, le=1)
classModel(BaseModel):
value: Union[A, B]
Model(value={"tag": "b", "x": 2}) # this will fail with "tag must be 'a'" and "x" must be LE 1
I would expect the error to be just "'x' needs to be LE 1", but the error also complains that "'tag' must be 'a'".
Checks
Bug
Output of
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
:Tested with git checkout 5ccbdcb.
See this test in my branch.
I would expect the error to be just "'x' needs to be LE 1", but the error also complains that "'tag' must be 'a'".
This is somewhat related to #619
The text was updated successfully, but these errors were encountered: