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
frompydanticimportBaseModelfromdecimalimportDecimalfromtypingimportUnionclassModel(BaseModel):
v: Union[str, Decimal]
model=Model(v=Decimal("1.1"))
model.v# '1.1' rather than Decimal('1.1')# But change Union position is correctclassModel(BaseModel):
v: Union[Decimal, str]
model=Model(v=Decimal("1.1"))
model.v# Decimal('1.1')
The text was updated successfully, but these errors were encountered:
Checks
Bug
Output of
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
:The text was updated successfully, but these errors were encountered: