add type hints for func is_optional_or_union

This commit is contained in:
honglei 2023-08-15 01:13:56 +08:00
parent a0b84c574d
commit fa8902c778

View File

@ -442,7 +442,7 @@ def get_sqlalchemy_type(field: FieldInfo) -> Any:
type_: Optional[type] = field.annotation
# Resolve Optional/Union fields
def is_optional_or_union(type_):
def is_optional_or_union(type_: Optional[type]) -> bool:
if sys.version_info >= (3, 10):
return get_origin(type_) in (types.UnionType, Union)
else: