field required

This commit is contained in:
honglei 2023-08-16 22:58:10 +08:00
parent 72dc89d92b
commit fa8955c700

View File

@ -666,9 +666,7 @@ def _is_field_noneable(field: FieldInfo) -> bool:
return field.nullable return field.nullable
if not field.is_required(): if not field.is_required():
default = getattr(field, "original_default", field.default) default = getattr(field, "original_default", field.default)
if default is None: if default is PydanticUndefined:
return True
elif default is PydanticUndefined:
return False return False
if field.annotation is None or field.annotation is NoneType: if field.annotation is None or field.annotation is NoneType:
return True return True