We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c8cc4ae commit 0fdc9f3Copy full SHA for 0fdc9f3
1 file changed
fastapi_amis_admin/utils/pydantic.py
@@ -66,10 +66,18 @@ def field_outer_type(field: ModelField) -> Any:
66
return field.field_info.annotation
67
68
def field_allow_none(field: ModelField) -> bool:
69
- if is_union(field.field_info.annotation):
70
- for t in get_args(field.field_info.annotation):
71
- if is_none_type(t):
72
- return True
+ ann = field.field_info.annotation
+ if not is_union(ann):
+ origin = get_origin(ann)
+ if origin is None:
73
+ return False
74
+ elif origin is Annotated:
75
+ return field_allow_none(get_args(ann)[0])
76
+ elif not is_union(origin):
77
78
+ for t in get_args(ann):
79
+ if is_none_type(t):
80
+ return True
81
return False
82
83
@lru_cache(maxsize=512)
0 commit comments