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
@pytest.mark.xfail(reason='strict=True in model_validate_json does not overwrite strict=False given in ConfigDict''See issue: https://github.com/pydantic/pydantic/issues/8930')deftest_model_validate_list_strict() ->None:
# FIXME: This change must be implemented in pydantic-core. The argument strict=True# in model_validate_json method is not overwriting the one set with ConfigDict(strict=False)# for sequence like types. See: https://github.com/pydantic/pydantic/issues/8930classLaxModel(BaseModel):
x: List[str]
model_config=ConfigDict(strict=False)
assertLaxModel.model_validate_json(json.dumps({'x': ('a', 'b', 'c')}), strict=None) ==LaxModel(x=('a', 'b', 'c'))
assertLaxModel.model_validate_json(json.dumps({'x': ('a', 'b', 'c')}), strict=False) ==LaxModel(x=('a', 'b', 'c'))
withpytest.raises(ValidationError) asexc_info:
LaxModel.model_validate_json(json.dumps({'x': ('a', 'b', 'c')}), strict=True)
assertexc_info.value.errors(include_url=False) == [
{'type': 'list_type', 'loc': ('x',), 'msg': 'Input should be a valid list', 'input': ('a', 'b', 'c')}
]
Revealed when investigating our abundance of sequence validator issues :)
The text was updated successfully, but these errors were encountered:
Revealed when investigating our abundance of sequence validator issues :)
The text was updated successfully, but these errors were encountered: