apparently we should use .annotation, and .allow_none is useless
This commit is contained in:
parent
c9fe2e10b3
commit
c2a39b46d7
@ -14,6 +14,7 @@ from typing import (
|
|||||||
Callable,
|
Callable,
|
||||||
ClassVar,
|
ClassVar,
|
||||||
Dict,
|
Dict,
|
||||||
|
ForwardRef,
|
||||||
FrozenSet,
|
FrozenSet,
|
||||||
Iterable,
|
Iterable,
|
||||||
List,
|
List,
|
||||||
@ -278,14 +279,9 @@ def true_type_for_pydantic_field(f: ModelField):
|
|||||||
Returns:
|
Returns:
|
||||||
The type for the field.
|
The type for the field.
|
||||||
"""
|
"""
|
||||||
outer_type = f.outer_type_
|
if not isinstance(f.annotation, (str, ForwardRef)):
|
||||||
if (
|
return f.annotation
|
||||||
f.allow_none
|
return f.outer_type_
|
||||||
and not is_optional(outer_type)
|
|
||||||
and outer_type not in (None, type(None))
|
|
||||||
):
|
|
||||||
return Optional[outer_type]
|
|
||||||
return outer_type
|
|
||||||
|
|
||||||
|
|
||||||
def value_inside_optional(cls: GenericType) -> GenericType:
|
def value_inside_optional(cls: GenericType) -> GenericType:
|
||||||
|
Loading…
Reference in New Issue
Block a user