|
| 1 | +from __future__ import annotations |
| 2 | + |
1 | 3 | import inspect as inspect_module |
2 | 4 | import ipaddress |
3 | 5 | import uuid |
@@ -115,7 +117,8 @@ def __dataclass_transform__( |
115 | 117 | return lambda a: a |
116 | 118 |
|
117 | 119 |
|
118 | | -class FieldInfo(PydanticFieldInfo): |
| 120 | +class FieldInfo(PydanticFieldInfo): # type: ignore[misc] |
| 121 | + # mypy - ignore that PydanticFieldInfo is @final |
119 | 122 | def __init__(self, default: Any = Undefined, **kwargs: Any) -> None: |
120 | 123 | primary_key = kwargs.pop("primary_key", False) |
121 | 124 | nullable = kwargs.pop("nullable", Undefined) |
@@ -671,7 +674,7 @@ def __init__( |
671 | 674 | setattr(cls, rel_name, rel_info.sa_relationship) # Fix #315 |
672 | 675 | continue |
673 | 676 | raw_ann = cls.__annotations__[rel_name] |
674 | | - origin = get_origin(raw_ann) |
| 677 | + origin: Any = get_origin(raw_ann) |
675 | 678 | if origin is Mapped: |
676 | 679 | ann = raw_ann.__args__[0] |
677 | 680 | else: |
@@ -934,27 +937,27 @@ def model_dump( |
934 | 937 | mode: Union[Literal["json", "python"], str] = "python", |
935 | 938 | include: Union[IncEx, None] = None, |
936 | 939 | exclude: Union[IncEx, None] = None, |
937 | | - context: Union[Any, None] = None, |
| 940 | + context: Union[Any, None] = None, # v2.7 |
938 | 941 | by_alias: Union[bool, None] = None, |
939 | 942 | exclude_unset: bool = False, |
940 | 943 | exclude_defaults: bool = False, |
941 | 944 | exclude_none: bool = False, |
| 945 | + exclude_computed_fields: bool = False, # v2.12 |
942 | 946 | round_trip: bool = False, |
943 | 947 | warnings: Union[bool, Literal["none", "warn", "error"]] = True, |
944 | | - fallback: Union[Callable[[Any], Any], None] = None, |
945 | | - serialize_as_any: bool = False, |
| 948 | + fallback: Union[Callable[[Any], Any], None] = None, # v2.11 |
| 949 | + serialize_as_any: bool = False, # v2.7 |
946 | 950 | ) -> Dict[str, Any]: |
947 | 951 | if PYDANTIC_MINOR_VERSION < (2, 11): |
948 | 952 | by_alias = by_alias or False |
| 953 | + extra_kwargs: Dict[str, Any] = {} |
949 | 954 | if PYDANTIC_MINOR_VERSION >= (2, 7): |
950 | | - extra_kwargs: Dict[str, Any] = { |
951 | | - "context": context, |
952 | | - "serialize_as_any": serialize_as_any, |
953 | | - } |
| 955 | + extra_kwargs["context"] = context |
| 956 | + extra_kwargs["serialize_as_any"] = serialize_as_any |
954 | 957 | if PYDANTIC_MINOR_VERSION >= (2, 11): |
955 | 958 | extra_kwargs["fallback"] = fallback |
956 | | - else: |
957 | | - extra_kwargs = {} |
| 959 | + if PYDANTIC_MINOR_VERSION >= (2, 12): |
| 960 | + extra_kwargs["exclude_computed_fields"] = exclude_computed_fields |
958 | 961 | if IS_PYDANTIC_V2: |
959 | 962 | return super().model_dump( |
960 | 963 | mode=mode, |
|
0 commit comments