|
|
@ -585,10 +585,10 @@ if shared.PYDANTIC_VERSION_MINOR_TUPLE >= (2, 6): |
|
|
# Omit by default for scalar mapping and scalar sequence mapping annotations |
|
|
# Omit by default for scalar mapping and scalar sequence mapping annotations |
|
|
# added in Pydantic v2.6 https://github.com/pydantic/pydantic/releases/tag/v2.6.0 |
|
|
# added in Pydantic v2.6 https://github.com/pydantic/pydantic/releases/tag/v2.6.0 |
|
|
def _omit_by_default(annotation: Any) -> Any: |
|
|
def _omit_by_default(annotation: Any) -> Any: |
|
|
origin = getattr(annotation, "__origin__", None) |
|
|
origin = get_origin(annotation) |
|
|
args = getattr(annotation, "__args__", ()) |
|
|
args = get_args(annotation) |
|
|
|
|
|
|
|
|
if origin is Union: |
|
|
if origin is Union or origin is UnionType: |
|
|
new_args = tuple(_omit_by_default(arg) for arg in args) |
|
|
new_args = tuple(_omit_by_default(arg) for arg in args) |
|
|
return Union[new_args] |
|
|
return Union[new_args] |
|
|
elif origin is list: |
|
|
elif origin is list: |
|
|
|