|
|
@@ -194,13 +194,13 @@ def _validate(model: BaseModel):
|
|
|
"""Perform the actual model validation that we sabotaged w/ required() and similar functions"""
|
|
|
for k, fld in model.__pydantic_fields__.items():
|
|
|
attr = getattr(model, k)
|
|
|
- if fld.annotation is None:
|
|
|
+ if fld.annotation is None or isinstance(attr, fld.annotation):
|
|
|
continue
|
|
|
|
|
|
if isinstance(attr, (Ref, Factory, NoneType)):
|
|
|
raise TypeError(f"fld '{k}' in {type(model).__qualname__} is unset")
|
|
|
- if not isinstance(attr, fld.annotation):
|
|
|
- raise TypeError(
|
|
|
- f"field '{k}' in {type(model).__qualname__} is of the wrong type "
|
|
|
- f"(should be {fld.annotation})"
|
|
|
- )
|
|
|
+
|
|
|
+ raise TypeError(
|
|
|
+ f"field '{k}' in {type(model).__qualname__} is of the wrong type "
|
|
|
+ f"(should be {fld.annotation})"
|
|
|
+ )
|