Browse Source

add comment linking pydantic issue

pull/9837/head
JONEMI21 6 months ago
parent
commit
c7e6d8fba6
  1. 5
      fastapi/_compat/v2.py

5
fastapi/_compat/v2.py

@ -589,6 +589,11 @@ if shared.PYDANTIC_VERSION_MINOR_TUPLE >= (2, 6):
args = get_args(annotation) args = get_args(annotation)
if (origin is Union or origin is UnionType) and depth == 0: if (origin is Union or origin is UnionType) and depth == 0:
# making the depth check since the values of dicts being Union types
# is not working as expected as of Pydantic v2.12.3 so we just omit at
# the top level Union here for now
# https://github.com/pydantic/pydantic-core/issues/1900
# https://github.com/pydantic/pydantic/issues/12750
return Union[tuple(_omit_by_default(arg) for arg in args)] return Union[tuple(_omit_by_default(arg) for arg in args)]
elif origin is list: elif origin is list:
return list[_omit_by_default(args[0], depth=depth + 1)] # type: ignore[misc] return list[_omit_by_default(args[0], depth=depth + 1)] # type: ignore[misc]

Loading…
Cancel
Save