From 562b883be379eb1029b5bc8bffb11ad298cc6d44 Mon Sep 17 00:00:00 2001 From: armandobelardo Date: Tue, 13 Aug 2024 20:40:41 -0400 Subject: [PATCH 1/7] stop calling dict twice --- .../fastapi/pydantic_utilities.py | 65 ++- .../pydantic/pydantic_utilities.py | 65 ++- .../core_utilities/sdk/pydantic_utilities.py | 65 ++- generators/python/poetry.lock | 439 +++++++++--------- generators/python/pyproject.toml | 2 +- .../python/tests/utils/test_union_utils.py | 7 +- generators/python/tests/utils/test_unset.py | 14 + generators/python/tests/utils/union_utils/2.0 | 8 + .../utils/union_utils/fern/generators.yml | 2 + .../tests/utils/union_utils/types/__init__.py | 12 +- .../types/core/pydantic_utilities.py | 54 ++- .../union_utils/types/resources/__init__.py | 12 +- .../types/resources/types/__init__.py | 3 +- .../union_utils/types/resources/types/name.py | 27 ++ 14 files changed, 487 insertions(+), 288 deletions(-) create mode 100644 generators/python/tests/utils/test_unset.py create mode 100644 generators/python/tests/utils/union_utils/2.0 create mode 100644 generators/python/tests/utils/union_utils/types/resources/types/name.py diff --git a/generators/python/core_utilities/fastapi/pydantic_utilities.py b/generators/python/core_utilities/fastapi/pydantic_utilities.py index 4b1656e2df3..b6dc264ae70 100644 --- a/generators/python/core_utilities/fastapi/pydantic_utilities.py +++ b/generators/python/core_utilities/fastapi/pydantic_utilities.py @@ -1,5 +1,8 @@ +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt +from tkinter import E import typing from collections import defaultdict @@ -104,27 +107,29 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -174,13 +179,39 @@ def decorator(func: AnyCallable) -> AnyCallable: return decorator -def universal_field_validator(field_name: str, pre: bool = False) -> typing.Callable[[AnyCallable], AnyCallable]: +def universal_field_validator( + field_name: str, pre: bool = False +) -> typing.Callable[[AnyCallable], AnyCallable]: def decorator(func: AnyCallable) -> AnyCallable: if IS_PYDANTIC_V2: - return pydantic.field_validator(field_name, mode="before" if pre else "after")( - func - ) # type: ignore # Pydantic v2 + return pydantic.field_validator( + field_name, mode="before" if pre else "after" + )(func) # type: ignore # Pydantic v2 else: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/generators/python/core_utilities/pydantic/pydantic_utilities.py b/generators/python/core_utilities/pydantic/pydantic_utilities.py index 4b1656e2df3..b6dc264ae70 100644 --- a/generators/python/core_utilities/pydantic/pydantic_utilities.py +++ b/generators/python/core_utilities/pydantic/pydantic_utilities.py @@ -1,5 +1,8 @@ +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt +from tkinter import E import typing from collections import defaultdict @@ -104,27 +107,29 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -174,13 +179,39 @@ def decorator(func: AnyCallable) -> AnyCallable: return decorator -def universal_field_validator(field_name: str, pre: bool = False) -> typing.Callable[[AnyCallable], AnyCallable]: +def universal_field_validator( + field_name: str, pre: bool = False +) -> typing.Callable[[AnyCallable], AnyCallable]: def decorator(func: AnyCallable) -> AnyCallable: if IS_PYDANTIC_V2: - return pydantic.field_validator(field_name, mode="before" if pre else "after")( - func - ) # type: ignore # Pydantic v2 + return pydantic.field_validator( + field_name, mode="before" if pre else "after" + )(func) # type: ignore # Pydantic v2 else: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/generators/python/core_utilities/sdk/pydantic_utilities.py b/generators/python/core_utilities/sdk/pydantic_utilities.py index 4b1656e2df3..b6dc264ae70 100644 --- a/generators/python/core_utilities/sdk/pydantic_utilities.py +++ b/generators/python/core_utilities/sdk/pydantic_utilities.py @@ -1,5 +1,8 @@ +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt +from tkinter import E import typing from collections import defaultdict @@ -104,27 +107,29 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -174,13 +179,39 @@ def decorator(func: AnyCallable) -> AnyCallable: return decorator -def universal_field_validator(field_name: str, pre: bool = False) -> typing.Callable[[AnyCallable], AnyCallable]: +def universal_field_validator( + field_name: str, pre: bool = False +) -> typing.Callable[[AnyCallable], AnyCallable]: def decorator(func: AnyCallable) -> AnyCallable: if IS_PYDANTIC_V2: - return pydantic.field_validator(field_name, mode="before" if pre else "after")( - func - ) # type: ignore # Pydantic v2 + return pydantic.field_validator( + field_name, mode="before" if pre else "after" + )(func) # type: ignore # Pydantic v2 else: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/generators/python/poetry.lock b/generators/python/poetry.lock index d44e4d79380..446c15d34ad 100644 --- a/generators/python/poetry.lock +++ b/generators/python/poetry.lock @@ -1,15 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. - -[[package]] -name = "annotated-types" -version = "0.7.0" -description = "Reusable constraint types to use with typing.Annotated" -optional = false -python-versions = ">=3.8" -files = [ - {file = "annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53"}, - {file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"}, -] +# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "anyio" @@ -311,45 +300,46 @@ files = [ [[package]] name = "httpcore" -version = "0.16.3" +version = "1.0.5" description = "A minimal low-level HTTP client." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "httpcore-0.16.3-py3-none-any.whl", hash = "sha256:da1fb708784a938aa084bde4feb8317056c55037247c787bd7e19eb2c2949dc0"}, - {file = "httpcore-0.16.3.tar.gz", hash = "sha256:c5d6f04e2fc530f39e0c077e6a30caa53f1451096120f1f38b954afd0b17c0cb"}, + {file = "httpcore-1.0.5-py3-none-any.whl", hash = "sha256:421f18bac248b25d310f3cacd198d55b8e6125c107797b609ff9b7a6ba7991b5"}, + {file = "httpcore-1.0.5.tar.gz", hash = "sha256:34a38e2f9291467ee3b44e89dd52615370e152954ba21721378a87b2960f7a61"}, ] [package.dependencies] -anyio = ">=3.0,<5.0" certifi = "*" h11 = ">=0.13,<0.15" -sniffio = "==1.*" [package.extras] +asyncio = ["anyio (>=4.0,<5.0)"] http2 = ["h2 (>=3,<5)"] socks = ["socksio (==1.*)"] +trio = ["trio (>=0.22.0,<0.26.0)"] [[package]] name = "httpx" -version = "0.23.3" +version = "0.27.0" description = "The next generation HTTP client." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "httpx-0.23.3-py3-none-any.whl", hash = "sha256:a211fcce9b1254ea24f0cd6af9869b3d29aba40154e947d2a07bb499b3e310d6"}, - {file = "httpx-0.23.3.tar.gz", hash = "sha256:9818458eb565bb54898ccb9b8b251a28785dd4a55afbc23d0eb410754fe7d0f9"}, + {file = "httpx-0.27.0-py3-none-any.whl", hash = "sha256:71d5465162c13681bff01ad59b2cc68dd838ea1f10e51574bac27103f00c91a5"}, + {file = "httpx-0.27.0.tar.gz", hash = "sha256:a0cb88a46f32dc874e04ee956e4c2764aba2aa228f650b06788ba6bda2962ab5"}, ] [package.dependencies] +anyio = "*" certifi = "*" -httpcore = ">=0.15.0,<0.17.0" -rfc3986 = {version = ">=1.3,<2", extras = ["idna2008"]} +httpcore = "==1.*" +idna = "*" sniffio = "*" [package.extras] brotli = ["brotli", "brotlicffi"] -cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<13)"] +cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"] http2 = ["h2 (>=3,<5)"] socks = ["socksio (==1.*)"] @@ -581,122 +571,152 @@ files = [ [[package]] name = "pydantic" -version = "2.8.2" -description = "Data validation using Python type hints" +version = "1.10.15" +description = "Data validation and settings management using python type hints" optional = false -python-versions = ">=3.8" +python-versions = ">=3.7" files = [ - {file = "pydantic-2.8.2-py3-none-any.whl", hash = "sha256:73ee9fddd406dc318b885c7a2eab8a6472b68b8fb5ba8150949fc3db939f23c8"}, - {file = "pydantic-2.8.2.tar.gz", hash = "sha256:6f62c13d067b0755ad1c21a34bdd06c0c12625a22b0fc09c6b149816604f7c2a"}, + {file = "pydantic-1.10.15-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:22ed12ee588b1df028a2aa5d66f07bf8f8b4c8579c2e96d5a9c1f96b77f3bb55"}, + {file = "pydantic-1.10.15-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:75279d3cac98186b6ebc2597b06bcbc7244744f6b0b44a23e4ef01e5683cc0d2"}, + {file = "pydantic-1.10.15-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:50f1666a9940d3d68683c9d96e39640f709d7a72ff8702987dab1761036206bb"}, + {file = "pydantic-1.10.15-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:82790d4753ee5d00739d6cb5cf56bceb186d9d6ce134aca3ba7befb1eedbc2c8"}, + {file = "pydantic-1.10.15-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:d207d5b87f6cbefbdb1198154292faee8017d7495a54ae58db06762004500d00"}, + {file = "pydantic-1.10.15-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:e49db944fad339b2ccb80128ffd3f8af076f9f287197a480bf1e4ca053a866f0"}, + {file = "pydantic-1.10.15-cp310-cp310-win_amd64.whl", hash = "sha256:d3b5c4cbd0c9cb61bbbb19ce335e1f8ab87a811f6d589ed52b0254cf585d709c"}, + {file = "pydantic-1.10.15-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c3d5731a120752248844676bf92f25a12f6e45425e63ce22e0849297a093b5b0"}, + {file = "pydantic-1.10.15-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c365ad9c394f9eeffcb30a82f4246c0006417f03a7c0f8315d6211f25f7cb654"}, + {file = "pydantic-1.10.15-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3287e1614393119c67bd4404f46e33ae3be3ed4cd10360b48d0a4459f420c6a3"}, + {file = "pydantic-1.10.15-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:be51dd2c8596b25fe43c0a4a59c2bee4f18d88efb8031188f9e7ddc6b469cf44"}, + {file = "pydantic-1.10.15-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:6a51a1dd4aa7b3f1317f65493a182d3cff708385327c1c82c81e4a9d6d65b2e4"}, + {file = "pydantic-1.10.15-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:4e316e54b5775d1eb59187f9290aeb38acf620e10f7fd2f776d97bb788199e53"}, + {file = "pydantic-1.10.15-cp311-cp311-win_amd64.whl", hash = "sha256:0d142fa1b8f2f0ae11ddd5e3e317dcac060b951d605fda26ca9b234b92214986"}, + {file = "pydantic-1.10.15-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:7ea210336b891f5ea334f8fc9f8f862b87acd5d4a0cbc9e3e208e7aa1775dabf"}, + {file = "pydantic-1.10.15-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3453685ccd7140715e05f2193d64030101eaad26076fad4e246c1cc97e1bb30d"}, + {file = "pydantic-1.10.15-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9bea1f03b8d4e8e86702c918ccfd5d947ac268f0f0cc6ed71782e4b09353b26f"}, + {file = "pydantic-1.10.15-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:005655cabc29081de8243126e036f2065bd7ea5b9dff95fde6d2c642d39755de"}, + {file = "pydantic-1.10.15-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:af9850d98fc21e5bc24ea9e35dd80a29faf6462c608728a110c0a30b595e58b7"}, + {file = "pydantic-1.10.15-cp37-cp37m-win_amd64.whl", hash = "sha256:d31ee5b14a82c9afe2bd26aaa405293d4237d0591527d9129ce36e58f19f95c1"}, + {file = "pydantic-1.10.15-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:5e09c19df304b8123938dc3c53d3d3be6ec74b9d7d0d80f4f4b5432ae16c2022"}, + {file = "pydantic-1.10.15-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7ac9237cd62947db00a0d16acf2f3e00d1ae9d3bd602b9c415f93e7a9fc10528"}, + {file = "pydantic-1.10.15-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:584f2d4c98ffec420e02305cf675857bae03c9d617fcfdc34946b1160213a948"}, + {file = "pydantic-1.10.15-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:bbc6989fad0c030bd70a0b6f626f98a862224bc2b1e36bfc531ea2facc0a340c"}, + {file = "pydantic-1.10.15-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:d573082c6ef99336f2cb5b667b781d2f776d4af311574fb53d908517ba523c22"}, + {file = "pydantic-1.10.15-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6bd7030c9abc80134087d8b6e7aa957e43d35714daa116aced57269a445b8f7b"}, + {file = "pydantic-1.10.15-cp38-cp38-win_amd64.whl", hash = "sha256:3350f527bb04138f8aff932dc828f154847fbdc7a1a44c240fbfff1b57f49a12"}, + {file = "pydantic-1.10.15-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:51d405b42f1b86703555797270e4970a9f9bd7953f3990142e69d1037f9d9e51"}, + {file = "pydantic-1.10.15-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a980a77c52723b0dc56640ced396b73a024d4b74f02bcb2d21dbbac1debbe9d0"}, + {file = "pydantic-1.10.15-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:67f1a1fb467d3f49e1708a3f632b11c69fccb4e748a325d5a491ddc7b5d22383"}, + {file = "pydantic-1.10.15-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:676ed48f2c5bbad835f1a8ed8a6d44c1cd5a21121116d2ac40bd1cd3619746ed"}, + {file = "pydantic-1.10.15-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:92229f73400b80c13afcd050687f4d7e88de9234d74b27e6728aa689abcf58cc"}, + {file = "pydantic-1.10.15-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:2746189100c646682eff0bce95efa7d2e203420d8e1c613dc0c6b4c1d9c1fde4"}, + {file = "pydantic-1.10.15-cp39-cp39-win_amd64.whl", hash = "sha256:394f08750bd8eaad714718812e7fab615f873b3cdd0b9d84e76e51ef3b50b6b7"}, + {file = "pydantic-1.10.15-py3-none-any.whl", hash = "sha256:28e552a060ba2740d0d2aabe35162652c1459a0b9069fe0db7f4ee0e18e74d58"}, + {file = "pydantic-1.10.15.tar.gz", hash = "sha256:ca832e124eda231a60a041da4f013e3ff24949d94a01154b137fc2f2a43c3ffb"}, ] [package.dependencies] -annotated-types = ">=0.4.0" -pydantic-core = "2.20.1" -typing-extensions = [ - {version = ">=4.12.2", markers = "python_version >= \"3.13\""}, - {version = ">=4.6.1", markers = "python_version < \"3.13\""}, -] +typing-extensions = ">=4.2.0" [package.extras] -email = ["email-validator (>=2.0.0)"] +dotenv = ["python-dotenv (>=0.10.4)"] +email = ["email-validator (>=1.0.3)"] [[package]] name = "pydantic-core" -version = "2.20.1" +version = "2.21.0" description = "Core functionality for Pydantic validation and serialization" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic_core-2.20.1-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:3acae97ffd19bf091c72df4d726d552c473f3576409b2a7ca36b2f535ffff4a3"}, - {file = "pydantic_core-2.20.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:41f4c96227a67a013e7de5ff8f20fb496ce573893b7f4f2707d065907bffdbd6"}, - {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5f239eb799a2081495ea659d8d4a43a8f42cd1fe9ff2e7e436295c38a10c286a"}, - {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:53e431da3fc53360db73eedf6f7124d1076e1b4ee4276b36fb25514544ceb4a3"}, - {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f1f62b2413c3a0e846c3b838b2ecd6c7a19ec6793b2a522745b0869e37ab5bc1"}, - {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5d41e6daee2813ecceea8eda38062d69e280b39df793f5a942fa515b8ed67953"}, - {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3d482efec8b7dc6bfaedc0f166b2ce349df0011f5d2f1f25537ced4cfc34fd98"}, - {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:e93e1a4b4b33daed65d781a57a522ff153dcf748dee70b40c7258c5861e1768a"}, - {file = "pydantic_core-2.20.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:e7c4ea22b6739b162c9ecaaa41d718dfad48a244909fe7ef4b54c0b530effc5a"}, - {file = "pydantic_core-2.20.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:4f2790949cf385d985a31984907fecb3896999329103df4e4983a4a41e13e840"}, - {file = "pydantic_core-2.20.1-cp310-none-win32.whl", hash = "sha256:5e999ba8dd90e93d57410c5e67ebb67ffcaadcea0ad973240fdfd3a135506250"}, - {file = "pydantic_core-2.20.1-cp310-none-win_amd64.whl", hash = "sha256:512ecfbefef6dac7bc5eaaf46177b2de58cdf7acac8793fe033b24ece0b9566c"}, - {file = "pydantic_core-2.20.1-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:d2a8fa9d6d6f891f3deec72f5cc668e6f66b188ab14bb1ab52422fe8e644f312"}, - {file = "pydantic_core-2.20.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:175873691124f3d0da55aeea1d90660a6ea7a3cfea137c38afa0a5ffabe37b88"}, - {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:37eee5b638f0e0dcd18d21f59b679686bbd18917b87db0193ae36f9c23c355fc"}, - {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:25e9185e2d06c16ee438ed39bf62935ec436474a6ac4f9358524220f1b236e43"}, - {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:150906b40ff188a3260cbee25380e7494ee85048584998c1e66df0c7a11c17a6"}, - {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8ad4aeb3e9a97286573c03df758fc7627aecdd02f1da04516a86dc159bf70121"}, - {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d3f3ed29cd9f978c604708511a1f9c2fdcb6c38b9aae36a51905b8811ee5cbf1"}, - {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:b0dae11d8f5ded51699c74d9548dcc5938e0804cc8298ec0aa0da95c21fff57b"}, - {file = "pydantic_core-2.20.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:faa6b09ee09433b87992fb5a2859efd1c264ddc37280d2dd5db502126d0e7f27"}, - {file = "pydantic_core-2.20.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:9dc1b507c12eb0481d071f3c1808f0529ad41dc415d0ca11f7ebfc666e66a18b"}, - {file = "pydantic_core-2.20.1-cp311-none-win32.whl", hash = "sha256:fa2fddcb7107e0d1808086ca306dcade7df60a13a6c347a7acf1ec139aa6789a"}, - {file = "pydantic_core-2.20.1-cp311-none-win_amd64.whl", hash = "sha256:40a783fb7ee353c50bd3853e626f15677ea527ae556429453685ae32280c19c2"}, - {file = "pydantic_core-2.20.1-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:595ba5be69b35777474fa07f80fc260ea71255656191adb22a8c53aba4479231"}, - {file = "pydantic_core-2.20.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:a4f55095ad087474999ee28d3398bae183a66be4823f753cd7d67dd0153427c9"}, - {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f9aa05d09ecf4c75157197f27cdc9cfaeb7c5f15021c6373932bf3e124af029f"}, - {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e97fdf088d4b31ff4ba35db26d9cc472ac7ef4a2ff2badeabf8d727b3377fc52"}, - {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bc633a9fe1eb87e250b5c57d389cf28998e4292336926b0b6cdaee353f89a237"}, - {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d573faf8eb7e6b1cbbcb4f5b247c60ca8be39fe2c674495df0eb4318303137fe"}, - {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:26dc97754b57d2fd00ac2b24dfa341abffc380b823211994c4efac7f13b9e90e"}, - {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:33499e85e739a4b60c9dac710c20a08dc73cb3240c9a0e22325e671b27b70d24"}, - {file = "pydantic_core-2.20.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:bebb4d6715c814597f85297c332297c6ce81e29436125ca59d1159b07f423eb1"}, - {file = "pydantic_core-2.20.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:516d9227919612425c8ef1c9b869bbbee249bc91912c8aaffb66116c0b447ebd"}, - {file = "pydantic_core-2.20.1-cp312-none-win32.whl", hash = "sha256:469f29f9093c9d834432034d33f5fe45699e664f12a13bf38c04967ce233d688"}, - {file = "pydantic_core-2.20.1-cp312-none-win_amd64.whl", hash = "sha256:035ede2e16da7281041f0e626459bcae33ed998cca6a0a007a5ebb73414ac72d"}, - {file = "pydantic_core-2.20.1-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:0827505a5c87e8aa285dc31e9ec7f4a17c81a813d45f70b1d9164e03a813a686"}, - {file = "pydantic_core-2.20.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:19c0fa39fa154e7e0b7f82f88ef85faa2a4c23cc65aae2f5aea625e3c13c735a"}, - {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4aa223cd1e36b642092c326d694d8bf59b71ddddc94cdb752bbbb1c5c91d833b"}, - {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c336a6d235522a62fef872c6295a42ecb0c4e1d0f1a3e500fe949415761b8a19"}, - {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7eb6a0587eded33aeefea9f916899d42b1799b7b14b8f8ff2753c0ac1741edac"}, - {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:70c8daf4faca8da5a6d655f9af86faf6ec2e1768f4b8b9d0226c02f3d6209703"}, - {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e9fa4c9bf273ca41f940bceb86922a7667cd5bf90e95dbb157cbb8441008482c"}, - {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:11b71d67b4725e7e2a9f6e9c0ac1239bbc0c48cce3dc59f98635efc57d6dac83"}, - {file = "pydantic_core-2.20.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:270755f15174fb983890c49881e93f8f1b80f0b5e3a3cc1394a255706cabd203"}, - {file = "pydantic_core-2.20.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:c81131869240e3e568916ef4c307f8b99583efaa60a8112ef27a366eefba8ef0"}, - {file = "pydantic_core-2.20.1-cp313-none-win32.whl", hash = "sha256:b91ced227c41aa29c672814f50dbb05ec93536abf8f43cd14ec9521ea09afe4e"}, - {file = "pydantic_core-2.20.1-cp313-none-win_amd64.whl", hash = "sha256:65db0f2eefcaad1a3950f498aabb4875c8890438bc80b19362cf633b87a8ab20"}, - {file = "pydantic_core-2.20.1-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:4745f4ac52cc6686390c40eaa01d48b18997cb130833154801a442323cc78f91"}, - {file = "pydantic_core-2.20.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a8ad4c766d3f33ba8fd692f9aa297c9058970530a32c728a2c4bfd2616d3358b"}, - {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:41e81317dd6a0127cabce83c0c9c3fbecceae981c8391e6f1dec88a77c8a569a"}, - {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:04024d270cf63f586ad41fff13fde4311c4fc13ea74676962c876d9577bcc78f"}, - {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:eaad4ff2de1c3823fddf82f41121bdf453d922e9a238642b1dedb33c4e4f98ad"}, - {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:26ab812fa0c845df815e506be30337e2df27e88399b985d0bb4e3ecfe72df31c"}, - {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3c5ebac750d9d5f2706654c638c041635c385596caf68f81342011ddfa1e5598"}, - {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2aafc5a503855ea5885559eae883978c9b6d8c8993d67766ee73d82e841300dd"}, - {file = "pydantic_core-2.20.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:4868f6bd7c9d98904b748a2653031fc9c2f85b6237009d475b1008bfaeb0a5aa"}, - {file = "pydantic_core-2.20.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:aa2f457b4af386254372dfa78a2eda2563680d982422641a85f271c859df1987"}, - {file = "pydantic_core-2.20.1-cp38-none-win32.whl", hash = "sha256:225b67a1f6d602de0ce7f6c1c3ae89a4aa25d3de9be857999e9124f15dab486a"}, - {file = "pydantic_core-2.20.1-cp38-none-win_amd64.whl", hash = "sha256:6b507132dcfc0dea440cce23ee2182c0ce7aba7054576efc65634f080dbe9434"}, - {file = "pydantic_core-2.20.1-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:b03f7941783b4c4a26051846dea594628b38f6940a2fdc0df00b221aed39314c"}, - {file = "pydantic_core-2.20.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:1eedfeb6089ed3fad42e81a67755846ad4dcc14d73698c120a82e4ccf0f1f9f6"}, - {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:635fee4e041ab9c479e31edda27fcf966ea9614fff1317e280d99eb3e5ab6fe2"}, - {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:77bf3ac639c1ff567ae3b47f8d4cc3dc20f9966a2a6dd2311dcc055d3d04fb8a"}, - {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7ed1b0132f24beeec5a78b67d9388656d03e6a7c837394f99257e2d55b461611"}, - {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c6514f963b023aeee506678a1cf821fe31159b925c4b76fe2afa94cc70b3222b"}, - {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:10d4204d8ca33146e761c79f83cc861df20e7ae9f6487ca290a97702daf56006"}, - {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2d036c7187b9422ae5b262badb87a20a49eb6c5238b2004e96d4da1231badef1"}, - {file = "pydantic_core-2.20.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:9ebfef07dbe1d93efb94b4700f2d278494e9162565a54f124c404a5656d7ff09"}, - {file = "pydantic_core-2.20.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:6b9d9bb600328a1ce523ab4f454859e9d439150abb0906c5a1983c146580ebab"}, - {file = "pydantic_core-2.20.1-cp39-none-win32.whl", hash = "sha256:784c1214cb6dd1e3b15dd8b91b9a53852aed16671cc3fbe4786f4f1db07089e2"}, - {file = "pydantic_core-2.20.1-cp39-none-win_amd64.whl", hash = "sha256:d2fe69c5434391727efa54b47a1e7986bb0186e72a41b203df8f5b0a19a4f669"}, - {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:a45f84b09ac9c3d35dfcf6a27fd0634d30d183205230a0ebe8373a0e8cfa0906"}, - {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:d02a72df14dfdbaf228424573a07af10637bd490f0901cee872c4f434a735b94"}, - {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d2b27e6af28f07e2f195552b37d7d66b150adbaa39a6d327766ffd695799780f"}, - {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:084659fac3c83fd674596612aeff6041a18402f1e1bc19ca39e417d554468482"}, - {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:242b8feb3c493ab78be289c034a1f659e8826e2233786e36f2893a950a719bb6"}, - {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:38cf1c40a921d05c5edc61a785c0ddb4bed67827069f535d794ce6bcded919fc"}, - {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:e0bbdd76ce9aa5d4209d65f2b27fc6e5ef1312ae6c5333c26db3f5ade53a1e99"}, - {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:254ec27fdb5b1ee60684f91683be95e5133c994cc54e86a0b0963afa25c8f8a6"}, - {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:407653af5617f0757261ae249d3fba09504d7a71ab36ac057c938572d1bc9331"}, - {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:c693e916709c2465b02ca0ad7b387c4f8423d1db7b4649c551f27a529181c5ad"}, - {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5b5ff4911aea936a47d9376fd3ab17e970cc543d1b68921886e7f64bd28308d1"}, - {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:177f55a886d74f1808763976ac4efd29b7ed15c69f4d838bbd74d9d09cf6fa86"}, - {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:964faa8a861d2664f0c7ab0c181af0bea66098b1919439815ca8803ef136fc4e"}, - {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:4dd484681c15e6b9a977c785a345d3e378d72678fd5f1f3c0509608da24f2ac0"}, - {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:f6d6cff3538391e8486a431569b77921adfcdef14eb18fbf19b7c0a5294d4e6a"}, - {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:a6d511cc297ff0883bc3708b465ff82d7560193169a8b93260f74ecb0a5e08a7"}, - {file = "pydantic_core-2.20.1.tar.gz", hash = "sha256:26ca695eeee5f9f1aeeb211ffc12f10bcb6f71e2989988fda61dabd65db878d4"}, + {file = "pydantic_core-2.21.0-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:a97aa0a1f6c3f4e235fb2c9d12b92415faf8741c6a262d23a61fd26df7e30ff8"}, + {file = "pydantic_core-2.21.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d309202bbf9ff33e4e9e0ffd3ddcbf096e69bc81c7e68255612ca22cb1130a59"}, + {file = "pydantic_core-2.21.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e227183d791092b28815a435bd65f7105762473b3518d3a14ef8b663b99ce185"}, + {file = "pydantic_core-2.21.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f6ef7fd514588f8414ec033ead05ebde25a348971b0f0fd3bdc24c0276b87fd0"}, + {file = "pydantic_core-2.21.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fda3119daaa7c26ac08847c07ea96dc488bc61a34023b1050c2c20ba9493f778"}, + {file = "pydantic_core-2.21.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:07224088a793c38f8d4ef4a71889c9aaf568d250afe3ebac815b5d9578f48e41"}, + {file = "pydantic_core-2.21.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:334bd7b4ece531af9339f55d87c0bc9867f8dc71b0f9312f3f10402af9b0867e"}, + {file = "pydantic_core-2.21.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2d146b6cdd06de822e9cd6e9c255d46b7ff15b0fc312996fb7f1cd31329c3275"}, + {file = "pydantic_core-2.21.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:4dcd68eb7baf796822739273864a8d988a3e81d11b1e19db2ddfb83d495fe33b"}, + {file = "pydantic_core-2.21.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:6ead7f2f7c37dbe5264083e0b3a1ae84773402359d47b2bbcc1ce07867ef80d1"}, + {file = "pydantic_core-2.21.0-cp310-none-win32.whl", hash = "sha256:f4a8e22ab111391d694c7ac35f1db3f47bd58badf76d44478c2e5fbf1622a75b"}, + {file = "pydantic_core-2.21.0-cp310-none-win_amd64.whl", hash = "sha256:75e96800f42e06e72314346575ed561b76718b92115c79888a64513b817edd40"}, + {file = "pydantic_core-2.21.0-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:0c5d05c712ba7612bb3bdd7cdc3b306bbbe0c90c2bbe66a80c7c72ea751e6b62"}, + {file = "pydantic_core-2.21.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:21b97bb2fdf330c6fb03f43307671f0cb3051cbf89a58e1cd4c99a09c69c9341"}, + {file = "pydantic_core-2.21.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:986cad6e75c9d4e8f72d5085ee8109f75dc4d9d5095c994e00ce7f3787f7022b"}, + {file = "pydantic_core-2.21.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:400cbd6fdd92815eceac1812f8cc7501789da127fe35d7ff6d08d9de377a52b9"}, + {file = "pydantic_core-2.21.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:45fc6e4be497271834e3e263288a833b328669c27056df6af83ce379e61579d7"}, + {file = "pydantic_core-2.21.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f19f026a94202157c1b6db326cb09142c996adcd8e7f705b5c4f01815fef48a9"}, + {file = "pydantic_core-2.21.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:815e9cc5cf36522097556b9c968b529f528799bfe81a38d481ae8f5564b41d1b"}, + {file = "pydantic_core-2.21.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:fda0c0e6db4ce5f568619390e7055ea77d4572261d1815d597095542d71f2b1e"}, + {file = "pydantic_core-2.21.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:ba34c0b31e3829693310f83d3f7d917a9c8c6bccbf8ac1eb5f7759c52d368e36"}, + {file = "pydantic_core-2.21.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:ad512defbcb20c7e9a30b166ddcc61583568a6e13904b0d769b78df14de8ce43"}, + {file = "pydantic_core-2.21.0-cp311-none-win32.whl", hash = "sha256:0a1e19114c93ced62b691a44721488af04080658410d01cd895cb2afc16abb5b"}, + {file = "pydantic_core-2.21.0-cp311-none-win_amd64.whl", hash = "sha256:c95d11d9167e8bb2cafdd12858e9c51e92edd30813976eff637e4ab4555d742e"}, + {file = "pydantic_core-2.21.0-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:86b6f0a53daadf0c5a19733489c7987d278962b92411214f56bf52eb757cc9d7"}, + {file = "pydantic_core-2.21.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:c53d38dec60b0906a716f66f9ea70811a8b2ae9d6234d2108a57f8750b0c707f"}, + {file = "pydantic_core-2.21.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:639e0e7c9f5777b9b1c5f760d25cc615c40bef005af15c892324193fc18c8141"}, + {file = "pydantic_core-2.21.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2fe2e1cc87e8ddfc251e7f4100b30ca96700866b17d972ec842330cd10f9b379"}, + {file = "pydantic_core-2.21.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c5b839081226a4c4e3c96efe89fbb5004a9f1eebc039fcd4e26794cfe4412b5a"}, + {file = "pydantic_core-2.21.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e20b44a5dcb290bad3d02680d52a58c5b5938547d85bcb56b3412bfdb387a3a8"}, + {file = "pydantic_core-2.21.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5069840df8f808bca75956114844260481ea86e524364573d937e47c5013a982"}, + {file = "pydantic_core-2.21.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:130102233794bca08eaab7075711b637055e861c2ebb9e3c29ed117a3b035316"}, + {file = "pydantic_core-2.21.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:375008cd44acad0bbfa7e18819e8613bb638bcbad890c071d835c593ed0bd73f"}, + {file = "pydantic_core-2.21.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:5bcebd8b7e972d36ebc6b50f1f1fd9ff43eef53e60312dfa3ba809f1e33ec40f"}, + {file = "pydantic_core-2.21.0-cp312-none-win32.whl", hash = "sha256:7cb413eb75374e88a4989bc17c30f6eda6707bfeaad2272900e3dc5c08e91519"}, + {file = "pydantic_core-2.21.0-cp312-none-win_amd64.whl", hash = "sha256:3ab9a69b1beb04c7d263af049acca39c749753507bf811a639278b7aaf68ad79"}, + {file = "pydantic_core-2.21.0-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:0bf9815c7d5535b7d8c62248fa1536335c8186b9daa08056c5cb753e47b4435c"}, + {file = "pydantic_core-2.21.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:bf6b0cb6655970729ef3f35f54009cecfba6ba7cb8033bf3c56162b4bc418122"}, + {file = "pydantic_core-2.21.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:30085b96b9168451663ea9872cbf94922c5045158d243c404917a2ca9a1abe32"}, + {file = "pydantic_core-2.21.0-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e168240f12b187a1a214bf4867f9bab1a91cea3142e1cf361b7dddb7d08cc409"}, + {file = "pydantic_core-2.21.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e960a00230f1fca4ed34f5230e4db467eccc68f0777c565d9c3ce9aa6593f3e5"}, + {file = "pydantic_core-2.21.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:006a8210cd7134a7ae328433cb84a1076badbf5731c7876f96962ef8fd61d42d"}, + {file = "pydantic_core-2.21.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b0c40b8092c4679956aabff88454d618113529e40253b2a7df0a431e61ea2d84"}, + {file = "pydantic_core-2.21.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:72e74856b503cb434479cf7d21bb3dc140ed2d97e2be2ac452ec483d275f413b"}, + {file = "pydantic_core-2.21.0-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:dd5de610e64e77062877ee58a12f505fd4e1b092e61b3631f1677c267c7c6a8c"}, + {file = "pydantic_core-2.21.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:f2e6a46a6c9abd4f480fbced953936889380dec40e0a9f8aba32f45e1baae5f1"}, + {file = "pydantic_core-2.21.0-cp313-none-win32.whl", hash = "sha256:7c792fcb776d412d3ce2d71577ad729d627500998963bce88298b6a87b241ed8"}, + {file = "pydantic_core-2.21.0-cp313-none-win_amd64.whl", hash = "sha256:28317f20cdef82a41cdaa0f152be692c49fe0c22cc4ea55d73c0bd4624fcce14"}, + {file = "pydantic_core-2.21.0-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:ce1796df2f4c0a8605d30cd8b2726589ee404b34d8ecef93453e3c4366bea821"}, + {file = "pydantic_core-2.21.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:1e2134bf92b5a59223dfef4b50ee19fb76935299df0ab8aa0c99055ce7ae0d36"}, + {file = "pydantic_core-2.21.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1c0739fdbfcecb83fd8ef48863fdc82d108e647690d4948a88afa1dd307e175e"}, + {file = "pydantic_core-2.21.0-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:8a430bac8c43eb8a3e279cecab067ef2afbba6f28a8a6a0cf419c89588757436"}, + {file = "pydantic_core-2.21.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6a72b8b6e5350d74d13deecffdc393e768941fc3b61e6973e9c0ea26c33b3969"}, + {file = "pydantic_core-2.21.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c4114ca818afd13787312374df8740f026eaa0230bc87f81153eb6a20c3f39ad"}, + {file = "pydantic_core-2.21.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:07b5f813dd7c1520609ef764b3e9a80182456e4a003264eb473640f97afff985"}, + {file = "pydantic_core-2.21.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:a403beaa2651dc55df42def4d364f08705f5373ca3d44bbfa5ba6160767eb8fb"}, + {file = "pydantic_core-2.21.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:c95f17e63c5f811027bf768e027f247d49038c0ace817990417a0410894bfd67"}, + {file = "pydantic_core-2.21.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:23043d6944bd281f353896f7516edfaa8111e65bd80fd936dc1a8751dcc4e4cf"}, + {file = "pydantic_core-2.21.0-cp38-none-win32.whl", hash = "sha256:baefe94e313184f024f594ac35eabbc467c830b0fe7eb71c2fddc469414006e2"}, + {file = "pydantic_core-2.21.0-cp38-none-win_amd64.whl", hash = "sha256:c5a9cc3fd81cdd60ef203920794ccbe73630f82770e03e9446ee782454760235"}, + {file = "pydantic_core-2.21.0-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:4b68e752432f67403739bad3c94946d134ad7143840f54281d039bab21a1ca5e"}, + {file = "pydantic_core-2.21.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ab770f7506d579de7f51f15ce4994a53f3155347d51d87970f70038662ff70a9"}, + {file = "pydantic_core-2.21.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e9038a1b8c1ad42cf2be95a6fb1e2e3b66730e23ad0f677f2e9e2e5f02afbad3"}, + {file = "pydantic_core-2.21.0-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e2e7e7d1a08fbddd7cc8cea3a9cd23fc772b7b955056e5a3575808a4acbc20fa"}, + {file = "pydantic_core-2.21.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fa78fbd6a49b4a7481d700645f08fefb789e739fa6a46a3fa6a5fbbb2a83985c"}, + {file = "pydantic_core-2.21.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:90e3a7291073098b61a8331e13907132c5a8f1ffc69a576fc05aae1ffb1849a3"}, + {file = "pydantic_core-2.21.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:88fd993f5c19e5d63c9e441b9f3156d266fc16d02498abaf56a76761d8c74ec7"}, + {file = "pydantic_core-2.21.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:43e10ff6648ba9281c1389ee44953b8def12211afb3d3c169982df3dedcda79f"}, + {file = "pydantic_core-2.21.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:84f69f77893e691f4d2e77df0366494cf16bd5326ce5f045b654d7aef82eb1e7"}, + {file = "pydantic_core-2.21.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:4ce1ead9e4b628272c51e5b869cc78d0523a03a1fee9fbba474f48e1a436e553"}, + {file = "pydantic_core-2.21.0-cp39-none-win32.whl", hash = "sha256:0a06a47227b09ef094901ba3c8e069121965701aae1e9c6aa19cacbbba0b23af"}, + {file = "pydantic_core-2.21.0-cp39-none-win_amd64.whl", hash = "sha256:e281ec1c9dd7379f92b6f1da2e902c7d6fcc99b58ca58cd8de520ab189a184f7"}, + {file = "pydantic_core-2.21.0-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:88cf788e5a4a70014f1ce916a245fb8ffa939421a4e407f6eca962735813fd54"}, + {file = "pydantic_core-2.21.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:6f9e0b7c870298d6533579b7132e68d8e2c47ef35e2f5c79160389dfd527b3ac"}, + {file = "pydantic_core-2.21.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c1c622bfeab021f1c461ddb4097713d73122eec4bc6943b2800bb559df7f6fe1"}, + {file = "pydantic_core-2.21.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:356c73057d231f138d2638daa1dcc56e77e8d2e744fc7f04bfb5505389f08c7a"}, + {file = "pydantic_core-2.21.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:20a8d6e18e34ae34cfe26ce2c3cc866ee88b8623a4f1e93319501b3a68b57c44"}, + {file = "pydantic_core-2.21.0-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:97957c5484bdfe56b0a7ec8a623cd54f8872fb1f55090a2f52a3c065726d6bc6"}, + {file = "pydantic_core-2.21.0-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:ed1e082eecf51152fb9bdbbb14e574c72a78a592774617873522f6b3dee3e8ed"}, + {file = "pydantic_core-2.21.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:92e8b3bf64b210d51a5fc950be62dadecad5a8e329b34b8b2f690a505f6dafe3"}, + {file = "pydantic_core-2.21.0-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:6826218c59be7d2c9c306d5b7fa829b4ad4b2d96cb984c91f8ec82b91f63dc63"}, + {file = "pydantic_core-2.21.0-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:ab3391fb685026e6928b4d51cd044403ecefa7e7421a0f14887eb4708c3da7bb"}, + {file = "pydantic_core-2.21.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1b224bde36cafcc7f1d51e5c88cb784eb1a76f74701b5700dcc37dca66be745b"}, + {file = "pydantic_core-2.21.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b64bfc7b468cc524e9acfaf379333c1a4f771adf19d15ceae3b8f580ed9a0d4e"}, + {file = "pydantic_core-2.21.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:48991177fc0cf6cd9fd245433db167382c8c36bb18f64195532842ba5ba082fa"}, + {file = "pydantic_core-2.21.0-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:d9251ed0317455ccccd520600d4b6b07fd1486d53846bd82677f08a4999df949"}, + {file = "pydantic_core-2.21.0-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:4e6699cb02d3f063f6b35609830fc6d56aba1b4bcb6a82d604b5dd6b2156f87a"}, + {file = "pydantic_core-2.21.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:46be3c8c7e8346f2c02bf261b4dbff1d9e31001fb231ce9a1d52d7ef61d291fc"}, + {file = "pydantic_core-2.21.0.tar.gz", hash = "sha256:79c747f9916e5b6cb588dfd994d9ac15a93e43eb07467d9e6f24d892c176bbf5"}, ] [package.dependencies] @@ -765,81 +785,66 @@ pytest = ">=3.6.0,<9" [[package]] name = "pyyaml" -version = "6.0.1" +version = "6.0.2" description = "YAML parser and emitter for Python" optional = false -python-versions = ">=3.6" -files = [ - {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, - {file = "PyYAML-6.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f"}, - {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, - {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, - {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, - {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, - {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, - {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, - {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, - {file = "PyYAML-6.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f003ed9ad21d6a4713f0a9b5a7a0a79e08dd0f221aff4525a2be4c346ee60aab"}, - {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, - {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, - {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, - {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, - {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, - {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, - {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, - {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, - {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, - {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, - {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, - {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, - {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, - {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, - {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:afd7e57eddb1a54f0f1a974bc4391af8bcce0b444685d936840f125cf046d5bd"}, - {file = "PyYAML-6.0.1-cp36-cp36m-win32.whl", hash = "sha256:fca0e3a251908a499833aa292323f32437106001d436eca0e6e7833256674585"}, - {file = "PyYAML-6.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:f22ac1c3cac4dbc50079e965eba2c1058622631e526bd9afd45fedd49ba781fa"}, - {file = "PyYAML-6.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b1275ad35a5d18c62a7220633c913e1b42d44b46ee12554e5fd39c70a243d6a3"}, - {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:18aeb1bf9a78867dc38b259769503436b7c72f7a1f1f4c93ff9a17de54319b27"}, - {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:596106435fa6ad000c2991a98fa58eeb8656ef2325d7e158344fb33864ed87e3"}, - {file = "PyYAML-6.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:baa90d3f661d43131ca170712d903e6295d1f7a0f595074f151c0aed377c9b9c"}, - {file = "PyYAML-6.0.1-cp37-cp37m-win32.whl", hash = "sha256:9046c58c4395dff28dd494285c82ba00b546adfc7ef001486fbf0324bc174fba"}, - {file = "PyYAML-6.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:4fb147e7a67ef577a588a0e2c17b6db51dda102c71de36f8549b6816a96e1867"}, - {file = "PyYAML-6.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1d4c7e777c441b20e32f52bd377e0c409713e8bb1386e1099c2415f26e479595"}, - {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, - {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, - {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, - {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, - {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, - {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, - {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, - {file = "PyYAML-6.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c8098ddcc2a85b61647b2590f825f3db38891662cfc2fc776415143f599bb859"}, - {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, - {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, - {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, - {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, - {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, - {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, - {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, -] - -[[package]] -name = "rfc3986" -version = "1.5.0" -description = "Validating URI References per RFC 3986" -optional = false -python-versions = "*" +python-versions = ">=3.8" files = [ - {file = "rfc3986-1.5.0-py2.py3-none-any.whl", hash = "sha256:a86d6e1f5b1dc238b218b012df0aa79409667bb209e58da56d0b94704e712a97"}, - {file = "rfc3986-1.5.0.tar.gz", hash = "sha256:270aaf10d87d0d4e095063c65bf3ddbc6ee3d0b226328ce21e036f946e421835"}, + {file = "PyYAML-6.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0a9a2848a5b7feac301353437eb7d5957887edbf81d56e903999a75a3d743086"}, + {file = "PyYAML-6.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:29717114e51c84ddfba879543fb232a6ed60086602313ca38cce623c1d62cfbf"}, + {file = "PyYAML-6.0.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8824b5a04a04a047e72eea5cec3bc266db09e35de6bdfe34c9436ac5ee27d237"}, + {file = "PyYAML-6.0.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7c36280e6fb8385e520936c3cb3b8042851904eba0e58d277dca80a5cfed590b"}, + {file = "PyYAML-6.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ec031d5d2feb36d1d1a24380e4db6d43695f3748343d99434e6f5f9156aaa2ed"}, + {file = "PyYAML-6.0.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:936d68689298c36b53b29f23c6dbb74de12b4ac12ca6cfe0e047bedceea56180"}, + {file = "PyYAML-6.0.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:23502f431948090f597378482b4812b0caae32c22213aecf3b55325e049a6c68"}, + {file = "PyYAML-6.0.2-cp310-cp310-win32.whl", hash = "sha256:2e99c6826ffa974fe6e27cdb5ed0021786b03fc98e5ee3c5bfe1fd5015f42b99"}, + {file = "PyYAML-6.0.2-cp310-cp310-win_amd64.whl", hash = "sha256:a4d3091415f010369ae4ed1fc6b79def9416358877534caf6a0fdd2146c87a3e"}, + {file = "PyYAML-6.0.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:cc1c1159b3d456576af7a3e4d1ba7e6924cb39de8f67111c735f6fc832082774"}, + {file = "PyYAML-6.0.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:1e2120ef853f59c7419231f3bf4e7021f1b936f6ebd222406c3b60212205d2ee"}, + {file = "PyYAML-6.0.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5d225db5a45f21e78dd9358e58a98702a0302f2659a3c6cd320564b75b86f47c"}, + {file = "PyYAML-6.0.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5ac9328ec4831237bec75defaf839f7d4564be1e6b25ac710bd1a96321cc8317"}, + {file = "PyYAML-6.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3ad2a3decf9aaba3d29c8f537ac4b243e36bef957511b4766cb0057d32b0be85"}, + {file = "PyYAML-6.0.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:ff3824dc5261f50c9b0dfb3be22b4567a6f938ccce4587b38952d85fd9e9afe4"}, + {file = "PyYAML-6.0.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:797b4f722ffa07cc8d62053e4cff1486fa6dc094105d13fea7b1de7d8bf71c9e"}, + {file = "PyYAML-6.0.2-cp311-cp311-win32.whl", hash = "sha256:11d8f3dd2b9c1207dcaf2ee0bbbfd5991f571186ec9cc78427ba5bd32afae4b5"}, + {file = "PyYAML-6.0.2-cp311-cp311-win_amd64.whl", hash = "sha256:e10ce637b18caea04431ce14fabcf5c64a1c61ec9c56b071a4b7ca131ca52d44"}, + {file = "PyYAML-6.0.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:c70c95198c015b85feafc136515252a261a84561b7b1d51e3384e0655ddf25ab"}, + {file = "PyYAML-6.0.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ce826d6ef20b1bc864f0a68340c8b3287705cae2f8b4b1d932177dcc76721725"}, + {file = "PyYAML-6.0.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1f71ea527786de97d1a0cc0eacd1defc0985dcf6b3f17bb77dcfc8c34bec4dc5"}, + {file = "PyYAML-6.0.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9b22676e8097e9e22e36d6b7bda33190d0d400f345f23d4065d48f4ca7ae0425"}, + {file = "PyYAML-6.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:80bab7bfc629882493af4aa31a4cfa43a4c57c83813253626916b8c7ada83476"}, + {file = "PyYAML-6.0.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:0833f8694549e586547b576dcfaba4a6b55b9e96098b36cdc7ebefe667dfed48"}, + {file = "PyYAML-6.0.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8b9c7197f7cb2738065c481a0461e50ad02f18c78cd75775628afb4d7137fb3b"}, + {file = "PyYAML-6.0.2-cp312-cp312-win32.whl", hash = "sha256:ef6107725bd54b262d6dedcc2af448a266975032bc85ef0172c5f059da6325b4"}, + {file = "PyYAML-6.0.2-cp312-cp312-win_amd64.whl", hash = "sha256:7e7401d0de89a9a855c839bc697c079a4af81cf878373abd7dc625847d25cbd8"}, + {file = "PyYAML-6.0.2-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:efdca5630322a10774e8e98e1af481aad470dd62c3170801852d752aa7a783ba"}, + {file = "PyYAML-6.0.2-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:50187695423ffe49e2deacb8cd10510bc361faac997de9efef88badc3bb9e2d1"}, + {file = "PyYAML-6.0.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0ffe8360bab4910ef1b9e87fb812d8bc0a308b0d0eef8c8f44e0254ab3b07133"}, + {file = "PyYAML-6.0.2-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:17e311b6c678207928d649faa7cb0d7b4c26a0ba73d41e99c4fff6b6c3276484"}, + {file = "PyYAML-6.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:70b189594dbe54f75ab3a1acec5f1e3faa7e8cf2f1e08d9b561cb41b845f69d5"}, + {file = "PyYAML-6.0.2-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:41e4e3953a79407c794916fa277a82531dd93aad34e29c2a514c2c0c5fe971cc"}, + {file = "PyYAML-6.0.2-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:68ccc6023a3400877818152ad9a1033e3db8625d899c72eacb5a668902e4d652"}, + {file = "PyYAML-6.0.2-cp313-cp313-win32.whl", hash = "sha256:bc2fa7c6b47d6bc618dd7fb02ef6fdedb1090ec036abab80d4681424b84c1183"}, + {file = "PyYAML-6.0.2-cp313-cp313-win_amd64.whl", hash = "sha256:8388ee1976c416731879ac16da0aff3f63b286ffdd57cdeb95f3f2e085687563"}, + {file = "PyYAML-6.0.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:24471b829b3bf607e04e88d79542a9d48bb037c2267d7927a874e6c205ca7e9a"}, + {file = "PyYAML-6.0.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d7fded462629cfa4b685c5416b949ebad6cec74af5e2d42905d41e257e0869f5"}, + {file = "PyYAML-6.0.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d84a1718ee396f54f3a086ea0a66d8e552b2ab2017ef8b420e92edbc841c352d"}, + {file = "PyYAML-6.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9056c1ecd25795207ad294bcf39f2db3d845767be0ea6e6a34d856f006006083"}, + {file = "PyYAML-6.0.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:82d09873e40955485746739bcb8b4586983670466c23382c19cffecbf1fd8706"}, + {file = "PyYAML-6.0.2-cp38-cp38-win32.whl", hash = "sha256:43fa96a3ca0d6b1812e01ced1044a003533c47f6ee8aca31724f78e93ccc089a"}, + {file = "PyYAML-6.0.2-cp38-cp38-win_amd64.whl", hash = "sha256:01179a4a8559ab5de078078f37e5c1a30d76bb88519906844fd7bdea1b7729ff"}, + {file = "PyYAML-6.0.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:688ba32a1cffef67fd2e9398a2efebaea461578b0923624778664cc1c914db5d"}, + {file = "PyYAML-6.0.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a8786accb172bd8afb8be14490a16625cbc387036876ab6ba70912730faf8e1f"}, + {file = "PyYAML-6.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d8e03406cac8513435335dbab54c0d385e4a49e4945d2909a581c83647ca0290"}, + {file = "PyYAML-6.0.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f753120cb8181e736c57ef7636e83f31b9c0d1722c516f7e86cf15b7aa57ff12"}, + {file = "PyYAML-6.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3b1fdb9dc17f5a7677423d508ab4f243a726dea51fa5e70992e59a7411c89d19"}, + {file = "PyYAML-6.0.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:0b69e4ce7a131fe56b7e4d770c67429700908fc0752af059838b1cfb41960e4e"}, + {file = "PyYAML-6.0.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:a9f8c2e67970f13b16084e04f134610fd1d374bf477b17ec1599185cf611d725"}, + {file = "PyYAML-6.0.2-cp39-cp39-win32.whl", hash = "sha256:6395c297d42274772abc367baaa79683958044e5d3835486c16da75d2a694631"}, + {file = "PyYAML-6.0.2-cp39-cp39-win_amd64.whl", hash = "sha256:39693e1f8320ae4f43943590b49779ffb98acb81f788220ea932a6b6c51004d8"}, + {file = "pyyaml-6.0.2.tar.gz", hash = "sha256:d584d9ec91ad65861cc08d42e834324ef890a082e591037abe114850ff7bbc3e"}, ] -[package.dependencies] -idna = {version = "*", optional = true, markers = "extra == \"idna2008\""} - -[package.extras] -idna2008 = ["idna"] - [[package]] name = "rich" version = "12.6.0" @@ -860,29 +865,29 @@ jupyter = ["ipywidgets (>=7.5.1,<8.0.0)"] [[package]] name = "ruff" -version = "0.5.6" +version = "0.5.7" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.5.6-py3-none-linux_armv6l.whl", hash = "sha256:a0ef5930799a05522985b9cec8290b185952f3fcd86c1772c3bdbd732667fdcd"}, - {file = "ruff-0.5.6-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:b652dc14f6ef5d1552821e006f747802cc32d98d5509349e168f6bf0ee9f8f42"}, - {file = "ruff-0.5.6-py3-none-macosx_11_0_arm64.whl", hash = "sha256:80521b88d26a45e871f31e4b88938fd87db7011bb961d8afd2664982dfc3641a"}, - {file = "ruff-0.5.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d9bc8f328a9f1309ae80e4d392836e7dbc77303b38ed4a7112699e63d3b066ab"}, - {file = "ruff-0.5.6-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4d394940f61f7720ad371ddedf14722ee1d6250fd8d020f5ea5a86e7be217daf"}, - {file = "ruff-0.5.6-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:111a99cdb02f69ddb2571e2756e017a1496c2c3a2aeefe7b988ddab38b416d36"}, - {file = "ruff-0.5.6-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:e395daba77a79f6dc0d07311f94cc0560375ca20c06f354c7c99af3bf4560c5d"}, - {file = "ruff-0.5.6-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c476acb43c3c51e3c614a2e878ee1589655fa02dab19fe2db0423a06d6a5b1b6"}, - {file = "ruff-0.5.6-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e2ff8003f5252fd68425fd53d27c1f08b201d7ed714bb31a55c9ac1d4c13e2eb"}, - {file = "ruff-0.5.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c94e084ba3eaa80c2172918c2ca2eb2230c3f15925f4ed8b6297260c6ef179ad"}, - {file = "ruff-0.5.6-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:1f77c1c3aa0669fb230b06fb24ffa3e879391a3ba3f15e3d633a752da5a3e670"}, - {file = "ruff-0.5.6-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:f908148c93c02873210a52cad75a6eda856b2cbb72250370ce3afef6fb99b1ed"}, - {file = "ruff-0.5.6-py3-none-musllinux_1_2_i686.whl", hash = "sha256:563a7ae61ad284187d3071d9041c08019975693ff655438d8d4be26e492760bd"}, - {file = "ruff-0.5.6-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:94fe60869bfbf0521e04fd62b74cbca21cbc5beb67cbb75ab33fe8c174f54414"}, - {file = "ruff-0.5.6-py3-none-win32.whl", hash = "sha256:e6a584c1de6f8591c2570e171cc7ce482bb983d49c70ddf014393cd39e9dfaed"}, - {file = "ruff-0.5.6-py3-none-win_amd64.whl", hash = "sha256:d7fe7dccb1a89dc66785d7aa0ac283b2269712d8ed19c63af908fdccca5ccc1a"}, - {file = "ruff-0.5.6-py3-none-win_arm64.whl", hash = "sha256:57c6c0dd997b31b536bff49b9eee5ed3194d60605a4427f735eeb1f9c1b8d264"}, - {file = "ruff-0.5.6.tar.gz", hash = "sha256:07c9e3c2a8e1fe377dd460371c3462671a728c981c3205a5217291422209f642"}, + {file = "ruff-0.5.7-py3-none-linux_armv6l.whl", hash = "sha256:548992d342fc404ee2e15a242cdbea4f8e39a52f2e7752d0e4cbe88d2d2f416a"}, + {file = "ruff-0.5.7-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:00cc8872331055ee017c4f1071a8a31ca0809ccc0657da1d154a1d2abac5c0be"}, + {file = "ruff-0.5.7-py3-none-macosx_11_0_arm64.whl", hash = "sha256:eaf3d86a1fdac1aec8a3417a63587d93f906c678bb9ed0b796da7b59c1114a1e"}, + {file = "ruff-0.5.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a01c34400097b06cf8a6e61b35d6d456d5bd1ae6961542de18ec81eaf33b4cb8"}, + {file = "ruff-0.5.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:fcc8054f1a717e2213500edaddcf1dbb0abad40d98e1bd9d0ad364f75c763eea"}, + {file = "ruff-0.5.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7f70284e73f36558ef51602254451e50dd6cc479f8b6f8413a95fcb5db4a55fc"}, + {file = "ruff-0.5.7-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:a78ad870ae3c460394fc95437d43deb5c04b5c29297815a2a1de028903f19692"}, + {file = "ruff-0.5.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9ccd078c66a8e419475174bfe60a69adb36ce04f8d4e91b006f1329d5cd44bcf"}, + {file = "ruff-0.5.7-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7e31c9bad4ebf8fdb77b59cae75814440731060a09a0e0077d559a556453acbb"}, + {file = "ruff-0.5.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8d796327eed8e168164346b769dd9a27a70e0298d667b4ecee6877ce8095ec8e"}, + {file = "ruff-0.5.7-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:4a09ea2c3f7778cc635e7f6edf57d566a8ee8f485f3c4454db7771efb692c499"}, + {file = "ruff-0.5.7-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:a36d8dcf55b3a3bc353270d544fb170d75d2dff41eba5df57b4e0b67a95bb64e"}, + {file = "ruff-0.5.7-py3-none-musllinux_1_2_i686.whl", hash = "sha256:9369c218f789eefbd1b8d82a8cf25017b523ac47d96b2f531eba73770971c9e5"}, + {file = "ruff-0.5.7-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:b88ca3db7eb377eb24fb7c82840546fb7acef75af4a74bd36e9ceb37a890257e"}, + {file = "ruff-0.5.7-py3-none-win32.whl", hash = "sha256:33d61fc0e902198a3e55719f4be6b375b28f860b09c281e4bdbf783c0566576a"}, + {file = "ruff-0.5.7-py3-none-win_amd64.whl", hash = "sha256:083bbcbe6fadb93cd86709037acc510f86eed5a314203079df174c40bbbca6b3"}, + {file = "ruff-0.5.7-py3-none-win_arm64.whl", hash = "sha256:2dca26154ff9571995107221d0aeaad0e75a77b5a682d6236cf89a58c70b76f4"}, + {file = "ruff-0.5.7.tar.gz", hash = "sha256:8dfc0a458797f5d9fb622dd0efc52d796f23f0a1493a9527f4e49a550ae9a7e5"}, ] [[package]] @@ -1067,4 +1072,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "481db7c435ac15886c0e4b5afbf7ea276b7ebd24f30cbb48090fc2a33542852b" +content-hash = "b0fc887ff0c75d88165dd1fe5c5d61aa0dd863fa95ce8bafa5e1424e2fa6e6c1" diff --git a/generators/python/pyproject.toml b/generators/python/pyproject.toml index 76bcad6ad33..2ee74fc01a6 100644 --- a/generators/python/pyproject.toml +++ b/generators/python/pyproject.toml @@ -6,7 +6,7 @@ authors = [] [tool.poetry.dependencies] python = "^3.9" -pydantic = "^2.8.2" +pydantic = "1.10.15" typer = {extras = ["all"], version = "^0.6.1"} fern-fern-generator-exec-sdk = {version = "0.82.5", source = "fern-prod"} ordered-set = "^4.1.0" diff --git a/generators/python/tests/utils/test_union_utils.py b/generators/python/tests/utils/test_union_utils.py index 1c83907f884..3bc23a5a278 100644 --- a/generators/python/tests/utils/test_union_utils.py +++ b/generators/python/tests/utils/test_union_utils.py @@ -1,3 +1,4 @@ +import json from .union_utils.types.resources.types.shape import Shape @@ -11,4 +12,8 @@ def test_union_utils() -> None: square=lambda _: False ) - assert is_circle \ No newline at end of file + assert is_circle + assert circle.dict() == json.loads(dummy) + assert circle.json() == dummy + + print(circle.dict(), circle.json()) \ No newline at end of file diff --git a/generators/python/tests/utils/test_unset.py b/generators/python/tests/utils/test_unset.py new file mode 100644 index 00000000000..f8fe991a18d --- /dev/null +++ b/generators/python/tests/utils/test_unset.py @@ -0,0 +1,14 @@ +from typing import Optional +from .union_utils.types.core.pydantic_utilities import UniversalBaseModel + + +class SomeObject(UniversalBaseModel): + name: str + age: int + city: str = "NY" + optional: Optional[str] = None + +def test_unset() -> None: + so = SomeObject(name="John", age=30) + assert so.dict() == {"name": "John", "age": 30, "city": "NY"} + assert so.dict(exclude_unset=True) == {"name": "John", "age": 30, "city": "NY"} diff --git a/generators/python/tests/utils/union_utils/2.0 b/generators/python/tests/utils/union_utils/2.0 new file mode 100644 index 00000000000..158cb0a84bb --- /dev/null +++ b/generators/python/tests/utils/union_utils/2.0 @@ -0,0 +1,8 @@ +The following packages are already present in the pyproject.toml and will be skipped: + + - pydantic + +If you want to update it to the latest compatible version, you can use `poetry update package`. +If you prefer to upgrade it to the latest available version, you can use `poetry add package@latest`. + +Nothing to add. diff --git a/generators/python/tests/utils/union_utils/fern/generators.yml b/generators/python/tests/utils/union_utils/fern/generators.yml index 970fa0af75c..37ff3db6aee 100644 --- a/generators/python/tests/utils/union_utils/fern/generators.yml +++ b/generators/python/tests/utils/union_utils/fern/generators.yml @@ -12,3 +12,5 @@ groups: skip_validation: true use_provided_defaults: true include_union_utils: true + wrapped_aliases: true + version: v1 diff --git a/generators/python/tests/utils/union_utils/types/__init__.py b/generators/python/tests/utils/union_utils/types/__init__.py index a9d867fbade..7662fb533f2 100644 --- a/generators/python/tests/utils/union_utils/types/__init__.py +++ b/generators/python/tests/utils/union_utils/types/__init__.py @@ -1,5 +1,13 @@ # This file was auto-generated by Fern from our API Definition. -from .resources import Circle, Color, Shape, Square, UndiscriminatedShape, types +from .resources import Circle, Color, Name, Shape, Square, UndiscriminatedShape, types -__all__ = ["Circle", "Color", "Shape", "Square", "UndiscriminatedShape", "types"] +__all__ = [ + "Circle", + "Color", + "Name", + "Shape", + "Square", + "UndiscriminatedShape", + "types", +] diff --git a/generators/python/tests/utils/union_utils/types/core/pydantic_utilities.py b/generators/python/tests/utils/union_utils/types/core/pydantic_utilities.py index bdf65d5331b..b6dc264ae70 100644 --- a/generators/python/tests/utils/union_utils/types/core/pydantic_utilities.py +++ b/generators/python/tests/utils/union_utils/types/core/pydantic_utilities.py @@ -2,8 +2,10 @@ # nopycln: file import datetime as dt +from tkinter import E import typing from collections import defaultdict + import typing_extensions import pydantic @@ -105,27 +107,29 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -187,3 +191,27 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/generators/python/tests/utils/union_utils/types/resources/__init__.py b/generators/python/tests/utils/union_utils/types/resources/__init__.py index 1b80ffa3927..3dbedd06283 100644 --- a/generators/python/tests/utils/union_utils/types/resources/__init__.py +++ b/generators/python/tests/utils/union_utils/types/resources/__init__.py @@ -1,6 +1,14 @@ # This file was auto-generated by Fern from our API Definition. from . import types -from .types import Circle, Color, Shape, Square, UndiscriminatedShape +from .types import Circle, Color, Name, Shape, Square, UndiscriminatedShape -__all__ = ["Circle", "Color", "Shape", "Square", "UndiscriminatedShape", "types"] +__all__ = [ + "Circle", + "Color", + "Name", + "Shape", + "Square", + "UndiscriminatedShape", + "types", +] diff --git a/generators/python/tests/utils/union_utils/types/resources/types/__init__.py b/generators/python/tests/utils/union_utils/types/resources/types/__init__.py index 926e6224242..be22ee1e74d 100644 --- a/generators/python/tests/utils/union_utils/types/resources/types/__init__.py +++ b/generators/python/tests/utils/union_utils/types/resources/types/__init__.py @@ -2,8 +2,9 @@ from .circle import Circle from .color import Color +from .name import Name from .shape import Shape from .square import Square from .undiscriminated_shape import UndiscriminatedShape -__all__ = ["Circle", "Color", "Shape", "Square", "UndiscriminatedShape"] +__all__ = ["Circle", "Color", "Name", "Shape", "Square", "UndiscriminatedShape"] diff --git a/generators/python/tests/utils/union_utils/types/resources/types/name.py b/generators/python/tests/utils/union_utils/types/resources/types/name.py new file mode 100644 index 00000000000..fe2f7f8b0a7 --- /dev/null +++ b/generators/python/tests/utils/union_utils/types/resources/types/name.py @@ -0,0 +1,27 @@ +# This file was auto-generated by Fern from our API Definition. + +from __future__ import annotations +from ...core.unchecked_base_model import UncheckedBaseModel +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing +import pydantic + + +class Name(UncheckedBaseModel): + __root__: str + + def get_as_str(self) -> str: + return self.__root__ + + @staticmethod + def from_str(value: str) -> Name: + return Name(__root__=value) + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow" + ) # type: ignore # Pydantic v2 + else: + + class Config: + extra = pydantic.Extra.allow From b1864da5b1921cb719f157ede1fa7d3984e08dc8 Mon Sep 17 00:00:00 2001 From: armandobelardo Date: Wed, 14 Aug 2024 06:29:58 -0400 Subject: [PATCH 2/7] update seed --- .../python/core_utilities/fastapi/__init__.py | 2 - .../fastapi/pydantic_utilities.py | 35 +-- .../pydantic/pydantic_utilities.py | 35 +-- .../core_utilities/sdk/pydantic_utilities.py | 35 +-- generators/python/poetry.lock | 247 ++++++++---------- generators/python/pyproject.toml | 2 +- .../core_utilities/core_utilities.py | 10 - .../fastapi/core_utilities/core_utilities.py | 1 - .../sdk/core_utilities/core_utilities.py | 10 - .../example_models/types/core/__init__.py | 2 - .../types/core/datetime_utils.py | 4 +- .../types/core/pydantic_utilities.py | 137 ++++++---- .../types/core/serialization.py | 28 +- .../types/core/unchecked_base_model.py | 60 +++-- .../types/resources/types/circle.py | 10 +- .../resources/types/object_with_defaults.py | 10 +- .../types/object_with_optional_field.py | 24 +- .../types/resources/types/shape.py | 24 +- .../types/resources/types/square.py | 10 +- .../resources/types/undiscriminated_shape.py | 1 - generators/python/tests/utils/test_unset.py | 5 + .../typeddict_models/types/core/__init__.py | 2 - .../types/core/datetime_utils.py | 4 +- .../types/core/pydantic_utilities.py | 137 ++++++---- .../types/core/serialization.py | 28 +- .../types/core/unchecked_base_model.py | 60 +++-- .../types/resources/types/circle.py | 10 +- .../resources/types/object_with_defaults.py | 10 +- .../types/object_with_optional_field.py | 24 +- .../types/resources/types/requests/circle.py | 6 +- .../types/requests/object_with_defaults.py | 1 + .../requests/object_with_optional_field.py | 37 ++- .../types/resources/types/requests/shape.py | 22 +- .../types/resources/types/requests/square.py | 6 +- .../types/requests/undiscriminated_shape.py | 1 - .../types/resources/types/shape.py | 32 ++- .../types/resources/types/square.py | 10 +- .../resources/types/undiscriminated_shape.py | 1 - generators/python/tests/utils/union_utils/2.0 | 8 - .../utils/union_utils/fern/generators.yml | 2 - .../tests/utils/union_utils/types/__init__.py | 12 +- .../utils/union_utils/types/core/__init__.py | 2 - .../types/core/pydantic_utilities.py | 27 +- .../union_utils/types/resources/__init__.py | 12 +- .../types/resources/types/__init__.py | 3 +- .../union_utils/types/resources/types/name.py | 27 -- seed/fastapi/alias-extends/core/__init__.py | 2 - .../alias-extends/core/pydantic_utilities.py | 74 ++++-- seed/fastapi/alias/core/__init__.py | 2 - seed/fastapi/alias/core/pydantic_utilities.py | 74 ++++-- .../api-wide-base-path/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- seed/fastapi/audiences/core/__init__.py | 2 - .../audiences/core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- seed/fastapi/basic-auth/core/__init__.py | 2 - .../basic-auth/core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../circular-references/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- seed/fastapi/code-samples/core/__init__.py | 2 - .../code-samples/core/pydantic_utilities.py | 74 ++++-- seed/fastapi/custom-auth/core/__init__.py | 2 - .../custom-auth/core/pydantic_utilities.py | 74 ++++-- seed/fastapi/error-property/core/__init__.py | 2 - .../error-property/core/pydantic_utilities.py | 74 ++++-- seed/fastapi/examples/core/__init__.py | 2 - .../examples/core/pydantic_utilities.py | 74 ++++-- .../include-validators/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../no-custom-config/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../exhaustive/pydantic-v1/core/__init__.py | 2 - .../pydantic-v1/core/pydantic_utilities.py | 74 ++++-- .../exhaustive/pydantic-v2/core/__init__.py | 2 - .../pydantic-v2/core/pydantic_utilities.py | 74 ++++-- .../skip-formatting/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- seed/fastapi/extends/core/__init__.py | 2 - .../extends/core/pydantic_utilities.py | 74 ++++-- .../fastapi/extra-properties/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- seed/fastapi/folders/core/__init__.py | 2 - .../folders/core/pydantic_utilities.py | 74 ++++-- seed/fastapi/grpc-proto/core/__init__.py | 2 - .../grpc-proto/core/pydantic_utilities.py | 74 ++++-- seed/fastapi/grpc/core/__init__.py | 2 - seed/fastapi/grpc/core/pydantic_utilities.py | 74 ++++-- .../idempotency-headers/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../imdb/async-handlers/core/__init__.py | 2 - .../async-handlers/core/pydantic_utilities.py | 74 ++++-- .../includes-extra-fields/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../imdb/no-custom-config/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- seed/fastapi/mixed-case/core/__init__.py | 2 - .../mixed-case/core/pydantic_utilities.py | 74 ++++-- seed/fastapi/multi-line-docs/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../multi-url-environment/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- seed/fastapi/no-environment/core/__init__.py | 2 - .../no-environment/core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../oauth-client-credentials/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- seed/fastapi/object/core/__init__.py | 2 - .../fastapi/object/core/pydantic_utilities.py | 74 ++++-- .../objects-with-imports/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- seed/fastapi/optional/core/__init__.py | 2 - .../optional/core/pydantic_utilities.py | 74 ++++-- seed/fastapi/package-yml/core/__init__.py | 2 - .../package-yml/core/pydantic_utilities.py | 74 ++++-- seed/fastapi/pagination/core/__init__.py | 2 - .../pagination/core/pydantic_utilities.py | 74 ++++-- seed/fastapi/plain-text/core/__init__.py | 2 - .../plain-text/core/pydantic_utilities.py | 74 ++++-- .../reserved-keywords/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- seed/fastapi/simple-fhir/core/__init__.py | 2 - .../simple-fhir/core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- seed/fastapi/trace/core/__init__.py | 2 - seed/fastapi/trace/core/pydantic_utilities.py | 74 ++++-- .../undiscriminated-unions/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- seed/fastapi/unions/core/__init__.py | 2 - .../fastapi/unions/core/pydantic_utilities.py | 74 ++++-- seed/fastapi/unknown/core/__init__.py | 2 - .../unknown/core/pydantic_utilities.py | 74 ++++-- seed/fastapi/validation/core/__init__.py | 2 - .../validation/core/pydantic_utilities.py | 74 ++++-- seed/fastapi/variables/core/__init__.py | 2 - .../variables/core/pydantic_utilities.py | 74 ++++-- .../version-no-default/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- seed/fastapi/version/core/__init__.py | 2 - .../version/core/pydantic_utilities.py | 74 ++++-- seed/fastapi/websocket/core/__init__.py | 2 - .../websocket/core/pydantic_utilities.py | 74 ++++-- .../src/seed/alias_extends/core/__init__.py | 2 - .../alias_extends/core/pydantic_utilities.py | 74 ++++-- .../alias/src/seed/alias/core/__init__.py | 2 - .../src/seed/alias/core/pydantic_utilities.py | 74 ++++-- .../seed/api_wide_base_path/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../src/seed/audiences/core/__init__.py | 2 - .../seed/audiences/core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../src/seed/basic_auth/core/__init__.py | 2 - .../basic_auth/core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../bytes/src/seed/bytes/core/__init__.py | 2 - .../src/seed/bytes/core/pydantic_utilities.py | 74 ++++-- .../src/seed/api/core/__init__.py | 2 - .../src/seed/api/core/pydantic_utilities.py | 74 ++++-- .../src/seed/api/core/__init__.py | 2 - .../src/seed/api/core/pydantic_utilities.py | 74 ++++-- .../src/seed/code_samples/core/__init__.py | 2 - .../code_samples/core/pydantic_utilities.py | 74 ++++-- .../src/seed/custom_auth/core/__init__.py | 2 - .../custom_auth/core/pydantic_utilities.py | 74 ++++-- .../enum/src/seed/enum/core/__init__.py | 2 - .../src/seed/enum/core/pydantic_utilities.py | 74 ++++-- .../src/seed/error_property/core/__init__.py | 2 - .../error_property/core/pydantic_utilities.py | 74 ++++-- .../src/seed/examples/core/__init__.py | 2 - .../seed/examples/core/pydantic_utilities.py | 74 ++++-- .../src/seed/exhaustive/core/__init__.py | 2 - .../exhaustive/core/pydantic_utilities.py | 74 ++++-- .../src/seed/exhaustive/core/__init__.py | 2 - .../exhaustive/core/pydantic_utilities.py | 74 ++++-- .../extends/src/seed/extends/core/__init__.py | 2 - .../seed/extends/core/pydantic_utilities.py | 74 ++++-- .../seed/extra_properties/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../src/seed/file_download/core/__init__.py | 2 - .../file_download/core/pydantic_utilities.py | 74 ++++-- .../src/seed/file_upload/core/__init__.py | 2 - .../file_upload/core/pydantic_utilities.py | 74 ++++-- .../folders/src/seed/api/core/__init__.py | 2 - .../src/seed/api/core/pydantic_utilities.py | 74 ++++-- .../grpc-proto/src/seed/api/core/__init__.py | 2 - .../src/seed/api/core/pydantic_utilities.py | 74 ++++-- .../grpc/src/seed/api/core/__init__.py | 2 - .../src/seed/api/core/pydantic_utilities.py | 74 ++++-- .../seed/idempotency_headers/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../imdb/src/seed/api/core/__init__.py | 2 - .../src/seed/api/core/pydantic_utilities.py | 74 ++++-- .../literal/src/seed/literal/core/__init__.py | 2 - .../seed/literal/core/pydantic_utilities.py | 74 ++++-- .../src/seed/mixed_case/core/__init__.py | 2 - .../mixed_case/core/pydantic_utilities.py | 74 ++++-- .../src/seed/multi_line_docs/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../multi_url_environment/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../src/seed/no_environment/core/__init__.py | 2 - .../no_environment/core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../oauth_client_credentials/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../oauth_client_credentials/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../object/src/seed/object/core/__init__.py | 2 - .../seed/object/core/pydantic_utilities.py | 74 ++++-- .../objects_with_imports/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../objects_with_imports/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../src/seed/package_yml/core/__init__.py | 2 - .../package_yml/core/pydantic_utilities.py | 74 ++++-- .../src/seed/pagination/core/__init__.py | 2 - .../pagination/core/pydantic_utilities.py | 74 ++++-- .../src/seed/plain_text/core/__init__.py | 2 - .../plain_text/core/pydantic_utilities.py | 74 ++++-- .../seed/query_parameters/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../src/seed/nursery_api/core/__init__.py | 2 - .../nursery_api/core/pydantic_utilities.py | 74 ++++-- .../seed/response_property/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../simple-fhir/src/seed/api/core/__init__.py | 2 - .../src/seed/api/core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../src/seed/streaming/core/__init__.py | 2 - .../seed/streaming/core/pydantic_utilities.py | 74 ++++-- .../src/seed/streaming/core/__init__.py | 2 - .../seed/streaming/core/pydantic_utilities.py | 74 ++++-- .../trace/src/seed/trace/core/__init__.py | 2 - .../src/seed/trace/core/pydantic_utilities.py | 74 ++++-- .../undiscriminated_unions/core/__init__.py | 2 - .../core/pydantic_utilities.py | 74 ++++-- .../unions/src/seed/unions/core/__init__.py | 2 - .../seed/unions/core/pydantic_utilities.py | 74 ++++-- .../src/seed/unknown_as_any/core/__init__.py | 2 - .../unknown_as_any/core/pydantic_utilities.py | 74 ++++-- .../src/seed/validation/core/__init__.py | 2 - .../validation/core/pydantic_utilities.py | 74 ++++-- .../src/seed/variables/core/__init__.py | 2 - .../seed/variables/core/pydantic_utilities.py | 74 ++++-- .../src/seed/version/core/__init__.py | 2 - .../seed/version/core/pydantic_utilities.py | 74 ++++-- .../version/src/seed/version/core/__init__.py | 2 - .../seed/version/core/pydantic_utilities.py | 74 ++++-- .../src/seed/websocket/core/__init__.py | 2 - .../seed/websocket/core/pydantic_utilities.py | 74 ++++-- .../alias-extends/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../alias/src/seed/core/__init__.py | 2 - .../alias/src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../audiences/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../basic-auth/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../bytes/src/seed/core/__init__.py | 2 - .../bytes/src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../code-samples/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../custom-auth/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../enum/real-enum/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../enum/strenum/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../error-property/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../client-filename/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../examples/readme/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../pydantic-v1/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../union-utils/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../extends/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../file-download/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../file-upload/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../folders/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../grpc-proto/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../python-sdk/grpc/src/seed/core/__init__.py | 2 - .../grpc/src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../python-sdk/imdb/src/seed/core/__init__.py | 2 - .../imdb/src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../mixed-case/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../multi-line-docs/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../no-environment/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../object/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../optional/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../package-yml/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../pagination/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../plain-text/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../simple-fhir/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../trace/src/seed/core/__init__.py | 2 - .../trace/src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../union-naming-v1/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../union-utils/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../unknown/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../with-defaults/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../variables/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../version/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- .../websocket/src/seed/core/__init__.py | 2 - .../src/seed/core/pydantic_utilities.py | 74 ++++-- 441 files changed, 10127 insertions(+), 6095 deletions(-) delete mode 100644 generators/python/tests/utils/union_utils/2.0 delete mode 100644 generators/python/tests/utils/union_utils/types/resources/types/name.py diff --git a/generators/python/core_utilities/fastapi/__init__.py b/generators/python/core_utilities/fastapi/__init__.py index 7575f65ca72..8bee1fe7e16 100644 --- a/generators/python/core_utilities/fastapi/__init__.py +++ b/generators/python/core_utilities/fastapi/__init__.py @@ -3,7 +3,6 @@ from .pydantic_utilities import ( IS_PYDANTIC_V2, UniversalBaseModel, - deep_union_pydantic_dicts, parse_obj_as, ) from .route_args import route_args @@ -15,7 +14,6 @@ "BearerToken", "route_args", "serialize_datetime", - "deep_union_pydantic_dicts", "parse_obj_as", "UniversalBaseModel", "IS_PYDANTIC_V2", diff --git a/generators/python/core_utilities/fastapi/pydantic_utilities.py b/generators/python/core_utilities/fastapi/pydantic_utilities.py index b6dc264ae70..2537c0101d9 100644 --- a/generators/python/core_utilities/fastapi/pydantic_utilities.py +++ b/generators/python/core_utilities/fastapi/pydantic_utilities.py @@ -2,7 +2,6 @@ # nopycln: file import datetime as dt -from tkinter import E import typing from collections import defaultdict @@ -56,19 +55,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -107,9 +93,14 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) - for name, field in fields.items(): + for name, field in fields.items(): if field not in _fields_set: default = _get_field_default(field) @@ -127,7 +118,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) @@ -179,21 +170,21 @@ def decorator(func: AnyCallable) -> AnyCallable: return decorator -def universal_field_validator( - field_name: str, pre: bool = False -) -> typing.Callable[[AnyCallable], AnyCallable]: +def universal_field_validator(field_name: str, pre: bool = False) -> typing.Callable[[AnyCallable], AnyCallable]: def decorator(func: AnyCallable) -> AnyCallable: if IS_PYDANTIC_V2: - return pydantic.field_validator( - field_name, mode="before" if pre else "after" - )(func) # type: ignore # Pydantic v2 + return pydantic.field_validator(field_name, mode="before" if pre else "after")( + func + ) # type: ignore # Pydantic v2 else: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + def _get_model_fields( model: typing.Type["Model"], ) -> typing.Mapping[str, PydanticField]: diff --git a/generators/python/core_utilities/pydantic/pydantic_utilities.py b/generators/python/core_utilities/pydantic/pydantic_utilities.py index b6dc264ae70..2537c0101d9 100644 --- a/generators/python/core_utilities/pydantic/pydantic_utilities.py +++ b/generators/python/core_utilities/pydantic/pydantic_utilities.py @@ -2,7 +2,6 @@ # nopycln: file import datetime as dt -from tkinter import E import typing from collections import defaultdict @@ -56,19 +55,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -107,9 +93,14 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) - for name, field in fields.items(): + for name, field in fields.items(): if field not in _fields_set: default = _get_field_default(field) @@ -127,7 +118,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) @@ -179,21 +170,21 @@ def decorator(func: AnyCallable) -> AnyCallable: return decorator -def universal_field_validator( - field_name: str, pre: bool = False -) -> typing.Callable[[AnyCallable], AnyCallable]: +def universal_field_validator(field_name: str, pre: bool = False) -> typing.Callable[[AnyCallable], AnyCallable]: def decorator(func: AnyCallable) -> AnyCallable: if IS_PYDANTIC_V2: - return pydantic.field_validator( - field_name, mode="before" if pre else "after" - )(func) # type: ignore # Pydantic v2 + return pydantic.field_validator(field_name, mode="before" if pre else "after")( + func + ) # type: ignore # Pydantic v2 else: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + def _get_model_fields( model: typing.Type["Model"], ) -> typing.Mapping[str, PydanticField]: diff --git a/generators/python/core_utilities/sdk/pydantic_utilities.py b/generators/python/core_utilities/sdk/pydantic_utilities.py index b6dc264ae70..2537c0101d9 100644 --- a/generators/python/core_utilities/sdk/pydantic_utilities.py +++ b/generators/python/core_utilities/sdk/pydantic_utilities.py @@ -2,7 +2,6 @@ # nopycln: file import datetime as dt -from tkinter import E import typing from collections import defaultdict @@ -56,19 +55,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -107,9 +93,14 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) - for name, field in fields.items(): + for name, field in fields.items(): if field not in _fields_set: default = _get_field_default(field) @@ -127,7 +118,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) @@ -179,21 +170,21 @@ def decorator(func: AnyCallable) -> AnyCallable: return decorator -def universal_field_validator( - field_name: str, pre: bool = False -) -> typing.Callable[[AnyCallable], AnyCallable]: +def universal_field_validator(field_name: str, pre: bool = False) -> typing.Callable[[AnyCallable], AnyCallable]: def decorator(func: AnyCallable) -> AnyCallable: if IS_PYDANTIC_V2: - return pydantic.field_validator( - field_name, mode="before" if pre else "after" - )(func) # type: ignore # Pydantic v2 + return pydantic.field_validator(field_name, mode="before" if pre else "after")( + func + ) # type: ignore # Pydantic v2 else: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + def _get_model_fields( model: typing.Type["Model"], ) -> typing.Mapping[str, PydanticField]: diff --git a/generators/python/poetry.lock b/generators/python/poetry.lock index 446c15d34ad..863b97cfed1 100644 --- a/generators/python/poetry.lock +++ b/generators/python/poetry.lock @@ -1,5 +1,16 @@ # This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +[[package]] +name = "annotated-types" +version = "0.7.0" +description = "Reusable constraint types to use with typing.Annotated" +optional = false +python-versions = ">=3.8" +files = [ + {file = "annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53"}, + {file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"}, +] + [[package]] name = "anyio" version = "4.4.0" @@ -571,152 +582,122 @@ files = [ [[package]] name = "pydantic" -version = "1.10.15" -description = "Data validation and settings management using python type hints" +version = "2.8.2" +description = "Data validation using Python type hints" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "pydantic-1.10.15-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:22ed12ee588b1df028a2aa5d66f07bf8f8b4c8579c2e96d5a9c1f96b77f3bb55"}, - {file = "pydantic-1.10.15-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:75279d3cac98186b6ebc2597b06bcbc7244744f6b0b44a23e4ef01e5683cc0d2"}, - {file = "pydantic-1.10.15-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:50f1666a9940d3d68683c9d96e39640f709d7a72ff8702987dab1761036206bb"}, - {file = "pydantic-1.10.15-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:82790d4753ee5d00739d6cb5cf56bceb186d9d6ce134aca3ba7befb1eedbc2c8"}, - {file = "pydantic-1.10.15-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:d207d5b87f6cbefbdb1198154292faee8017d7495a54ae58db06762004500d00"}, - {file = "pydantic-1.10.15-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:e49db944fad339b2ccb80128ffd3f8af076f9f287197a480bf1e4ca053a866f0"}, - {file = "pydantic-1.10.15-cp310-cp310-win_amd64.whl", hash = "sha256:d3b5c4cbd0c9cb61bbbb19ce335e1f8ab87a811f6d589ed52b0254cf585d709c"}, - {file = "pydantic-1.10.15-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c3d5731a120752248844676bf92f25a12f6e45425e63ce22e0849297a093b5b0"}, - {file = "pydantic-1.10.15-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:c365ad9c394f9eeffcb30a82f4246c0006417f03a7c0f8315d6211f25f7cb654"}, - {file = "pydantic-1.10.15-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3287e1614393119c67bd4404f46e33ae3be3ed4cd10360b48d0a4459f420c6a3"}, - {file = "pydantic-1.10.15-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:be51dd2c8596b25fe43c0a4a59c2bee4f18d88efb8031188f9e7ddc6b469cf44"}, - {file = "pydantic-1.10.15-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:6a51a1dd4aa7b3f1317f65493a182d3cff708385327c1c82c81e4a9d6d65b2e4"}, - {file = "pydantic-1.10.15-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:4e316e54b5775d1eb59187f9290aeb38acf620e10f7fd2f776d97bb788199e53"}, - {file = "pydantic-1.10.15-cp311-cp311-win_amd64.whl", hash = "sha256:0d142fa1b8f2f0ae11ddd5e3e317dcac060b951d605fda26ca9b234b92214986"}, - {file = "pydantic-1.10.15-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:7ea210336b891f5ea334f8fc9f8f862b87acd5d4a0cbc9e3e208e7aa1775dabf"}, - {file = "pydantic-1.10.15-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3453685ccd7140715e05f2193d64030101eaad26076fad4e246c1cc97e1bb30d"}, - {file = "pydantic-1.10.15-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9bea1f03b8d4e8e86702c918ccfd5d947ac268f0f0cc6ed71782e4b09353b26f"}, - {file = "pydantic-1.10.15-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:005655cabc29081de8243126e036f2065bd7ea5b9dff95fde6d2c642d39755de"}, - {file = "pydantic-1.10.15-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:af9850d98fc21e5bc24ea9e35dd80a29faf6462c608728a110c0a30b595e58b7"}, - {file = "pydantic-1.10.15-cp37-cp37m-win_amd64.whl", hash = "sha256:d31ee5b14a82c9afe2bd26aaa405293d4237d0591527d9129ce36e58f19f95c1"}, - {file = "pydantic-1.10.15-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:5e09c19df304b8123938dc3c53d3d3be6ec74b9d7d0d80f4f4b5432ae16c2022"}, - {file = "pydantic-1.10.15-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7ac9237cd62947db00a0d16acf2f3e00d1ae9d3bd602b9c415f93e7a9fc10528"}, - {file = "pydantic-1.10.15-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:584f2d4c98ffec420e02305cf675857bae03c9d617fcfdc34946b1160213a948"}, - {file = "pydantic-1.10.15-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:bbc6989fad0c030bd70a0b6f626f98a862224bc2b1e36bfc531ea2facc0a340c"}, - {file = "pydantic-1.10.15-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:d573082c6ef99336f2cb5b667b781d2f776d4af311574fb53d908517ba523c22"}, - {file = "pydantic-1.10.15-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6bd7030c9abc80134087d8b6e7aa957e43d35714daa116aced57269a445b8f7b"}, - {file = "pydantic-1.10.15-cp38-cp38-win_amd64.whl", hash = "sha256:3350f527bb04138f8aff932dc828f154847fbdc7a1a44c240fbfff1b57f49a12"}, - {file = "pydantic-1.10.15-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:51d405b42f1b86703555797270e4970a9f9bd7953f3990142e69d1037f9d9e51"}, - {file = "pydantic-1.10.15-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a980a77c52723b0dc56640ced396b73a024d4b74f02bcb2d21dbbac1debbe9d0"}, - {file = "pydantic-1.10.15-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:67f1a1fb467d3f49e1708a3f632b11c69fccb4e748a325d5a491ddc7b5d22383"}, - {file = "pydantic-1.10.15-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:676ed48f2c5bbad835f1a8ed8a6d44c1cd5a21121116d2ac40bd1cd3619746ed"}, - {file = "pydantic-1.10.15-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:92229f73400b80c13afcd050687f4d7e88de9234d74b27e6728aa689abcf58cc"}, - {file = "pydantic-1.10.15-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:2746189100c646682eff0bce95efa7d2e203420d8e1c613dc0c6b4c1d9c1fde4"}, - {file = "pydantic-1.10.15-cp39-cp39-win_amd64.whl", hash = "sha256:394f08750bd8eaad714718812e7fab615f873b3cdd0b9d84e76e51ef3b50b6b7"}, - {file = "pydantic-1.10.15-py3-none-any.whl", hash = "sha256:28e552a060ba2740d0d2aabe35162652c1459a0b9069fe0db7f4ee0e18e74d58"}, - {file = "pydantic-1.10.15.tar.gz", hash = "sha256:ca832e124eda231a60a041da4f013e3ff24949d94a01154b137fc2f2a43c3ffb"}, + {file = "pydantic-2.8.2-py3-none-any.whl", hash = "sha256:73ee9fddd406dc318b885c7a2eab8a6472b68b8fb5ba8150949fc3db939f23c8"}, + {file = "pydantic-2.8.2.tar.gz", hash = "sha256:6f62c13d067b0755ad1c21a34bdd06c0c12625a22b0fc09c6b149816604f7c2a"}, ] [package.dependencies] -typing-extensions = ">=4.2.0" +annotated-types = ">=0.4.0" +pydantic-core = "2.20.1" +typing-extensions = [ + {version = ">=4.12.2", markers = "python_version >= \"3.13\""}, + {version = ">=4.6.1", markers = "python_version < \"3.13\""}, +] [package.extras] -dotenv = ["python-dotenv (>=0.10.4)"] -email = ["email-validator (>=1.0.3)"] +email = ["email-validator (>=2.0.0)"] [[package]] name = "pydantic-core" -version = "2.21.0" +version = "2.20.1" description = "Core functionality for Pydantic validation and serialization" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic_core-2.21.0-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:a97aa0a1f6c3f4e235fb2c9d12b92415faf8741c6a262d23a61fd26df7e30ff8"}, - {file = "pydantic_core-2.21.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d309202bbf9ff33e4e9e0ffd3ddcbf096e69bc81c7e68255612ca22cb1130a59"}, - {file = "pydantic_core-2.21.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e227183d791092b28815a435bd65f7105762473b3518d3a14ef8b663b99ce185"}, - {file = "pydantic_core-2.21.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:f6ef7fd514588f8414ec033ead05ebde25a348971b0f0fd3bdc24c0276b87fd0"}, - {file = "pydantic_core-2.21.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fda3119daaa7c26ac08847c07ea96dc488bc61a34023b1050c2c20ba9493f778"}, - {file = "pydantic_core-2.21.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:07224088a793c38f8d4ef4a71889c9aaf568d250afe3ebac815b5d9578f48e41"}, - {file = "pydantic_core-2.21.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:334bd7b4ece531af9339f55d87c0bc9867f8dc71b0f9312f3f10402af9b0867e"}, - {file = "pydantic_core-2.21.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2d146b6cdd06de822e9cd6e9c255d46b7ff15b0fc312996fb7f1cd31329c3275"}, - {file = "pydantic_core-2.21.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:4dcd68eb7baf796822739273864a8d988a3e81d11b1e19db2ddfb83d495fe33b"}, - {file = "pydantic_core-2.21.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:6ead7f2f7c37dbe5264083e0b3a1ae84773402359d47b2bbcc1ce07867ef80d1"}, - {file = "pydantic_core-2.21.0-cp310-none-win32.whl", hash = "sha256:f4a8e22ab111391d694c7ac35f1db3f47bd58badf76d44478c2e5fbf1622a75b"}, - {file = "pydantic_core-2.21.0-cp310-none-win_amd64.whl", hash = "sha256:75e96800f42e06e72314346575ed561b76718b92115c79888a64513b817edd40"}, - {file = "pydantic_core-2.21.0-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:0c5d05c712ba7612bb3bdd7cdc3b306bbbe0c90c2bbe66a80c7c72ea751e6b62"}, - {file = "pydantic_core-2.21.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:21b97bb2fdf330c6fb03f43307671f0cb3051cbf89a58e1cd4c99a09c69c9341"}, - {file = "pydantic_core-2.21.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:986cad6e75c9d4e8f72d5085ee8109f75dc4d9d5095c994e00ce7f3787f7022b"}, - {file = "pydantic_core-2.21.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:400cbd6fdd92815eceac1812f8cc7501789da127fe35d7ff6d08d9de377a52b9"}, - {file = "pydantic_core-2.21.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:45fc6e4be497271834e3e263288a833b328669c27056df6af83ce379e61579d7"}, - {file = "pydantic_core-2.21.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f19f026a94202157c1b6db326cb09142c996adcd8e7f705b5c4f01815fef48a9"}, - {file = "pydantic_core-2.21.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:815e9cc5cf36522097556b9c968b529f528799bfe81a38d481ae8f5564b41d1b"}, - {file = "pydantic_core-2.21.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:fda0c0e6db4ce5f568619390e7055ea77d4572261d1815d597095542d71f2b1e"}, - {file = "pydantic_core-2.21.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:ba34c0b31e3829693310f83d3f7d917a9c8c6bccbf8ac1eb5f7759c52d368e36"}, - {file = "pydantic_core-2.21.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:ad512defbcb20c7e9a30b166ddcc61583568a6e13904b0d769b78df14de8ce43"}, - {file = "pydantic_core-2.21.0-cp311-none-win32.whl", hash = "sha256:0a1e19114c93ced62b691a44721488af04080658410d01cd895cb2afc16abb5b"}, - {file = "pydantic_core-2.21.0-cp311-none-win_amd64.whl", hash = "sha256:c95d11d9167e8bb2cafdd12858e9c51e92edd30813976eff637e4ab4555d742e"}, - {file = "pydantic_core-2.21.0-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:86b6f0a53daadf0c5a19733489c7987d278962b92411214f56bf52eb757cc9d7"}, - {file = "pydantic_core-2.21.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:c53d38dec60b0906a716f66f9ea70811a8b2ae9d6234d2108a57f8750b0c707f"}, - {file = "pydantic_core-2.21.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:639e0e7c9f5777b9b1c5f760d25cc615c40bef005af15c892324193fc18c8141"}, - {file = "pydantic_core-2.21.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:2fe2e1cc87e8ddfc251e7f4100b30ca96700866b17d972ec842330cd10f9b379"}, - {file = "pydantic_core-2.21.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c5b839081226a4c4e3c96efe89fbb5004a9f1eebc039fcd4e26794cfe4412b5a"}, - {file = "pydantic_core-2.21.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e20b44a5dcb290bad3d02680d52a58c5b5938547d85bcb56b3412bfdb387a3a8"}, - {file = "pydantic_core-2.21.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5069840df8f808bca75956114844260481ea86e524364573d937e47c5013a982"}, - {file = "pydantic_core-2.21.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:130102233794bca08eaab7075711b637055e861c2ebb9e3c29ed117a3b035316"}, - {file = "pydantic_core-2.21.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:375008cd44acad0bbfa7e18819e8613bb638bcbad890c071d835c593ed0bd73f"}, - {file = "pydantic_core-2.21.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:5bcebd8b7e972d36ebc6b50f1f1fd9ff43eef53e60312dfa3ba809f1e33ec40f"}, - {file = "pydantic_core-2.21.0-cp312-none-win32.whl", hash = "sha256:7cb413eb75374e88a4989bc17c30f6eda6707bfeaad2272900e3dc5c08e91519"}, - {file = "pydantic_core-2.21.0-cp312-none-win_amd64.whl", hash = "sha256:3ab9a69b1beb04c7d263af049acca39c749753507bf811a639278b7aaf68ad79"}, - {file = "pydantic_core-2.21.0-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:0bf9815c7d5535b7d8c62248fa1536335c8186b9daa08056c5cb753e47b4435c"}, - {file = "pydantic_core-2.21.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:bf6b0cb6655970729ef3f35f54009cecfba6ba7cb8033bf3c56162b4bc418122"}, - {file = "pydantic_core-2.21.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:30085b96b9168451663ea9872cbf94922c5045158d243c404917a2ca9a1abe32"}, - {file = "pydantic_core-2.21.0-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e168240f12b187a1a214bf4867f9bab1a91cea3142e1cf361b7dddb7d08cc409"}, - {file = "pydantic_core-2.21.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e960a00230f1fca4ed34f5230e4db467eccc68f0777c565d9c3ce9aa6593f3e5"}, - {file = "pydantic_core-2.21.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:006a8210cd7134a7ae328433cb84a1076badbf5731c7876f96962ef8fd61d42d"}, - {file = "pydantic_core-2.21.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b0c40b8092c4679956aabff88454d618113529e40253b2a7df0a431e61ea2d84"}, - {file = "pydantic_core-2.21.0-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:72e74856b503cb434479cf7d21bb3dc140ed2d97e2be2ac452ec483d275f413b"}, - {file = "pydantic_core-2.21.0-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:dd5de610e64e77062877ee58a12f505fd4e1b092e61b3631f1677c267c7c6a8c"}, - {file = "pydantic_core-2.21.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:f2e6a46a6c9abd4f480fbced953936889380dec40e0a9f8aba32f45e1baae5f1"}, - {file = "pydantic_core-2.21.0-cp313-none-win32.whl", hash = "sha256:7c792fcb776d412d3ce2d71577ad729d627500998963bce88298b6a87b241ed8"}, - {file = "pydantic_core-2.21.0-cp313-none-win_amd64.whl", hash = "sha256:28317f20cdef82a41cdaa0f152be692c49fe0c22cc4ea55d73c0bd4624fcce14"}, - {file = "pydantic_core-2.21.0-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:ce1796df2f4c0a8605d30cd8b2726589ee404b34d8ecef93453e3c4366bea821"}, - {file = "pydantic_core-2.21.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:1e2134bf92b5a59223dfef4b50ee19fb76935299df0ab8aa0c99055ce7ae0d36"}, - {file = "pydantic_core-2.21.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1c0739fdbfcecb83fd8ef48863fdc82d108e647690d4948a88afa1dd307e175e"}, - {file = "pydantic_core-2.21.0-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:8a430bac8c43eb8a3e279cecab067ef2afbba6f28a8a6a0cf419c89588757436"}, - {file = "pydantic_core-2.21.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6a72b8b6e5350d74d13deecffdc393e768941fc3b61e6973e9c0ea26c33b3969"}, - {file = "pydantic_core-2.21.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c4114ca818afd13787312374df8740f026eaa0230bc87f81153eb6a20c3f39ad"}, - {file = "pydantic_core-2.21.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:07b5f813dd7c1520609ef764b3e9a80182456e4a003264eb473640f97afff985"}, - {file = "pydantic_core-2.21.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:a403beaa2651dc55df42def4d364f08705f5373ca3d44bbfa5ba6160767eb8fb"}, - {file = "pydantic_core-2.21.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:c95f17e63c5f811027bf768e027f247d49038c0ace817990417a0410894bfd67"}, - {file = "pydantic_core-2.21.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:23043d6944bd281f353896f7516edfaa8111e65bd80fd936dc1a8751dcc4e4cf"}, - {file = "pydantic_core-2.21.0-cp38-none-win32.whl", hash = "sha256:baefe94e313184f024f594ac35eabbc467c830b0fe7eb71c2fddc469414006e2"}, - {file = "pydantic_core-2.21.0-cp38-none-win_amd64.whl", hash = "sha256:c5a9cc3fd81cdd60ef203920794ccbe73630f82770e03e9446ee782454760235"}, - {file = "pydantic_core-2.21.0-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:4b68e752432f67403739bad3c94946d134ad7143840f54281d039bab21a1ca5e"}, - {file = "pydantic_core-2.21.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ab770f7506d579de7f51f15ce4994a53f3155347d51d87970f70038662ff70a9"}, - {file = "pydantic_core-2.21.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e9038a1b8c1ad42cf2be95a6fb1e2e3b66730e23ad0f677f2e9e2e5f02afbad3"}, - {file = "pydantic_core-2.21.0-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e2e7e7d1a08fbddd7cc8cea3a9cd23fc772b7b955056e5a3575808a4acbc20fa"}, - {file = "pydantic_core-2.21.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fa78fbd6a49b4a7481d700645f08fefb789e739fa6a46a3fa6a5fbbb2a83985c"}, - {file = "pydantic_core-2.21.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:90e3a7291073098b61a8331e13907132c5a8f1ffc69a576fc05aae1ffb1849a3"}, - {file = "pydantic_core-2.21.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:88fd993f5c19e5d63c9e441b9f3156d266fc16d02498abaf56a76761d8c74ec7"}, - {file = "pydantic_core-2.21.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:43e10ff6648ba9281c1389ee44953b8def12211afb3d3c169982df3dedcda79f"}, - {file = "pydantic_core-2.21.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:84f69f77893e691f4d2e77df0366494cf16bd5326ce5f045b654d7aef82eb1e7"}, - {file = "pydantic_core-2.21.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:4ce1ead9e4b628272c51e5b869cc78d0523a03a1fee9fbba474f48e1a436e553"}, - {file = "pydantic_core-2.21.0-cp39-none-win32.whl", hash = "sha256:0a06a47227b09ef094901ba3c8e069121965701aae1e9c6aa19cacbbba0b23af"}, - {file = "pydantic_core-2.21.0-cp39-none-win_amd64.whl", hash = "sha256:e281ec1c9dd7379f92b6f1da2e902c7d6fcc99b58ca58cd8de520ab189a184f7"}, - {file = "pydantic_core-2.21.0-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:88cf788e5a4a70014f1ce916a245fb8ffa939421a4e407f6eca962735813fd54"}, - {file = "pydantic_core-2.21.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:6f9e0b7c870298d6533579b7132e68d8e2c47ef35e2f5c79160389dfd527b3ac"}, - {file = "pydantic_core-2.21.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c1c622bfeab021f1c461ddb4097713d73122eec4bc6943b2800bb559df7f6fe1"}, - {file = "pydantic_core-2.21.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:356c73057d231f138d2638daa1dcc56e77e8d2e744fc7f04bfb5505389f08c7a"}, - {file = "pydantic_core-2.21.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:20a8d6e18e34ae34cfe26ce2c3cc866ee88b8623a4f1e93319501b3a68b57c44"}, - {file = "pydantic_core-2.21.0-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:97957c5484bdfe56b0a7ec8a623cd54f8872fb1f55090a2f52a3c065726d6bc6"}, - {file = "pydantic_core-2.21.0-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:ed1e082eecf51152fb9bdbbb14e574c72a78a592774617873522f6b3dee3e8ed"}, - {file = "pydantic_core-2.21.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:92e8b3bf64b210d51a5fc950be62dadecad5a8e329b34b8b2f690a505f6dafe3"}, - {file = "pydantic_core-2.21.0-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:6826218c59be7d2c9c306d5b7fa829b4ad4b2d96cb984c91f8ec82b91f63dc63"}, - {file = "pydantic_core-2.21.0-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:ab3391fb685026e6928b4d51cd044403ecefa7e7421a0f14887eb4708c3da7bb"}, - {file = "pydantic_core-2.21.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1b224bde36cafcc7f1d51e5c88cb784eb1a76f74701b5700dcc37dca66be745b"}, - {file = "pydantic_core-2.21.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b64bfc7b468cc524e9acfaf379333c1a4f771adf19d15ceae3b8f580ed9a0d4e"}, - {file = "pydantic_core-2.21.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:48991177fc0cf6cd9fd245433db167382c8c36bb18f64195532842ba5ba082fa"}, - {file = "pydantic_core-2.21.0-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:d9251ed0317455ccccd520600d4b6b07fd1486d53846bd82677f08a4999df949"}, - {file = "pydantic_core-2.21.0-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:4e6699cb02d3f063f6b35609830fc6d56aba1b4bcb6a82d604b5dd6b2156f87a"}, - {file = "pydantic_core-2.21.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:46be3c8c7e8346f2c02bf261b4dbff1d9e31001fb231ce9a1d52d7ef61d291fc"}, - {file = "pydantic_core-2.21.0.tar.gz", hash = "sha256:79c747f9916e5b6cb588dfd994d9ac15a93e43eb07467d9e6f24d892c176bbf5"}, + {file = "pydantic_core-2.20.1-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:3acae97ffd19bf091c72df4d726d552c473f3576409b2a7ca36b2f535ffff4a3"}, + {file = "pydantic_core-2.20.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:41f4c96227a67a013e7de5ff8f20fb496ce573893b7f4f2707d065907bffdbd6"}, + {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5f239eb799a2081495ea659d8d4a43a8f42cd1fe9ff2e7e436295c38a10c286a"}, + {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:53e431da3fc53360db73eedf6f7124d1076e1b4ee4276b36fb25514544ceb4a3"}, + {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f1f62b2413c3a0e846c3b838b2ecd6c7a19ec6793b2a522745b0869e37ab5bc1"}, + {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5d41e6daee2813ecceea8eda38062d69e280b39df793f5a942fa515b8ed67953"}, + {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3d482efec8b7dc6bfaedc0f166b2ce349df0011f5d2f1f25537ced4cfc34fd98"}, + {file = "pydantic_core-2.20.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:e93e1a4b4b33daed65d781a57a522ff153dcf748dee70b40c7258c5861e1768a"}, + {file = "pydantic_core-2.20.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:e7c4ea22b6739b162c9ecaaa41d718dfad48a244909fe7ef4b54c0b530effc5a"}, + {file = "pydantic_core-2.20.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:4f2790949cf385d985a31984907fecb3896999329103df4e4983a4a41e13e840"}, + {file = "pydantic_core-2.20.1-cp310-none-win32.whl", hash = "sha256:5e999ba8dd90e93d57410c5e67ebb67ffcaadcea0ad973240fdfd3a135506250"}, + {file = "pydantic_core-2.20.1-cp310-none-win_amd64.whl", hash = "sha256:512ecfbefef6dac7bc5eaaf46177b2de58cdf7acac8793fe033b24ece0b9566c"}, + {file = "pydantic_core-2.20.1-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:d2a8fa9d6d6f891f3deec72f5cc668e6f66b188ab14bb1ab52422fe8e644f312"}, + {file = "pydantic_core-2.20.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:175873691124f3d0da55aeea1d90660a6ea7a3cfea137c38afa0a5ffabe37b88"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:37eee5b638f0e0dcd18d21f59b679686bbd18917b87db0193ae36f9c23c355fc"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:25e9185e2d06c16ee438ed39bf62935ec436474a6ac4f9358524220f1b236e43"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:150906b40ff188a3260cbee25380e7494ee85048584998c1e66df0c7a11c17a6"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8ad4aeb3e9a97286573c03df758fc7627aecdd02f1da04516a86dc159bf70121"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d3f3ed29cd9f978c604708511a1f9c2fdcb6c38b9aae36a51905b8811ee5cbf1"}, + {file = "pydantic_core-2.20.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:b0dae11d8f5ded51699c74d9548dcc5938e0804cc8298ec0aa0da95c21fff57b"}, + {file = "pydantic_core-2.20.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:faa6b09ee09433b87992fb5a2859efd1c264ddc37280d2dd5db502126d0e7f27"}, + {file = "pydantic_core-2.20.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:9dc1b507c12eb0481d071f3c1808f0529ad41dc415d0ca11f7ebfc666e66a18b"}, + {file = "pydantic_core-2.20.1-cp311-none-win32.whl", hash = "sha256:fa2fddcb7107e0d1808086ca306dcade7df60a13a6c347a7acf1ec139aa6789a"}, + {file = "pydantic_core-2.20.1-cp311-none-win_amd64.whl", hash = "sha256:40a783fb7ee353c50bd3853e626f15677ea527ae556429453685ae32280c19c2"}, + {file = "pydantic_core-2.20.1-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:595ba5be69b35777474fa07f80fc260ea71255656191adb22a8c53aba4479231"}, + {file = "pydantic_core-2.20.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:a4f55095ad087474999ee28d3398bae183a66be4823f753cd7d67dd0153427c9"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f9aa05d09ecf4c75157197f27cdc9cfaeb7c5f15021c6373932bf3e124af029f"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e97fdf088d4b31ff4ba35db26d9cc472ac7ef4a2ff2badeabf8d727b3377fc52"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bc633a9fe1eb87e250b5c57d389cf28998e4292336926b0b6cdaee353f89a237"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d573faf8eb7e6b1cbbcb4f5b247c60ca8be39fe2c674495df0eb4318303137fe"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:26dc97754b57d2fd00ac2b24dfa341abffc380b823211994c4efac7f13b9e90e"}, + {file = "pydantic_core-2.20.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:33499e85e739a4b60c9dac710c20a08dc73cb3240c9a0e22325e671b27b70d24"}, + {file = "pydantic_core-2.20.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:bebb4d6715c814597f85297c332297c6ce81e29436125ca59d1159b07f423eb1"}, + {file = "pydantic_core-2.20.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:516d9227919612425c8ef1c9b869bbbee249bc91912c8aaffb66116c0b447ebd"}, + {file = "pydantic_core-2.20.1-cp312-none-win32.whl", hash = "sha256:469f29f9093c9d834432034d33f5fe45699e664f12a13bf38c04967ce233d688"}, + {file = "pydantic_core-2.20.1-cp312-none-win_amd64.whl", hash = "sha256:035ede2e16da7281041f0e626459bcae33ed998cca6a0a007a5ebb73414ac72d"}, + {file = "pydantic_core-2.20.1-cp313-cp313-macosx_10_12_x86_64.whl", hash = "sha256:0827505a5c87e8aa285dc31e9ec7f4a17c81a813d45f70b1d9164e03a813a686"}, + {file = "pydantic_core-2.20.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:19c0fa39fa154e7e0b7f82f88ef85faa2a4c23cc65aae2f5aea625e3c13c735a"}, + {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4aa223cd1e36b642092c326d694d8bf59b71ddddc94cdb752bbbb1c5c91d833b"}, + {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c336a6d235522a62fef872c6295a42ecb0c4e1d0f1a3e500fe949415761b8a19"}, + {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7eb6a0587eded33aeefea9f916899d42b1799b7b14b8f8ff2753c0ac1741edac"}, + {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:70c8daf4faca8da5a6d655f9af86faf6ec2e1768f4b8b9d0226c02f3d6209703"}, + {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e9fa4c9bf273ca41f940bceb86922a7667cd5bf90e95dbb157cbb8441008482c"}, + {file = "pydantic_core-2.20.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:11b71d67b4725e7e2a9f6e9c0ac1239bbc0c48cce3dc59f98635efc57d6dac83"}, + {file = "pydantic_core-2.20.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:270755f15174fb983890c49881e93f8f1b80f0b5e3a3cc1394a255706cabd203"}, + {file = "pydantic_core-2.20.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:c81131869240e3e568916ef4c307f8b99583efaa60a8112ef27a366eefba8ef0"}, + {file = "pydantic_core-2.20.1-cp313-none-win32.whl", hash = "sha256:b91ced227c41aa29c672814f50dbb05ec93536abf8f43cd14ec9521ea09afe4e"}, + {file = "pydantic_core-2.20.1-cp313-none-win_amd64.whl", hash = "sha256:65db0f2eefcaad1a3950f498aabb4875c8890438bc80b19362cf633b87a8ab20"}, + {file = "pydantic_core-2.20.1-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:4745f4ac52cc6686390c40eaa01d48b18997cb130833154801a442323cc78f91"}, + {file = "pydantic_core-2.20.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a8ad4c766d3f33ba8fd692f9aa297c9058970530a32c728a2c4bfd2616d3358b"}, + {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:41e81317dd6a0127cabce83c0c9c3fbecceae981c8391e6f1dec88a77c8a569a"}, + {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:04024d270cf63f586ad41fff13fde4311c4fc13ea74676962c876d9577bcc78f"}, + {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:eaad4ff2de1c3823fddf82f41121bdf453d922e9a238642b1dedb33c4e4f98ad"}, + {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:26ab812fa0c845df815e506be30337e2df27e88399b985d0bb4e3ecfe72df31c"}, + {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3c5ebac750d9d5f2706654c638c041635c385596caf68f81342011ddfa1e5598"}, + {file = "pydantic_core-2.20.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2aafc5a503855ea5885559eae883978c9b6d8c8993d67766ee73d82e841300dd"}, + {file = "pydantic_core-2.20.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:4868f6bd7c9d98904b748a2653031fc9c2f85b6237009d475b1008bfaeb0a5aa"}, + {file = "pydantic_core-2.20.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:aa2f457b4af386254372dfa78a2eda2563680d982422641a85f271c859df1987"}, + {file = "pydantic_core-2.20.1-cp38-none-win32.whl", hash = "sha256:225b67a1f6d602de0ce7f6c1c3ae89a4aa25d3de9be857999e9124f15dab486a"}, + {file = "pydantic_core-2.20.1-cp38-none-win_amd64.whl", hash = "sha256:6b507132dcfc0dea440cce23ee2182c0ce7aba7054576efc65634f080dbe9434"}, + {file = "pydantic_core-2.20.1-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:b03f7941783b4c4a26051846dea594628b38f6940a2fdc0df00b221aed39314c"}, + {file = "pydantic_core-2.20.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:1eedfeb6089ed3fad42e81a67755846ad4dcc14d73698c120a82e4ccf0f1f9f6"}, + {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:635fee4e041ab9c479e31edda27fcf966ea9614fff1317e280d99eb3e5ab6fe2"}, + {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:77bf3ac639c1ff567ae3b47f8d4cc3dc20f9966a2a6dd2311dcc055d3d04fb8a"}, + {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7ed1b0132f24beeec5a78b67d9388656d03e6a7c837394f99257e2d55b461611"}, + {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c6514f963b023aeee506678a1cf821fe31159b925c4b76fe2afa94cc70b3222b"}, + {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:10d4204d8ca33146e761c79f83cc861df20e7ae9f6487ca290a97702daf56006"}, + {file = "pydantic_core-2.20.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:2d036c7187b9422ae5b262badb87a20a49eb6c5238b2004e96d4da1231badef1"}, + {file = "pydantic_core-2.20.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:9ebfef07dbe1d93efb94b4700f2d278494e9162565a54f124c404a5656d7ff09"}, + {file = "pydantic_core-2.20.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:6b9d9bb600328a1ce523ab4f454859e9d439150abb0906c5a1983c146580ebab"}, + {file = "pydantic_core-2.20.1-cp39-none-win32.whl", hash = "sha256:784c1214cb6dd1e3b15dd8b91b9a53852aed16671cc3fbe4786f4f1db07089e2"}, + {file = "pydantic_core-2.20.1-cp39-none-win_amd64.whl", hash = "sha256:d2fe69c5434391727efa54b47a1e7986bb0186e72a41b203df8f5b0a19a4f669"}, + {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:a45f84b09ac9c3d35dfcf6a27fd0634d30d183205230a0ebe8373a0e8cfa0906"}, + {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:d02a72df14dfdbaf228424573a07af10637bd490f0901cee872c4f434a735b94"}, + {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d2b27e6af28f07e2f195552b37d7d66b150adbaa39a6d327766ffd695799780f"}, + {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:084659fac3c83fd674596612aeff6041a18402f1e1bc19ca39e417d554468482"}, + {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:242b8feb3c493ab78be289c034a1f659e8826e2233786e36f2893a950a719bb6"}, + {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:38cf1c40a921d05c5edc61a785c0ddb4bed67827069f535d794ce6bcded919fc"}, + {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:e0bbdd76ce9aa5d4209d65f2b27fc6e5ef1312ae6c5333c26db3f5ade53a1e99"}, + {file = "pydantic_core-2.20.1-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:254ec27fdb5b1ee60684f91683be95e5133c994cc54e86a0b0963afa25c8f8a6"}, + {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:407653af5617f0757261ae249d3fba09504d7a71ab36ac057c938572d1bc9331"}, + {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:c693e916709c2465b02ca0ad7b387c4f8423d1db7b4649c551f27a529181c5ad"}, + {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5b5ff4911aea936a47d9376fd3ab17e970cc543d1b68921886e7f64bd28308d1"}, + {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:177f55a886d74f1808763976ac4efd29b7ed15c69f4d838bbd74d9d09cf6fa86"}, + {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:964faa8a861d2664f0c7ab0c181af0bea66098b1919439815ca8803ef136fc4e"}, + {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:4dd484681c15e6b9a977c785a345d3e378d72678fd5f1f3c0509608da24f2ac0"}, + {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:f6d6cff3538391e8486a431569b77921adfcdef14eb18fbf19b7c0a5294d4e6a"}, + {file = "pydantic_core-2.20.1-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:a6d511cc297ff0883bc3708b465ff82d7560193169a8b93260f74ecb0a5e08a7"}, + {file = "pydantic_core-2.20.1.tar.gz", hash = "sha256:26ca695eeee5f9f1aeeb211ffc12f10bcb6f71e2989988fda61dabd65db878d4"}, ] [package.dependencies] @@ -1072,4 +1053,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "b0fc887ff0c75d88165dd1fe5c5d61aa0dd863fa95ce8bafa5e1424e2fa6e6c1" +content-hash = "481db7c435ac15886c0e4b5afbf7ea276b7ebd24f30cbb48090fc2a33542852b" diff --git a/generators/python/pyproject.toml b/generators/python/pyproject.toml index 2ee74fc01a6..76bcad6ad33 100644 --- a/generators/python/pyproject.toml +++ b/generators/python/pyproject.toml @@ -6,7 +6,7 @@ authors = [] [tool.poetry.dependencies] python = "^3.9" -pydantic = "1.10.15" +pydantic = "^2.8.2" typer = {extras = ["all"], version = "^0.6.1"} fern-fern-generator-exec-sdk = {version = "0.82.5", source = "fern-prod"} ordered-set = "^4.1.0" diff --git a/generators/python/src/fern_python/generators/core_utilities/core_utilities.py b/generators/python/src/fern_python/generators/core_utilities/core_utilities.py index badc05306d7..6a0e2a71d73 100644 --- a/generators/python/src/fern_python/generators/core_utilities/core_utilities.py +++ b/generators/python/src/fern_python/generators/core_utilities/core_utilities.py @@ -34,7 +34,6 @@ def copy_to_project(self, *, project: Project) -> None: file=Filepath.FilepathPart(module_name="pydantic_utilities"), ), exports={ - "deep_union_pydantic_dicts", "parse_obj_as", "UniversalBaseModel", "IS_PYDANTIC_V2", @@ -163,15 +162,6 @@ def get_construct(self, type_of_obj: AST.TypeHint, obj: AST.Expression) -> AST.E else self.get_parse_obj_as(type_of_obj, obj) ) - def get_pydantic_deep_union_import(self) -> AST.Reference: - return AST.Reference( - qualified_name_excluding_import=(), - import_=AST.ReferenceImport( - module=AST.Module.local(*self._module_path, "pydantic_utilities"), - named_import="deep_union_pydantic_dicts", - ), - ) - def get_universal_base_model(self) -> AST.ClassReference: return AST.ClassReference( qualified_name_excluding_import=(), diff --git a/generators/python/src/fern_python/generators/fastapi/core_utilities/core_utilities.py b/generators/python/src/fern_python/generators/fastapi/core_utilities/core_utilities.py index 6eeabad5881..743285185a3 100644 --- a/generators/python/src/fern_python/generators/fastapi/core_utilities/core_utilities.py +++ b/generators/python/src/fern_python/generators/fastapi/core_utilities/core_utilities.py @@ -133,7 +133,6 @@ def copy_to_project(self, *, project: Project) -> None: file=Filepath.FilepathPart(module_name="pydantic_utilities"), ), exports={ - "deep_union_pydantic_dicts", "parse_obj_as", "UniversalBaseModel", "IS_PYDANTIC_V2", diff --git a/generators/python/src/fern_python/generators/sdk/core_utilities/core_utilities.py b/generators/python/src/fern_python/generators/sdk/core_utilities/core_utilities.py index 3e815d65d4b..f6b6760749b 100644 --- a/generators/python/src/fern_python/generators/sdk/core_utilities/core_utilities.py +++ b/generators/python/src/fern_python/generators/sdk/core_utilities/core_utilities.py @@ -112,7 +112,6 @@ def copy_to_project(self, *, project: Project) -> None: file=Filepath.FilepathPart(module_name="pydantic_utilities"), ), exports={ - "deep_union_pydantic_dicts", "parse_obj_as", "UniversalBaseModel", "IS_PYDANTIC_V2", @@ -493,15 +492,6 @@ def instantiate_paginator( ) ) - def get_pydantic_deep_union_import(self) -> AST.Reference: - return AST.Reference( - qualified_name_excluding_import=(), - import_=AST.ReferenceImport( - module=AST.Module.local(*self._module_path, "pydantic_utilities"), - named_import="deep_union_pydantic_dicts", - ), - ) - def get_encode_query(self, obj: AST.Expression) -> AST.Expression: return AST.Expression( AST.FunctionInvocation( diff --git a/generators/python/tests/utils/example_models/types/core/__init__.py b/generators/python/tests/utils/example_models/types/core/__init__.py index 29f1c168c81..959cce2fde0 100644 --- a/generators/python/tests/utils/example_models/types/core/__init__.py +++ b/generators/python/tests/utils/example_models/types/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -22,7 +21,6 @@ "UniversalBaseModel", "UniversalRootModel", "construct_type", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/generators/python/tests/utils/example_models/types/core/datetime_utils.py b/generators/python/tests/utils/example_models/types/core/datetime_utils.py index 7c9864a944c..47344e9d9cc 100644 --- a/generators/python/tests/utils/example_models/types/core/datetime_utils.py +++ b/generators/python/tests/utils/example_models/types/core/datetime_utils.py @@ -13,7 +13,9 @@ def serialize_datetime(v: dt.datetime) -> str: """ def _serialize_zoned_datetime(v: dt.datetime) -> str: - if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(None): + if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname( + None + ): # UTC is a special case where we use "Z" at the end instead of "+00:00" return v.isoformat().replace("+00:00", "Z") else: diff --git a/generators/python/tests/utils/example_models/types/core/pydantic_utilities.py b/generators/python/tests/utils/example_models/types/core/pydantic_utilities.py index 0b53853c101..142f9ee8db8 100644 --- a/generators/python/tests/utils/example_models/types/core/pydantic_utilities.py +++ b/generators/python/tests/utils/example_models/types/core/pydantic_utilities.py @@ -1,10 +1,13 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing from collections import defaultdict -from functools import wraps + +import typing_extensions import pydantic @@ -27,11 +30,15 @@ from pydantic.v1.typing import ( # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2 get_args as get_args, ) - from pydantic.v1.typing import get_origin as get_origin # pyright: ignore[reportMissingImports] # Pydantic v2 + from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2 + get_origin as get_origin, + ) from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2 is_literal_type as is_literal_type, ) - from pydantic.v1.typing import is_union as is_union # pyright: ignore[reportMissingImports] # Pydantic v2 + from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2 + is_union as is_union, + ) from pydantic.v1.fields import ModelField as ModelField # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2 else: from pydantic.datetime_parse import parse_date as parse_date # type: ignore # Pydantic v1 @@ -50,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -90,36 +84,55 @@ class Config: json_encoders = {dt.datetime: serialize_datetime} def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } if IS_PYDANTIC_V2: return super().model_dump_json(**kwargs_with_defaults) # type: ignore # Pydantic v2 else: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + "include": _fields_set, + **kwargs, + } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) + return super().dict(**kwargs_with_defaults_exclude_unset) -UniversalRootModel: typing.Type[typing.Any] if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 pass - UniversalRootModel = V2RootModel + UniversalRootModel: typing_extensions.TypeAlias = V2RootModel # type: ignore else: - UniversalRootModel = UniversalBaseModel + UniversalRootModel: typing_extensions.TypeAlias = UniversalBaseModel # type: ignore def encode_by_type(o: typing.Any) -> typing.Any: @@ -136,44 +149,64 @@ def encode_by_type(o: typing.Any) -> typing.Any: return encoder(o) -def update_forward_refs(model: typing.Type["Model"], **localns: typing.Any) -> None: +def update_forward_refs(model: typing.Type["Model"]) -> None: if IS_PYDANTIC_V2: - model.model_rebuild(force=True, raise_errors=False) # type: ignore # Pydantic v2 + model.model_rebuild(raise_errors=False) # type: ignore # Pydantic v2 else: - model.update_forward_refs(**localns) + model.update_forward_refs() # Mirrors Pydantic's internal typing AnyCallable = typing.Callable[..., typing.Any] -def universal_root_validator(pre: bool = False) -> typing.Callable[[AnyCallable], AnyCallable]: +def universal_root_validator( + pre: bool = False, +) -> typing.Callable[[AnyCallable], AnyCallable]: def decorator(func: AnyCallable) -> AnyCallable: - @wraps(func) - def validate(*args: typing.Any, **kwargs: typing.Any) -> AnyCallable: - if IS_PYDANTIC_V2: - wrapped_func = pydantic.model_validator("before" if pre else "after")(func) # type: ignore # Pydantic v2 - else: - wrapped_func = pydantic.root_validator(pre=pre)(func) # type: ignore # Pydantic v1 + if IS_PYDANTIC_V2: + return pydantic.model_validator(mode="before" if pre else "after")(func) # type: ignore # Pydantic v2 + else: + return pydantic.root_validator(pre=pre)(func) # type: ignore # Pydantic v1 + + return decorator - return wrapped_func(*args, **kwargs) - return validate +def universal_field_validator( + field_name: str, pre: bool = False +) -> typing.Callable[[AnyCallable], AnyCallable]: + def decorator(func: AnyCallable) -> AnyCallable: + if IS_PYDANTIC_V2: + return pydantic.field_validator( + field_name, mode="before" if pre else "after" + )(func) # type: ignore # Pydantic v2 + else: + return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator -def universal_field_validator(field_name: str, pre: bool = False) -> typing.Callable[[AnyCallable], AnyCallable]: - def decorator(func: AnyCallable) -> AnyCallable: - @wraps(func) - def validate(*args: typing.Any, **kwargs: typing.Any) -> AnyCallable: - if IS_PYDANTIC_V2: - wrapped_func = pydantic.field_validator(field_name, mode="before" if pre else "after")(func) # type: ignore # Pydantic v2 - else: - wrapped_func = pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - return wrapped_func(*args, **kwargs) - return validate +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 - return decorator + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/generators/python/tests/utils/example_models/types/core/serialization.py b/generators/python/tests/utils/example_models/types/core/serialization.py index 8ad5cf8125f..5400ca0bc3b 100644 --- a/generators/python/tests/utils/example_models/types/core/serialization.py +++ b/generators/python/tests/utils/example_models/types/core/serialization.py @@ -25,7 +25,10 @@ def __init__(self, *, alias: str) -> None: def convert_and_respect_annotation_metadata( - *, object_: typing.Any, annotation: typing.Any, inner_type: typing.Optional[typing.Any] = None + *, + object_: typing.Any, + annotation: typing.Any, + inner_type: typing.Optional[typing.Any] = None, ) -> typing.Any: """ Respect the metadata annotations on a field, such as aliasing. This function effectively @@ -53,7 +56,9 @@ def convert_and_respect_annotation_metadata( inner_type = annotation clean_type = _remove_annotations(inner_type) - if typing_extensions.is_typeddict(clean_type) and isinstance(object_, typing.Mapping): + if typing_extensions.is_typeddict(clean_type) and isinstance( + object_, typing.Mapping + ): return _convert_typeddict(object_, clean_type) if ( @@ -79,7 +84,8 @@ def convert_and_respect_annotation_metadata( or ( ( typing_extensions.get_origin(clean_type) == typing.Sequence - or typing_extensions.get_origin(clean_type) == collections.abc.Sequence + or typing_extensions.get_origin(clean_type) + == collections.abc.Sequence or clean_type == typing.Sequence ) and isinstance(object_, typing.Sequence) @@ -88,7 +94,9 @@ def convert_and_respect_annotation_metadata( ): inner_type = typing_extensions.get_args(clean_type)[0] return [ - convert_and_respect_annotation_metadata(object_=item, annotation=annotation, inner_type=inner_type) + convert_and_respect_annotation_metadata( + object_=item, annotation=annotation, inner_type=inner_type + ) for item in object_ ] @@ -98,7 +106,9 @@ def convert_and_respect_annotation_metadata( # of the same name to a different name from another member # Or if another member aliases a field of the same name that another member does not. for member in typing_extensions.get_args(clean_type): - object_ = convert_and_respect_annotation_metadata(object_=object_, annotation=annotation, inner_type=member) + object_ = convert_and_respect_annotation_metadata( + object_=object_, annotation=annotation, inner_type=member + ) return object_ annotated_type = _get_annotation(annotation) @@ -110,7 +120,9 @@ def convert_and_respect_annotation_metadata( return object_ -def _convert_typeddict(object_: typing.Mapping[str, object], expected_type: typing.Any) -> typing.Mapping[str, object]: +def _convert_typeddict( + object_: typing.Mapping[str, object], expected_type: typing.Any +) -> typing.Mapping[str, object]: converted_object: typing.Dict[str, object] = {} annotations = typing_extensions.get_type_hints(expected_type, include_extras=True) for key, value in object_.items(): @@ -118,8 +130,8 @@ def _convert_typeddict(object_: typing.Mapping[str, object], expected_type: typi if type_ is None: converted_object[key] = value else: - converted_object[_alias_key(key, type_)] = convert_and_respect_annotation_metadata( - object_=value, annotation=type_ + converted_object[_alias_key(key, type_)] = ( + convert_and_respect_annotation_metadata(object_=value, annotation=type_) ) return converted_object diff --git a/generators/python/tests/utils/example_models/types/core/unchecked_base_model.py b/generators/python/tests/utils/example_models/types/core/unchecked_base_model.py index 401cc513bd1..c5e3ed36f22 100644 --- a/generators/python/tests/utils/example_models/types/core/unchecked_base_model.py +++ b/generators/python/tests/utils/example_models/types/core/unchecked_base_model.py @@ -5,10 +5,11 @@ import typing import uuid -import pydantic import typing_extensions from pydantic_core import PydanticUndefined +import pydantic + from .pydantic_utilities import ( IS_PYDANTIC_V2, ModelField, @@ -35,7 +36,9 @@ def __init__(self, *, discriminant: str) -> None: class UncheckedBaseModel(UniversalBaseModel): if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow" + ) # type: ignore # Pydantic v2 else: class Config: @@ -43,7 +46,9 @@ class Config: @classmethod def model_construct( - cls: typing.Type["Model"], _fields_set: typing.Optional[typing.Set[str]] = None, **values: typing.Any + cls: typing.Type["Model"], + _fields_set: typing.Optional[typing.Set[str]] = None, + **values: typing.Any, ) -> "Model": # Fallback construct function to the specified override below. return cls.construct(_fields_set=_fields_set, **values) @@ -52,7 +57,9 @@ def model_construct( # Implementation taken from: https://github.com/pydantic/pydantic/issues/1168#issuecomment-817742836 @classmethod def construct( - cls: typing.Type["Model"], _fields_set: typing.Optional[typing.Set[str]] = None, **values: typing.Any + cls: typing.Type["Model"], + _fields_set: typing.Optional[typing.Set[str]] = None, + **values: typing.Any, ) -> "Model": m = cls.__new__(cls) fields_values = {} @@ -68,7 +75,9 @@ def construct( # you should always use the NAME of the field to for field_values, etc. # because that's how the object is constructed from a pydantic perspective key = field.alias - if key is None or (key not in values and populate_by_name): # Added this to allow population by field name + if key is None or ( + key not in values and populate_by_name + ): # Added this to allow population by field name key = name if key in values: @@ -78,7 +87,9 @@ def construct( type_ = typing.cast(typing.Type, field.outer_type_) # type: ignore # Pydantic < v1.10.15 fields_values[name] = ( - construct_type(object_=values[key], type_=type_) if type_ is not None else values[key] + construct_type(object_=values[key], type_=type_) + if type_ is not None + else values[key] ) _fields_set.add(name) else: @@ -114,14 +125,18 @@ def construct( return m -def _convert_undiscriminated_union_type(union_type: typing.Type[typing.Any], object_: typing.Any) -> typing.Any: +def _convert_undiscriminated_union_type( + union_type: typing.Type[typing.Any], object_: typing.Any +) -> typing.Any: inner_types = get_args(union_type) if typing.Any in inner_types: return object_ for inner_type in inner_types: try: - if inspect.isclass(inner_type) and issubclass(inner_type, pydantic.BaseModel): + if inspect.isclass(inner_type) and issubclass( + inner_type, pydantic.BaseModel + ): # Attempt a validated parse until one works return parse_obj_as(inner_type, object_) except Exception: @@ -135,7 +150,9 @@ def _convert_undiscriminated_union_type(union_type: typing.Type[typing.Any], obj continue -def _convert_union_type(type_: typing.Type[typing.Any], object_: typing.Any) -> typing.Any: +def _convert_union_type( + type_: typing.Type[typing.Any], object_: typing.Any +) -> typing.Any: base_type = get_origin(type_) or type_ union_type = type_ if base_type == typing_extensions.Annotated: @@ -147,10 +164,15 @@ def _convert_union_type(type_: typing.Type[typing.Any], object_: typing.Any) -> # Cast to the correct type, based on the discriminant for inner_type in get_args(union_type): try: - objects_discriminant = getattr(object_, metadata.discriminant) + objects_discriminant = getattr( + object_, metadata.discriminant + ) except: objects_discriminant = object_[metadata.discriminant] - if inner_type.__fields__[metadata.discriminant].default == objects_discriminant: + if ( + inner_type.__fields__[metadata.discriminant].default + == objects_discriminant + ): return construct_type(object_=object_, type_=inner_type) except Exception: # Allow to fall through to our regular union handling @@ -158,7 +180,9 @@ def _convert_union_type(type_: typing.Type[typing.Any], object_: typing.Any) -> return _convert_undiscriminated_union_type(union_type, object_) -def construct_type(*, type_: typing.Type[typing.Any], object_: typing.Any) -> typing.Any: +def construct_type( + *, type_: typing.Type[typing.Any], object_: typing.Any +) -> typing.Any: """ Here we are essentially creating the same `construct` method in spirit as the above, but for all types, not just Pydantic models. @@ -171,7 +195,9 @@ def construct_type(*, type_: typing.Type[typing.Any], object_: typing.Any) -> ty base_type = get_origin(type_) or type_ is_annotated = base_type == typing_extensions.Annotated maybe_annotation_members = get_args(type_) - is_annotated_union = is_annotated and is_union(get_origin(maybe_annotation_members[0])) + is_annotated_union = is_annotated and is_union( + get_origin(maybe_annotation_members[0]) + ) if base_type == typing.Any: return object_ @@ -182,7 +208,9 @@ def construct_type(*, type_: typing.Type[typing.Any], object_: typing.Any) -> ty key_type, items_type = get_args(type_) d = { - construct_type(object_=key, type_=key_type): construct_type(object_=item, type_=items_type) + construct_type(object_=key, type_=key_type): construct_type( + object_=item, type_=items_type + ) for key, item in object_.items() } return d @@ -263,7 +291,9 @@ def _get_is_populate_by_name(model: typing.Type["Model"]) -> bool: # Pydantic V1 swapped the typing of __fields__'s values from ModelField to FieldInfo # And so we try to handle both V1 cases, as well as V2 (FieldInfo from model.model_fields) -def _get_model_fields(model: typing.Type["Model"]) -> typing.Mapping[str, PydanticField]: +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: if IS_PYDANTIC_V2: return model.model_fields # type: ignore # Pydantic v2 else: diff --git a/generators/python/tests/utils/example_models/types/resources/types/circle.py b/generators/python/tests/utils/example_models/types/resources/types/circle.py index 28095b84b0e..c458d166125 100644 --- a/generators/python/tests/utils/example_models/types/resources/types/circle.py +++ b/generators/python/tests/utils/example_models/types/resources/types/circle.py @@ -1,18 +1,18 @@ # This file was auto-generated by Fern from our API Definition. +from ...core.unchecked_base_model import UncheckedBaseModel +from ...core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.unchecked_base_model import UncheckedBaseModel - class Circle(UncheckedBaseModel): radius: float if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow" + ) # type: ignore # Pydantic v2 else: class Config: diff --git a/generators/python/tests/utils/example_models/types/resources/types/object_with_defaults.py b/generators/python/tests/utils/example_models/types/resources/types/object_with_defaults.py index 0a59546a07c..085913b9c55 100644 --- a/generators/python/tests/utils/example_models/types/resources/types/object_with_defaults.py +++ b/generators/python/tests/utils/example_models/types/resources/types/object_with_defaults.py @@ -1,11 +1,9 @@ # This file was auto-generated by Fern from our API Definition. +from ...core.unchecked_base_model import UncheckedBaseModel import typing - -import pydantic - from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.unchecked_base_model import UncheckedBaseModel +import pydantic class ObjectWithDefaults(UncheckedBaseModel): @@ -18,7 +16,9 @@ class ObjectWithDefaults(UncheckedBaseModel): required_string: str = "I neeeeeeeeeed this!" if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow" + ) # type: ignore # Pydantic v2 else: class Config: diff --git a/generators/python/tests/utils/example_models/types/resources/types/object_with_optional_field.py b/generators/python/tests/utils/example_models/types/resources/types/object_with_optional_field.py index a06ad184dda..6c825671518 100644 --- a/generators/python/tests/utils/example_models/types/resources/types/object_with_optional_field.py +++ b/generators/python/tests/utils/example_models/types/resources/types/object_with_optional_field.py @@ -1,16 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.unchecked_base_model import UncheckedBaseModel import typing -import uuid - import pydantic - -from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.unchecked_base_model import UncheckedBaseModel +import datetime as dt +import uuid from .color import Color from .shape import Shape from .undiscriminated_shape import UndiscriminatedShape +from ...core.pydantic_utilities import IS_PYDANTIC_V2 class ObjectWithOptionalField(UncheckedBaseModel): @@ -24,17 +22,23 @@ class ObjectWithOptionalField(UncheckedBaseModel): date: typing.Optional[dt.date] = None uuid_: typing.Optional[uuid.UUID] = pydantic.Field(alias="uuid", default=None) base_64: typing.Optional[str] = pydantic.Field(alias="base64", default=None) - list_: typing.Optional[typing.List[str]] = pydantic.Field(alias="list", default=None) + list_: typing.Optional[typing.List[str]] = pydantic.Field( + alias="list", default=None + ) set_: typing.Optional[typing.Set[str]] = pydantic.Field(alias="set", default=None) - map_: typing.Optional[typing.Dict[int, str]] = pydantic.Field(alias="map", default=None) + map_: typing.Optional[typing.Dict[int, str]] = pydantic.Field( + alias="map", default=None + ) enum: typing.Optional[Color] = None union: typing.Optional[Shape] = None second_union: typing.Optional[Shape] = None undiscriminated_union: typing.Optional[UndiscriminatedShape] = None - any: typing.Any + any: typing.Optional[typing.Any] = None if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow" + ) # type: ignore # Pydantic v2 else: class Config: diff --git a/generators/python/tests/utils/example_models/types/resources/types/shape.py b/generators/python/tests/utils/example_models/types/resources/types/shape.py index f80a90eb153..e4eceaa842b 100644 --- a/generators/python/tests/utils/example_models/types/resources/types/shape.py +++ b/generators/python/tests/utils/example_models/types/resources/types/shape.py @@ -1,21 +1,21 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - +from ...core.unchecked_base_model import UncheckedBaseModel +from ...core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic import typing_extensions - -from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from ...core.unchecked_base_model import UnionMetadata class Base(UncheckedBaseModel): id: str if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow" + ) # type: ignore # Pydantic v2 else: class Config: @@ -27,7 +27,9 @@ class Shape_Circle(Base): radius: float if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow" + ) # type: ignore # Pydantic v2 else: class Config: @@ -39,11 +41,15 @@ class Shape_Square(Base): length: float if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow" + ) # type: ignore # Pydantic v2 else: class Config: extra = pydantic.Extra.allow -Shape = typing_extensions.Annotated[typing.Union[Shape_Circle, Shape_Square], UnionMetadata(discriminant="type")] +Shape = typing_extensions.Annotated[ + typing.Union[Shape_Circle, Shape_Square], UnionMetadata(discriminant="type") +] diff --git a/generators/python/tests/utils/example_models/types/resources/types/square.py b/generators/python/tests/utils/example_models/types/resources/types/square.py index 1ad1d91d3b8..4c7bddd393a 100644 --- a/generators/python/tests/utils/example_models/types/resources/types/square.py +++ b/generators/python/tests/utils/example_models/types/resources/types/square.py @@ -1,18 +1,18 @@ # This file was auto-generated by Fern from our API Definition. +from ...core.unchecked_base_model import UncheckedBaseModel +from ...core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic -from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.unchecked_base_model import UncheckedBaseModel - class Square(UncheckedBaseModel): length: float if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow" + ) # type: ignore # Pydantic v2 else: class Config: diff --git a/generators/python/tests/utils/example_models/types/resources/types/undiscriminated_shape.py b/generators/python/tests/utils/example_models/types/resources/types/undiscriminated_shape.py index 82a56066afe..a9f0da583a0 100644 --- a/generators/python/tests/utils/example_models/types/resources/types/undiscriminated_shape.py +++ b/generators/python/tests/utils/example_models/types/resources/types/undiscriminated_shape.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import Circle from .square import Square diff --git a/generators/python/tests/utils/test_unset.py b/generators/python/tests/utils/test_unset.py index f8fe991a18d..4d8cdab84ac 100644 --- a/generators/python/tests/utils/test_unset.py +++ b/generators/python/tests/utils/test_unset.py @@ -12,3 +12,8 @@ def test_unset() -> None: so = SomeObject(name="John", age=30) assert so.dict() == {"name": "John", "age": 30, "city": "NY"} assert so.dict(exclude_unset=True) == {"name": "John", "age": 30, "city": "NY"} + +def test_unset_with_updates() -> None: + so = SomeObject(name="John", age=30, city="Washington", optional="extra") + assert so.dict() == {"name": "John", "age": 30, "city": "Washington", "optional": "extra"} + assert so.dict(exclude_unset=True) == {"name": "John", "age": 30, "city": "Washington", "optional": "extra"} diff --git a/generators/python/tests/utils/typeddict_models/types/core/__init__.py b/generators/python/tests/utils/typeddict_models/types/core/__init__.py index 29f1c168c81..959cce2fde0 100644 --- a/generators/python/tests/utils/typeddict_models/types/core/__init__.py +++ b/generators/python/tests/utils/typeddict_models/types/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -22,7 +21,6 @@ "UniversalBaseModel", "UniversalRootModel", "construct_type", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/generators/python/tests/utils/typeddict_models/types/core/datetime_utils.py b/generators/python/tests/utils/typeddict_models/types/core/datetime_utils.py index 7c9864a944c..47344e9d9cc 100644 --- a/generators/python/tests/utils/typeddict_models/types/core/datetime_utils.py +++ b/generators/python/tests/utils/typeddict_models/types/core/datetime_utils.py @@ -13,7 +13,9 @@ def serialize_datetime(v: dt.datetime) -> str: """ def _serialize_zoned_datetime(v: dt.datetime) -> str: - if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname(None): + if v.tzinfo is not None and v.tzinfo.tzname(None) == dt.timezone.utc.tzname( + None + ): # UTC is a special case where we use "Z" at the end instead of "+00:00" return v.isoformat().replace("+00:00", "Z") else: diff --git a/generators/python/tests/utils/typeddict_models/types/core/pydantic_utilities.py b/generators/python/tests/utils/typeddict_models/types/core/pydantic_utilities.py index 203567d199c..142f9ee8db8 100644 --- a/generators/python/tests/utils/typeddict_models/types/core/pydantic_utilities.py +++ b/generators/python/tests/utils/typeddict_models/types/core/pydantic_utilities.py @@ -1,10 +1,13 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing from collections import defaultdict -from functools import wraps + +import typing_extensions import pydantic @@ -27,11 +30,15 @@ from pydantic.v1.typing import ( # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2 get_args as get_args, ) - from pydantic.v1.typing import get_origin as get_origin # pyright: ignore[reportMissingImports] # Pydantic v2 + from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2 + get_origin as get_origin, + ) from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2 is_literal_type as is_literal_type, ) - from pydantic.v1.typing import is_union as is_union # pyright: ignore[reportMissingImports] # Pydantic v2 + from pydantic.v1.typing import ( # pyright: ignore[reportMissingImports] # Pydantic v2 + is_union as is_union, + ) from pydantic.v1.fields import ModelField as ModelField # type: ignore # pyright: ignore[reportMissingImports] # Pydantic v2 else: from pydantic.datetime_parse import parse_date as parse_date # type: ignore # Pydantic v1 @@ -50,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -90,36 +84,55 @@ class Config: json_encoders = {dt.datetime: serialize_datetime} def json(self, **kwargs: typing.Any) -> str: - kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults: typing.Any = { + "by_alias": True, + "exclude_unset": True, + **kwargs, + } if IS_PYDANTIC_V2: return super().model_dump_json(**kwargs_with_defaults) # type: ignore # Pydantic v2 else: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} - kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + + kwargs_with_defaults_exclude_unset: typing.Any = { + "by_alias": True, + "exclude_unset": True, + "include": _fields_set, + **kwargs, + } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) - ) + return super().dict(**kwargs_with_defaults_exclude_unset) -UniversalRootModel: typing.Type[typing.Any] if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 pass - UniversalRootModel = V2RootModel + UniversalRootModel: typing_extensions.TypeAlias = V2RootModel # type: ignore else: - UniversalRootModel = UniversalBaseModel + UniversalRootModel: typing_extensions.TypeAlias = UniversalBaseModel # type: ignore def encode_by_type(o: typing.Any) -> typing.Any: @@ -136,44 +149,64 @@ def encode_by_type(o: typing.Any) -> typing.Any: return encoder(o) -def update_forward_refs(model: typing.Type["Model"], **localns: typing.Any) -> None: +def update_forward_refs(model: typing.Type["Model"]) -> None: if IS_PYDANTIC_V2: - model.model_rebuild(force=True, raise_errors=False) # type: ignore # Pydantic v2 + model.model_rebuild(raise_errors=False) # type: ignore # Pydantic v2 else: - model.update_forward_refs(**localns) + model.update_forward_refs() # Mirrors Pydantic's internal typing AnyCallable = typing.Callable[..., typing.Any] -def universal_root_validator(pre: bool = False) -> typing.Callable[[AnyCallable], AnyCallable]: +def universal_root_validator( + pre: bool = False, +) -> typing.Callable[[AnyCallable], AnyCallable]: def decorator(func: AnyCallable) -> AnyCallable: - @wraps(func) - def validate(*args: typing.Any, **kwargs: typing.Any) -> AnyCallable: - if IS_PYDANTIC_V2: - wrapped_func = pydantic.model_validator("before" if pre else "after")(func) # type: ignore # Pydantic v2 - else: - wrapped_func = pydantic.root_validator(pre=pre)(func) # type: ignore # Pydantic v1 + if IS_PYDANTIC_V2: + return pydantic.model_validator(mode="before" if pre else "after")(func) # type: ignore # Pydantic v2 + else: + return pydantic.root_validator(pre=pre)(func) # type: ignore # Pydantic v1 + + return decorator - return wrapped_func(*args, **kwargs) - return validate +def universal_field_validator( + field_name: str, pre: bool = False +) -> typing.Callable[[AnyCallable], AnyCallable]: + def decorator(func: AnyCallable) -> AnyCallable: + if IS_PYDANTIC_V2: + return pydantic.field_validator( + field_name, mode="before" if pre else "after" + )(func) # type: ignore # Pydantic v2 + else: + return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator -def universal_field_validator(field_name: str, pre: bool = False) -> typing.Callable[[AnyCallable], AnyCallable]: - def decorator(func: AnyCallable) -> AnyCallable: - @wraps(func) - def validate(*args: typing.Any, **kwargs: typing.Any) -> AnyCallable: - if IS_PYDANTIC_V2: - wrapped_func = pydantic.field_validator(field_name, mode="before" if pre else "after")(func) # type: ignore # Pydantic v2 - else: - wrapped_func = pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - return wrapped_func(*args, **kwargs) - return validate +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 - return decorator + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/generators/python/tests/utils/typeddict_models/types/core/serialization.py b/generators/python/tests/utils/typeddict_models/types/core/serialization.py index 8ad5cf8125f..5400ca0bc3b 100644 --- a/generators/python/tests/utils/typeddict_models/types/core/serialization.py +++ b/generators/python/tests/utils/typeddict_models/types/core/serialization.py @@ -25,7 +25,10 @@ def __init__(self, *, alias: str) -> None: def convert_and_respect_annotation_metadata( - *, object_: typing.Any, annotation: typing.Any, inner_type: typing.Optional[typing.Any] = None + *, + object_: typing.Any, + annotation: typing.Any, + inner_type: typing.Optional[typing.Any] = None, ) -> typing.Any: """ Respect the metadata annotations on a field, such as aliasing. This function effectively @@ -53,7 +56,9 @@ def convert_and_respect_annotation_metadata( inner_type = annotation clean_type = _remove_annotations(inner_type) - if typing_extensions.is_typeddict(clean_type) and isinstance(object_, typing.Mapping): + if typing_extensions.is_typeddict(clean_type) and isinstance( + object_, typing.Mapping + ): return _convert_typeddict(object_, clean_type) if ( @@ -79,7 +84,8 @@ def convert_and_respect_annotation_metadata( or ( ( typing_extensions.get_origin(clean_type) == typing.Sequence - or typing_extensions.get_origin(clean_type) == collections.abc.Sequence + or typing_extensions.get_origin(clean_type) + == collections.abc.Sequence or clean_type == typing.Sequence ) and isinstance(object_, typing.Sequence) @@ -88,7 +94,9 @@ def convert_and_respect_annotation_metadata( ): inner_type = typing_extensions.get_args(clean_type)[0] return [ - convert_and_respect_annotation_metadata(object_=item, annotation=annotation, inner_type=inner_type) + convert_and_respect_annotation_metadata( + object_=item, annotation=annotation, inner_type=inner_type + ) for item in object_ ] @@ -98,7 +106,9 @@ def convert_and_respect_annotation_metadata( # of the same name to a different name from another member # Or if another member aliases a field of the same name that another member does not. for member in typing_extensions.get_args(clean_type): - object_ = convert_and_respect_annotation_metadata(object_=object_, annotation=annotation, inner_type=member) + object_ = convert_and_respect_annotation_metadata( + object_=object_, annotation=annotation, inner_type=member + ) return object_ annotated_type = _get_annotation(annotation) @@ -110,7 +120,9 @@ def convert_and_respect_annotation_metadata( return object_ -def _convert_typeddict(object_: typing.Mapping[str, object], expected_type: typing.Any) -> typing.Mapping[str, object]: +def _convert_typeddict( + object_: typing.Mapping[str, object], expected_type: typing.Any +) -> typing.Mapping[str, object]: converted_object: typing.Dict[str, object] = {} annotations = typing_extensions.get_type_hints(expected_type, include_extras=True) for key, value in object_.items(): @@ -118,8 +130,8 @@ def _convert_typeddict(object_: typing.Mapping[str, object], expected_type: typi if type_ is None: converted_object[key] = value else: - converted_object[_alias_key(key, type_)] = convert_and_respect_annotation_metadata( - object_=value, annotation=type_ + converted_object[_alias_key(key, type_)] = ( + convert_and_respect_annotation_metadata(object_=value, annotation=type_) ) return converted_object diff --git a/generators/python/tests/utils/typeddict_models/types/core/unchecked_base_model.py b/generators/python/tests/utils/typeddict_models/types/core/unchecked_base_model.py index 401cc513bd1..c5e3ed36f22 100644 --- a/generators/python/tests/utils/typeddict_models/types/core/unchecked_base_model.py +++ b/generators/python/tests/utils/typeddict_models/types/core/unchecked_base_model.py @@ -5,10 +5,11 @@ import typing import uuid -import pydantic import typing_extensions from pydantic_core import PydanticUndefined +import pydantic + from .pydantic_utilities import ( IS_PYDANTIC_V2, ModelField, @@ -35,7 +36,9 @@ def __init__(self, *, discriminant: str) -> None: class UncheckedBaseModel(UniversalBaseModel): if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow" + ) # type: ignore # Pydantic v2 else: class Config: @@ -43,7 +46,9 @@ class Config: @classmethod def model_construct( - cls: typing.Type["Model"], _fields_set: typing.Optional[typing.Set[str]] = None, **values: typing.Any + cls: typing.Type["Model"], + _fields_set: typing.Optional[typing.Set[str]] = None, + **values: typing.Any, ) -> "Model": # Fallback construct function to the specified override below. return cls.construct(_fields_set=_fields_set, **values) @@ -52,7 +57,9 @@ def model_construct( # Implementation taken from: https://github.com/pydantic/pydantic/issues/1168#issuecomment-817742836 @classmethod def construct( - cls: typing.Type["Model"], _fields_set: typing.Optional[typing.Set[str]] = None, **values: typing.Any + cls: typing.Type["Model"], + _fields_set: typing.Optional[typing.Set[str]] = None, + **values: typing.Any, ) -> "Model": m = cls.__new__(cls) fields_values = {} @@ -68,7 +75,9 @@ def construct( # you should always use the NAME of the field to for field_values, etc. # because that's how the object is constructed from a pydantic perspective key = field.alias - if key is None or (key not in values and populate_by_name): # Added this to allow population by field name + if key is None or ( + key not in values and populate_by_name + ): # Added this to allow population by field name key = name if key in values: @@ -78,7 +87,9 @@ def construct( type_ = typing.cast(typing.Type, field.outer_type_) # type: ignore # Pydantic < v1.10.15 fields_values[name] = ( - construct_type(object_=values[key], type_=type_) if type_ is not None else values[key] + construct_type(object_=values[key], type_=type_) + if type_ is not None + else values[key] ) _fields_set.add(name) else: @@ -114,14 +125,18 @@ def construct( return m -def _convert_undiscriminated_union_type(union_type: typing.Type[typing.Any], object_: typing.Any) -> typing.Any: +def _convert_undiscriminated_union_type( + union_type: typing.Type[typing.Any], object_: typing.Any +) -> typing.Any: inner_types = get_args(union_type) if typing.Any in inner_types: return object_ for inner_type in inner_types: try: - if inspect.isclass(inner_type) and issubclass(inner_type, pydantic.BaseModel): + if inspect.isclass(inner_type) and issubclass( + inner_type, pydantic.BaseModel + ): # Attempt a validated parse until one works return parse_obj_as(inner_type, object_) except Exception: @@ -135,7 +150,9 @@ def _convert_undiscriminated_union_type(union_type: typing.Type[typing.Any], obj continue -def _convert_union_type(type_: typing.Type[typing.Any], object_: typing.Any) -> typing.Any: +def _convert_union_type( + type_: typing.Type[typing.Any], object_: typing.Any +) -> typing.Any: base_type = get_origin(type_) or type_ union_type = type_ if base_type == typing_extensions.Annotated: @@ -147,10 +164,15 @@ def _convert_union_type(type_: typing.Type[typing.Any], object_: typing.Any) -> # Cast to the correct type, based on the discriminant for inner_type in get_args(union_type): try: - objects_discriminant = getattr(object_, metadata.discriminant) + objects_discriminant = getattr( + object_, metadata.discriminant + ) except: objects_discriminant = object_[metadata.discriminant] - if inner_type.__fields__[metadata.discriminant].default == objects_discriminant: + if ( + inner_type.__fields__[metadata.discriminant].default + == objects_discriminant + ): return construct_type(object_=object_, type_=inner_type) except Exception: # Allow to fall through to our regular union handling @@ -158,7 +180,9 @@ def _convert_union_type(type_: typing.Type[typing.Any], object_: typing.Any) -> return _convert_undiscriminated_union_type(union_type, object_) -def construct_type(*, type_: typing.Type[typing.Any], object_: typing.Any) -> typing.Any: +def construct_type( + *, type_: typing.Type[typing.Any], object_: typing.Any +) -> typing.Any: """ Here we are essentially creating the same `construct` method in spirit as the above, but for all types, not just Pydantic models. @@ -171,7 +195,9 @@ def construct_type(*, type_: typing.Type[typing.Any], object_: typing.Any) -> ty base_type = get_origin(type_) or type_ is_annotated = base_type == typing_extensions.Annotated maybe_annotation_members = get_args(type_) - is_annotated_union = is_annotated and is_union(get_origin(maybe_annotation_members[0])) + is_annotated_union = is_annotated and is_union( + get_origin(maybe_annotation_members[0]) + ) if base_type == typing.Any: return object_ @@ -182,7 +208,9 @@ def construct_type(*, type_: typing.Type[typing.Any], object_: typing.Any) -> ty key_type, items_type = get_args(type_) d = { - construct_type(object_=key, type_=key_type): construct_type(object_=item, type_=items_type) + construct_type(object_=key, type_=key_type): construct_type( + object_=item, type_=items_type + ) for key, item in object_.items() } return d @@ -263,7 +291,9 @@ def _get_is_populate_by_name(model: typing.Type["Model"]) -> bool: # Pydantic V1 swapped the typing of __fields__'s values from ModelField to FieldInfo # And so we try to handle both V1 cases, as well as V2 (FieldInfo from model.model_fields) -def _get_model_fields(model: typing.Type["Model"]) -> typing.Mapping[str, PydanticField]: +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: if IS_PYDANTIC_V2: return model.model_fields # type: ignore # Pydantic v2 else: diff --git a/generators/python/tests/utils/typeddict_models/types/resources/types/circle.py b/generators/python/tests/utils/typeddict_models/types/resources/types/circle.py index 6e01c6088eb..cc0db0e4827 100644 --- a/generators/python/tests/utils/typeddict_models/types/resources/types/circle.py +++ b/generators/python/tests/utils/typeddict_models/types/resources/types/circle.py @@ -1,18 +1,18 @@ # This file was auto-generated by Fern from our API Definition. -import typing - +from ...core.unchecked_base_model import UncheckedBaseModel import pydantic - from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.unchecked_base_model import UncheckedBaseModel +import typing class Circle(UncheckedBaseModel): radius_measurement: float = pydantic.Field(alias="radiusMeasurement") if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow" + ) # type: ignore # Pydantic v2 else: class Config: diff --git a/generators/python/tests/utils/typeddict_models/types/resources/types/object_with_defaults.py b/generators/python/tests/utils/typeddict_models/types/resources/types/object_with_defaults.py index 0a59546a07c..085913b9c55 100644 --- a/generators/python/tests/utils/typeddict_models/types/resources/types/object_with_defaults.py +++ b/generators/python/tests/utils/typeddict_models/types/resources/types/object_with_defaults.py @@ -1,11 +1,9 @@ # This file was auto-generated by Fern from our API Definition. +from ...core.unchecked_base_model import UncheckedBaseModel import typing - -import pydantic - from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.unchecked_base_model import UncheckedBaseModel +import pydantic class ObjectWithDefaults(UncheckedBaseModel): @@ -18,7 +16,9 @@ class ObjectWithDefaults(UncheckedBaseModel): required_string: str = "I neeeeeeeeeed this!" if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow" + ) # type: ignore # Pydantic v2 else: class Config: diff --git a/generators/python/tests/utils/typeddict_models/types/resources/types/object_with_optional_field.py b/generators/python/tests/utils/typeddict_models/types/resources/types/object_with_optional_field.py index a06ad184dda..6c825671518 100644 --- a/generators/python/tests/utils/typeddict_models/types/resources/types/object_with_optional_field.py +++ b/generators/python/tests/utils/typeddict_models/types/resources/types/object_with_optional_field.py @@ -1,16 +1,14 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +from ...core.unchecked_base_model import UncheckedBaseModel import typing -import uuid - import pydantic - -from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.unchecked_base_model import UncheckedBaseModel +import datetime as dt +import uuid from .color import Color from .shape import Shape from .undiscriminated_shape import UndiscriminatedShape +from ...core.pydantic_utilities import IS_PYDANTIC_V2 class ObjectWithOptionalField(UncheckedBaseModel): @@ -24,17 +22,23 @@ class ObjectWithOptionalField(UncheckedBaseModel): date: typing.Optional[dt.date] = None uuid_: typing.Optional[uuid.UUID] = pydantic.Field(alias="uuid", default=None) base_64: typing.Optional[str] = pydantic.Field(alias="base64", default=None) - list_: typing.Optional[typing.List[str]] = pydantic.Field(alias="list", default=None) + list_: typing.Optional[typing.List[str]] = pydantic.Field( + alias="list", default=None + ) set_: typing.Optional[typing.Set[str]] = pydantic.Field(alias="set", default=None) - map_: typing.Optional[typing.Dict[int, str]] = pydantic.Field(alias="map", default=None) + map_: typing.Optional[typing.Dict[int, str]] = pydantic.Field( + alias="map", default=None + ) enum: typing.Optional[Color] = None union: typing.Optional[Shape] = None second_union: typing.Optional[Shape] = None undiscriminated_union: typing.Optional[UndiscriminatedShape] = None - any: typing.Any + any: typing.Optional[typing.Any] = None if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow" + ) # type: ignore # Pydantic v2 else: class Config: diff --git a/generators/python/tests/utils/typeddict_models/types/resources/types/requests/circle.py b/generators/python/tests/utils/typeddict_models/types/resources/types/requests/circle.py index 32be504e636..309d80a5d5c 100644 --- a/generators/python/tests/utils/typeddict_models/types/resources/types/requests/circle.py +++ b/generators/python/tests/utils/typeddict_models/types/resources/types/requests/circle.py @@ -1,9 +1,11 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from ....core.serialization import FieldMetadata class CircleParams(typing_extensions.TypedDict): - radius_measurement: typing_extensions.Annotated[float, FieldMetadata(alias="radiusMeasurement")] + radius_measurement: typing_extensions.Annotated[ + float, FieldMetadata(alias="radiusMeasurement") + ] diff --git a/generators/python/tests/utils/typeddict_models/types/resources/types/requests/object_with_defaults.py b/generators/python/tests/utils/typeddict_models/types/resources/types/requests/object_with_defaults.py index 304c9f6177e..b0016d2929b 100644 --- a/generators/python/tests/utils/typeddict_models/types/resources/types/requests/object_with_defaults.py +++ b/generators/python/tests/utils/typeddict_models/types/resources/types/requests/object_with_defaults.py @@ -1,6 +1,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/generators/python/tests/utils/typeddict_models/types/resources/types/requests/object_with_optional_field.py b/generators/python/tests/utils/typeddict_models/types/resources/types/requests/object_with_optional_field.py index 8c0c9589f10..2b32c5d61ea 100644 --- a/generators/python/tests/utils/typeddict_models/types/resources/types/requests/object_with_optional_field.py +++ b/generators/python/tests/utils/typeddict_models/types/resources/types/requests/object_with_optional_field.py @@ -1,12 +1,11 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from ....core.serialization import FieldMetadata +import datetime as dt +import uuid from ..color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -16,18 +15,32 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): literal: typing.Literal["lit_one"] string: typing_extensions.NotRequired[str] integer: typing_extensions.NotRequired[int] - long_: typing_extensions.NotRequired[typing_extensions.Annotated[int, FieldMetadata(alias="long")]] + long_: typing_extensions.NotRequired[ + typing_extensions.Annotated[int, FieldMetadata(alias="long")] + ] double: typing_extensions.NotRequired[float] - bool_: typing_extensions.NotRequired[typing_extensions.Annotated[bool, FieldMetadata(alias="bool")]] + bool_: typing_extensions.NotRequired[ + typing_extensions.Annotated[bool, FieldMetadata(alias="bool")] + ] datetime: typing_extensions.NotRequired[dt.datetime] date: typing_extensions.NotRequired[dt.date] - uuid_: typing_extensions.NotRequired[typing_extensions.Annotated[uuid.UUID, FieldMetadata(alias="uuid")]] - base_64: typing_extensions.NotRequired[typing_extensions.Annotated[str, FieldMetadata(alias="base64")]] - list_: typing_extensions.NotRequired[typing_extensions.Annotated[typing.Sequence[str], FieldMetadata(alias="list")]] - set_: typing_extensions.NotRequired[typing_extensions.Annotated[typing.Set[str], FieldMetadata(alias="set")]] - map_: typing_extensions.NotRequired[typing_extensions.Annotated[typing.Dict[int, str], FieldMetadata(alias="map")]] + uuid_: typing_extensions.NotRequired[ + typing_extensions.Annotated[uuid.UUID, FieldMetadata(alias="uuid")] + ] + base_64: typing_extensions.NotRequired[ + typing_extensions.Annotated[str, FieldMetadata(alias="base64")] + ] + list_: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Sequence[str], FieldMetadata(alias="list")] + ] + set_: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Set[str], FieldMetadata(alias="set")] + ] + map_: typing_extensions.NotRequired[ + typing_extensions.Annotated[typing.Dict[int, str], FieldMetadata(alias="map")] + ] enum: typing_extensions.NotRequired[Color] union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/generators/python/tests/utils/typeddict_models/types/resources/types/requests/shape.py b/generators/python/tests/utils/typeddict_models/types/resources/types/requests/shape.py index e4e476a9126..b59f5020acb 100644 --- a/generators/python/tests/utils/typeddict_models/types/resources/types/requests/shape.py +++ b/generators/python/tests/utils/typeddict_models/types/resources/types/requests/shape.py @@ -1,11 +1,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from ....core.serialization import FieldMetadata @@ -14,13 +12,21 @@ class Base(typing_extensions.TypedDict): class Shape_CircleParams(Base): - shape_type: typing_extensions.Annotated[typing.Literal["circle"], FieldMetadata(alias="shapeType")] - radius_measurement: typing_extensions.Annotated[float, FieldMetadata(alias="radiusMeasurement")] + shape_type: typing_extensions.Annotated[ + typing.Literal["circle"], FieldMetadata(alias="shapeType") + ] + radius_measurement: typing_extensions.Annotated[ + float, FieldMetadata(alias="radiusMeasurement") + ] class Shape_SquareParams(Base): - shape_type: typing_extensions.Annotated[typing.Literal["square"], FieldMetadata(alias="shapeType")] - length_measurement: typing_extensions.Annotated[float, FieldMetadata(alias="lengthMeasurement")] + shape_type: typing_extensions.Annotated[ + typing.Literal["square"], FieldMetadata(alias="shapeType") + ] + length_measurement: typing_extensions.Annotated[ + float, FieldMetadata(alias="lengthMeasurement") + ] ShapeParams = typing.Union[Shape_CircleParams, Shape_SquareParams] diff --git a/generators/python/tests/utils/typeddict_models/types/resources/types/requests/square.py b/generators/python/tests/utils/typeddict_models/types/resources/types/requests/square.py index 1f95b1c8b6f..1e9c6bcad2e 100644 --- a/generators/python/tests/utils/typeddict_models/types/resources/types/requests/square.py +++ b/generators/python/tests/utils/typeddict_models/types/resources/types/requests/square.py @@ -1,9 +1,11 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from ....core.serialization import FieldMetadata class SquareParams(typing_extensions.TypedDict): - length_measurement: typing_extensions.Annotated[float, FieldMetadata(alias="lengthMeasurement")] + length_measurement: typing_extensions.Annotated[ + float, FieldMetadata(alias="lengthMeasurement") + ] diff --git a/generators/python/tests/utils/typeddict_models/types/resources/types/requests/undiscriminated_shape.py b/generators/python/tests/utils/typeddict_models/types/resources/types/requests/undiscriminated_shape.py index e61e343ab1b..3ca2e4d76bb 100644 --- a/generators/python/tests/utils/typeddict_models/types/resources/types/requests/undiscriminated_shape.py +++ b/generators/python/tests/utils/typeddict_models/types/resources/types/requests/undiscriminated_shape.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/generators/python/tests/utils/typeddict_models/types/resources/types/shape.py b/generators/python/tests/utils/typeddict_models/types/resources/types/shape.py index 7eed13b1831..9515f0a930a 100644 --- a/generators/python/tests/utils/typeddict_models/types/resources/types/shape.py +++ b/generators/python/tests/utils/typeddict_models/types/resources/types/shape.py @@ -1,21 +1,21 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - +from ...core.unchecked_base_model import UncheckedBaseModel +from ...core.pydantic_utilities import IS_PYDANTIC_V2 import typing - import pydantic import typing_extensions - -from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.unchecked_base_model import UncheckedBaseModel, UnionMetadata +from ...core.unchecked_base_model import UnionMetadata class Base(UncheckedBaseModel): id: str if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow" + ) # type: ignore # Pydantic v2 else: class Config: @@ -23,11 +23,15 @@ class Config: class Shape_Circle(Base): - shape_type: typing.Literal["circle"] = pydantic.Field(alias="shapeType", default="circle") + shape_type: typing.Literal["circle"] = pydantic.Field( + alias="shapeType", default="circle" + ) radius_measurement: float = pydantic.Field(alias="radiusMeasurement") if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow" + ) # type: ignore # Pydantic v2 else: class Config: @@ -35,15 +39,21 @@ class Config: class Shape_Square(Base): - shape_type: typing.Literal["square"] = pydantic.Field(alias="shapeType", default="square") + shape_type: typing.Literal["square"] = pydantic.Field( + alias="shapeType", default="square" + ) length_measurement: float = pydantic.Field(alias="lengthMeasurement") if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow" + ) # type: ignore # Pydantic v2 else: class Config: extra = pydantic.Extra.allow -Shape = typing_extensions.Annotated[typing.Union[Shape_Circle, Shape_Square], UnionMetadata(discriminant="shapeType")] +Shape = typing_extensions.Annotated[ + typing.Union[Shape_Circle, Shape_Square], UnionMetadata(discriminant="shapeType") +] diff --git a/generators/python/tests/utils/typeddict_models/types/resources/types/square.py b/generators/python/tests/utils/typeddict_models/types/resources/types/square.py index e8a4cc61647..c6bd65544fd 100644 --- a/generators/python/tests/utils/typeddict_models/types/resources/types/square.py +++ b/generators/python/tests/utils/typeddict_models/types/resources/types/square.py @@ -1,18 +1,18 @@ # This file was auto-generated by Fern from our API Definition. -import typing - +from ...core.unchecked_base_model import UncheckedBaseModel import pydantic - from ...core.pydantic_utilities import IS_PYDANTIC_V2 -from ...core.unchecked_base_model import UncheckedBaseModel +import typing class Square(UncheckedBaseModel): length_measurement: float = pydantic.Field(alias="lengthMeasurement") if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow") # type: ignore # Pydantic v2 + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + extra="allow" + ) # type: ignore # Pydantic v2 else: class Config: diff --git a/generators/python/tests/utils/typeddict_models/types/resources/types/undiscriminated_shape.py b/generators/python/tests/utils/typeddict_models/types/resources/types/undiscriminated_shape.py index 82a56066afe..a9f0da583a0 100644 --- a/generators/python/tests/utils/typeddict_models/types/resources/types/undiscriminated_shape.py +++ b/generators/python/tests/utils/typeddict_models/types/resources/types/undiscriminated_shape.py @@ -1,7 +1,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import Circle from .square import Square diff --git a/generators/python/tests/utils/union_utils/2.0 b/generators/python/tests/utils/union_utils/2.0 deleted file mode 100644 index 158cb0a84bb..00000000000 --- a/generators/python/tests/utils/union_utils/2.0 +++ /dev/null @@ -1,8 +0,0 @@ -The following packages are already present in the pyproject.toml and will be skipped: - - - pydantic - -If you want to update it to the latest compatible version, you can use `poetry update package`. -If you prefer to upgrade it to the latest available version, you can use `poetry add package@latest`. - -Nothing to add. diff --git a/generators/python/tests/utils/union_utils/fern/generators.yml b/generators/python/tests/utils/union_utils/fern/generators.yml index 37ff3db6aee..970fa0af75c 100644 --- a/generators/python/tests/utils/union_utils/fern/generators.yml +++ b/generators/python/tests/utils/union_utils/fern/generators.yml @@ -12,5 +12,3 @@ groups: skip_validation: true use_provided_defaults: true include_union_utils: true - wrapped_aliases: true - version: v1 diff --git a/generators/python/tests/utils/union_utils/types/__init__.py b/generators/python/tests/utils/union_utils/types/__init__.py index 7662fb533f2..a9d867fbade 100644 --- a/generators/python/tests/utils/union_utils/types/__init__.py +++ b/generators/python/tests/utils/union_utils/types/__init__.py @@ -1,13 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -from .resources import Circle, Color, Name, Shape, Square, UndiscriminatedShape, types +from .resources import Circle, Color, Shape, Square, UndiscriminatedShape, types -__all__ = [ - "Circle", - "Color", - "Name", - "Shape", - "Square", - "UndiscriminatedShape", - "types", -] +__all__ = ["Circle", "Color", "Shape", "Square", "UndiscriminatedShape", "types"] diff --git a/generators/python/tests/utils/union_utils/types/core/__init__.py b/generators/python/tests/utils/union_utils/types/core/__init__.py index 29f1c168c81..959cce2fde0 100644 --- a/generators/python/tests/utils/union_utils/types/core/__init__.py +++ b/generators/python/tests/utils/union_utils/types/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -22,7 +21,6 @@ "UniversalBaseModel", "UniversalRootModel", "construct_type", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/generators/python/tests/utils/union_utils/types/core/pydantic_utilities.py b/generators/python/tests/utils/union_utils/types/core/pydantic_utilities.py index b6dc264ae70..142f9ee8db8 100644 --- a/generators/python/tests/utils/union_utils/types/core/pydantic_utilities.py +++ b/generators/python/tests/utils/union_utils/types/core/pydantic_utilities.py @@ -1,8 +1,9 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt -from tkinter import E import typing from collections import defaultdict @@ -56,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -107,9 +95,14 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) - for name, field in fields.items(): + for name, field in fields.items(): if field not in _fields_set: default = _get_field_default(field) @@ -127,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) @@ -192,8 +185,10 @@ def decorator(func: AnyCallable) -> AnyCallable: return decorator + PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + def _get_model_fields( model: typing.Type["Model"], ) -> typing.Mapping[str, PydanticField]: diff --git a/generators/python/tests/utils/union_utils/types/resources/__init__.py b/generators/python/tests/utils/union_utils/types/resources/__init__.py index 3dbedd06283..1b80ffa3927 100644 --- a/generators/python/tests/utils/union_utils/types/resources/__init__.py +++ b/generators/python/tests/utils/union_utils/types/resources/__init__.py @@ -1,14 +1,6 @@ # This file was auto-generated by Fern from our API Definition. from . import types -from .types import Circle, Color, Name, Shape, Square, UndiscriminatedShape +from .types import Circle, Color, Shape, Square, UndiscriminatedShape -__all__ = [ - "Circle", - "Color", - "Name", - "Shape", - "Square", - "UndiscriminatedShape", - "types", -] +__all__ = ["Circle", "Color", "Shape", "Square", "UndiscriminatedShape", "types"] diff --git a/generators/python/tests/utils/union_utils/types/resources/types/__init__.py b/generators/python/tests/utils/union_utils/types/resources/types/__init__.py index be22ee1e74d..926e6224242 100644 --- a/generators/python/tests/utils/union_utils/types/resources/types/__init__.py +++ b/generators/python/tests/utils/union_utils/types/resources/types/__init__.py @@ -2,9 +2,8 @@ from .circle import Circle from .color import Color -from .name import Name from .shape import Shape from .square import Square from .undiscriminated_shape import UndiscriminatedShape -__all__ = ["Circle", "Color", "Name", "Shape", "Square", "UndiscriminatedShape"] +__all__ = ["Circle", "Color", "Shape", "Square", "UndiscriminatedShape"] diff --git a/generators/python/tests/utils/union_utils/types/resources/types/name.py b/generators/python/tests/utils/union_utils/types/resources/types/name.py deleted file mode 100644 index fe2f7f8b0a7..00000000000 --- a/generators/python/tests/utils/union_utils/types/resources/types/name.py +++ /dev/null @@ -1,27 +0,0 @@ -# This file was auto-generated by Fern from our API Definition. - -from __future__ import annotations -from ...core.unchecked_base_model import UncheckedBaseModel -from ...core.pydantic_utilities import IS_PYDANTIC_V2 -import typing -import pydantic - - -class Name(UncheckedBaseModel): - __root__: str - - def get_as_str(self) -> str: - return self.__root__ - - @staticmethod - def from_str(value: str) -> Name: - return Name(__root__=value) - - if IS_PYDANTIC_V2: - model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( - extra="allow" - ) # type: ignore # Pydantic v2 - else: - - class Config: - extra = pydantic.Extra.allow diff --git a/seed/fastapi/alias-extends/core/__init__.py b/seed/fastapi/alias-extends/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/alias-extends/core/__init__.py +++ b/seed/fastapi/alias-extends/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/alias-extends/core/pydantic_utilities.py b/seed/fastapi/alias-extends/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/alias-extends/core/pydantic_utilities.py +++ b/seed/fastapi/alias-extends/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/alias/core/__init__.py b/seed/fastapi/alias/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/alias/core/__init__.py +++ b/seed/fastapi/alias/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/alias/core/pydantic_utilities.py b/seed/fastapi/alias/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/alias/core/pydantic_utilities.py +++ b/seed/fastapi/alias/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/api-wide-base-path/core/__init__.py b/seed/fastapi/api-wide-base-path/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/api-wide-base-path/core/__init__.py +++ b/seed/fastapi/api-wide-base-path/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py b/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py +++ b/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/audiences/core/__init__.py b/seed/fastapi/audiences/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/audiences/core/__init__.py +++ b/seed/fastapi/audiences/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/audiences/core/pydantic_utilities.py b/seed/fastapi/audiences/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/audiences/core/pydantic_utilities.py +++ b/seed/fastapi/audiences/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/auth-environment-variables/core/__init__.py b/seed/fastapi/auth-environment-variables/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/auth-environment-variables/core/__init__.py +++ b/seed/fastapi/auth-environment-variables/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py b/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/basic-auth-environment-variables/core/__init__.py b/seed/fastapi/basic-auth-environment-variables/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/basic-auth-environment-variables/core/__init__.py +++ b/seed/fastapi/basic-auth-environment-variables/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py b/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/basic-auth/core/__init__.py b/seed/fastapi/basic-auth/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/basic-auth/core/__init__.py +++ b/seed/fastapi/basic-auth/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/basic-auth/core/pydantic_utilities.py b/seed/fastapi/basic-auth/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/basic-auth/core/pydantic_utilities.py +++ b/seed/fastapi/basic-auth/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/bearer-token-environment-variable/core/__init__.py b/seed/fastapi/bearer-token-environment-variable/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/bearer-token-environment-variable/core/__init__.py +++ b/seed/fastapi/bearer-token-environment-variable/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py b/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py +++ b/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/circular-references-advanced/core/__init__.py b/seed/fastapi/circular-references-advanced/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/circular-references-advanced/core/__init__.py +++ b/seed/fastapi/circular-references-advanced/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py b/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py +++ b/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/circular-references/core/__init__.py b/seed/fastapi/circular-references/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/circular-references/core/__init__.py +++ b/seed/fastapi/circular-references/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/circular-references/core/pydantic_utilities.py b/seed/fastapi/circular-references/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/circular-references/core/pydantic_utilities.py +++ b/seed/fastapi/circular-references/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/code-samples/core/__init__.py b/seed/fastapi/code-samples/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/code-samples/core/__init__.py +++ b/seed/fastapi/code-samples/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/code-samples/core/pydantic_utilities.py b/seed/fastapi/code-samples/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/code-samples/core/pydantic_utilities.py +++ b/seed/fastapi/code-samples/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/custom-auth/core/__init__.py b/seed/fastapi/custom-auth/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/custom-auth/core/__init__.py +++ b/seed/fastapi/custom-auth/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/custom-auth/core/pydantic_utilities.py b/seed/fastapi/custom-auth/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/custom-auth/core/pydantic_utilities.py +++ b/seed/fastapi/custom-auth/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/error-property/core/__init__.py b/seed/fastapi/error-property/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/error-property/core/__init__.py +++ b/seed/fastapi/error-property/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/error-property/core/pydantic_utilities.py b/seed/fastapi/error-property/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/error-property/core/pydantic_utilities.py +++ b/seed/fastapi/error-property/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/examples/core/__init__.py b/seed/fastapi/examples/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/examples/core/__init__.py +++ b/seed/fastapi/examples/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/examples/core/pydantic_utilities.py b/seed/fastapi/examples/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/examples/core/pydantic_utilities.py +++ b/seed/fastapi/examples/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/exhaustive/include-validators/core/__init__.py b/seed/fastapi/exhaustive/include-validators/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/exhaustive/include-validators/core/__init__.py +++ b/seed/fastapi/exhaustive/include-validators/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py b/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/exhaustive/no-custom-config/core/__init__.py b/seed/fastapi/exhaustive/no-custom-config/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/exhaustive/no-custom-config/core/__init__.py +++ b/seed/fastapi/exhaustive/no-custom-config/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py b/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/exhaustive/pydantic-v1/core/__init__.py b/seed/fastapi/exhaustive/pydantic-v1/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/exhaustive/pydantic-v1/core/__init__.py +++ b/seed/fastapi/exhaustive/pydantic-v1/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py b/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/exhaustive/pydantic-v2/core/__init__.py b/seed/fastapi/exhaustive/pydantic-v2/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/exhaustive/pydantic-v2/core/__init__.py +++ b/seed/fastapi/exhaustive/pydantic-v2/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py b/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/exhaustive/skip-formatting/core/__init__.py b/seed/fastapi/exhaustive/skip-formatting/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/exhaustive/skip-formatting/core/__init__.py +++ b/seed/fastapi/exhaustive/skip-formatting/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py b/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/extends/core/__init__.py b/seed/fastapi/extends/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/extends/core/__init__.py +++ b/seed/fastapi/extends/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/extends/core/pydantic_utilities.py b/seed/fastapi/extends/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/extends/core/pydantic_utilities.py +++ b/seed/fastapi/extends/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/extra-properties/core/__init__.py b/seed/fastapi/extra-properties/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/extra-properties/core/__init__.py +++ b/seed/fastapi/extra-properties/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/extra-properties/core/pydantic_utilities.py b/seed/fastapi/extra-properties/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/extra-properties/core/pydantic_utilities.py +++ b/seed/fastapi/extra-properties/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/folders/core/__init__.py b/seed/fastapi/folders/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/folders/core/__init__.py +++ b/seed/fastapi/folders/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/folders/core/pydantic_utilities.py b/seed/fastapi/folders/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/folders/core/pydantic_utilities.py +++ b/seed/fastapi/folders/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/grpc-proto/core/__init__.py b/seed/fastapi/grpc-proto/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/grpc-proto/core/__init__.py +++ b/seed/fastapi/grpc-proto/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/grpc-proto/core/pydantic_utilities.py b/seed/fastapi/grpc-proto/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/grpc-proto/core/pydantic_utilities.py +++ b/seed/fastapi/grpc-proto/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/grpc/core/__init__.py b/seed/fastapi/grpc/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/grpc/core/__init__.py +++ b/seed/fastapi/grpc/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/grpc/core/pydantic_utilities.py b/seed/fastapi/grpc/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/grpc/core/pydantic_utilities.py +++ b/seed/fastapi/grpc/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/idempotency-headers/core/__init__.py b/seed/fastapi/idempotency-headers/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/idempotency-headers/core/__init__.py +++ b/seed/fastapi/idempotency-headers/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/idempotency-headers/core/pydantic_utilities.py b/seed/fastapi/idempotency-headers/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/idempotency-headers/core/pydantic_utilities.py +++ b/seed/fastapi/idempotency-headers/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/imdb/async-handlers/core/__init__.py b/seed/fastapi/imdb/async-handlers/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/imdb/async-handlers/core/__init__.py +++ b/seed/fastapi/imdb/async-handlers/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py b/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/imdb/includes-extra-fields/core/__init__.py b/seed/fastapi/imdb/includes-extra-fields/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/imdb/includes-extra-fields/core/__init__.py +++ b/seed/fastapi/imdb/includes-extra-fields/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py b/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/imdb/no-custom-config/core/__init__.py b/seed/fastapi/imdb/no-custom-config/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/imdb/no-custom-config/core/__init__.py +++ b/seed/fastapi/imdb/no-custom-config/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py b/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/mixed-case/core/__init__.py b/seed/fastapi/mixed-case/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/mixed-case/core/__init__.py +++ b/seed/fastapi/mixed-case/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/mixed-case/core/pydantic_utilities.py b/seed/fastapi/mixed-case/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/mixed-case/core/pydantic_utilities.py +++ b/seed/fastapi/mixed-case/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/multi-line-docs/core/__init__.py b/seed/fastapi/multi-line-docs/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/multi-line-docs/core/__init__.py +++ b/seed/fastapi/multi-line-docs/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/multi-line-docs/core/pydantic_utilities.py b/seed/fastapi/multi-line-docs/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/multi-line-docs/core/pydantic_utilities.py +++ b/seed/fastapi/multi-line-docs/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/multi-url-environment-no-default/core/__init__.py b/seed/fastapi/multi-url-environment-no-default/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/multi-url-environment-no-default/core/__init__.py +++ b/seed/fastapi/multi-url-environment-no-default/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/multi-url-environment-no-default/core/pydantic_utilities.py b/seed/fastapi/multi-url-environment-no-default/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/multi-url-environment-no-default/core/pydantic_utilities.py +++ b/seed/fastapi/multi-url-environment-no-default/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/multi-url-environment/core/__init__.py b/seed/fastapi/multi-url-environment/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/multi-url-environment/core/__init__.py +++ b/seed/fastapi/multi-url-environment/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/multi-url-environment/core/pydantic_utilities.py b/seed/fastapi/multi-url-environment/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/multi-url-environment/core/pydantic_utilities.py +++ b/seed/fastapi/multi-url-environment/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/no-environment/core/__init__.py b/seed/fastapi/no-environment/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/no-environment/core/__init__.py +++ b/seed/fastapi/no-environment/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/no-environment/core/pydantic_utilities.py b/seed/fastapi/no-environment/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/no-environment/core/pydantic_utilities.py +++ b/seed/fastapi/no-environment/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/oauth-client-credentials-default/core/__init__.py b/seed/fastapi/oauth-client-credentials-default/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/oauth-client-credentials-default/core/__init__.py +++ b/seed/fastapi/oauth-client-credentials-default/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/oauth-client-credentials-environment-variables/core/__init__.py b/seed/fastapi/oauth-client-credentials-environment-variables/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/oauth-client-credentials-environment-variables/core/__init__.py +++ b/seed/fastapi/oauth-client-credentials-environment-variables/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/oauth-client-credentials-environment-variables/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials-environment-variables/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/oauth-client-credentials-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials-environment-variables/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/oauth-client-credentials-nested-root/core/__init__.py b/seed/fastapi/oauth-client-credentials-nested-root/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/oauth-client-credentials-nested-root/core/__init__.py +++ b/seed/fastapi/oauth-client-credentials-nested-root/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/oauth-client-credentials-nested-root/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials-nested-root/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/oauth-client-credentials-nested-root/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials-nested-root/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/oauth-client-credentials/core/__init__.py b/seed/fastapi/oauth-client-credentials/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/oauth-client-credentials/core/__init__.py +++ b/seed/fastapi/oauth-client-credentials/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/object/core/__init__.py b/seed/fastapi/object/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/object/core/__init__.py +++ b/seed/fastapi/object/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/object/core/pydantic_utilities.py b/seed/fastapi/object/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/object/core/pydantic_utilities.py +++ b/seed/fastapi/object/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/objects-with-imports/core/__init__.py b/seed/fastapi/objects-with-imports/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/objects-with-imports/core/__init__.py +++ b/seed/fastapi/objects-with-imports/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/objects-with-imports/core/pydantic_utilities.py b/seed/fastapi/objects-with-imports/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/objects-with-imports/core/pydantic_utilities.py +++ b/seed/fastapi/objects-with-imports/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/optional/core/__init__.py b/seed/fastapi/optional/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/optional/core/__init__.py +++ b/seed/fastapi/optional/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/optional/core/pydantic_utilities.py b/seed/fastapi/optional/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/optional/core/pydantic_utilities.py +++ b/seed/fastapi/optional/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/package-yml/core/__init__.py b/seed/fastapi/package-yml/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/package-yml/core/__init__.py +++ b/seed/fastapi/package-yml/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/package-yml/core/pydantic_utilities.py b/seed/fastapi/package-yml/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/package-yml/core/pydantic_utilities.py +++ b/seed/fastapi/package-yml/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/pagination/core/__init__.py b/seed/fastapi/pagination/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/pagination/core/__init__.py +++ b/seed/fastapi/pagination/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/pagination/core/pydantic_utilities.py b/seed/fastapi/pagination/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/pagination/core/pydantic_utilities.py +++ b/seed/fastapi/pagination/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/plain-text/core/__init__.py b/seed/fastapi/plain-text/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/plain-text/core/__init__.py +++ b/seed/fastapi/plain-text/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/plain-text/core/pydantic_utilities.py b/seed/fastapi/plain-text/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/plain-text/core/pydantic_utilities.py +++ b/seed/fastapi/plain-text/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/reserved-keywords/core/__init__.py b/seed/fastapi/reserved-keywords/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/reserved-keywords/core/__init__.py +++ b/seed/fastapi/reserved-keywords/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/reserved-keywords/core/pydantic_utilities.py b/seed/fastapi/reserved-keywords/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/reserved-keywords/core/pydantic_utilities.py +++ b/seed/fastapi/reserved-keywords/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/simple-fhir/core/__init__.py b/seed/fastapi/simple-fhir/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/simple-fhir/core/__init__.py +++ b/seed/fastapi/simple-fhir/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/simple-fhir/core/pydantic_utilities.py b/seed/fastapi/simple-fhir/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/simple-fhir/core/pydantic_utilities.py +++ b/seed/fastapi/simple-fhir/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/single-url-environment-default/core/__init__.py b/seed/fastapi/single-url-environment-default/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/single-url-environment-default/core/__init__.py +++ b/seed/fastapi/single-url-environment-default/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py b/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py +++ b/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/single-url-environment-no-default/core/__init__.py b/seed/fastapi/single-url-environment-no-default/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/single-url-environment-no-default/core/__init__.py +++ b/seed/fastapi/single-url-environment-no-default/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/single-url-environment-no-default/core/pydantic_utilities.py b/seed/fastapi/single-url-environment-no-default/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/single-url-environment-no-default/core/pydantic_utilities.py +++ b/seed/fastapi/single-url-environment-no-default/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/trace/core/__init__.py b/seed/fastapi/trace/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/trace/core/__init__.py +++ b/seed/fastapi/trace/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/trace/core/pydantic_utilities.py b/seed/fastapi/trace/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/trace/core/pydantic_utilities.py +++ b/seed/fastapi/trace/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/undiscriminated-unions/core/__init__.py b/seed/fastapi/undiscriminated-unions/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/undiscriminated-unions/core/__init__.py +++ b/seed/fastapi/undiscriminated-unions/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py b/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py +++ b/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/unions/core/__init__.py b/seed/fastapi/unions/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/unions/core/__init__.py +++ b/seed/fastapi/unions/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/unions/core/pydantic_utilities.py b/seed/fastapi/unions/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/unions/core/pydantic_utilities.py +++ b/seed/fastapi/unions/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/unknown/core/__init__.py b/seed/fastapi/unknown/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/unknown/core/__init__.py +++ b/seed/fastapi/unknown/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/unknown/core/pydantic_utilities.py b/seed/fastapi/unknown/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/unknown/core/pydantic_utilities.py +++ b/seed/fastapi/unknown/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/validation/core/__init__.py b/seed/fastapi/validation/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/validation/core/__init__.py +++ b/seed/fastapi/validation/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/validation/core/pydantic_utilities.py b/seed/fastapi/validation/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/validation/core/pydantic_utilities.py +++ b/seed/fastapi/validation/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/variables/core/__init__.py b/seed/fastapi/variables/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/variables/core/__init__.py +++ b/seed/fastapi/variables/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/variables/core/pydantic_utilities.py b/seed/fastapi/variables/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/variables/core/pydantic_utilities.py +++ b/seed/fastapi/variables/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/version-no-default/core/__init__.py b/seed/fastapi/version-no-default/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/version-no-default/core/__init__.py +++ b/seed/fastapi/version-no-default/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/version-no-default/core/pydantic_utilities.py b/seed/fastapi/version-no-default/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/version-no-default/core/pydantic_utilities.py +++ b/seed/fastapi/version-no-default/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/version/core/__init__.py b/seed/fastapi/version/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/version/core/__init__.py +++ b/seed/fastapi/version/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/version/core/pydantic_utilities.py b/seed/fastapi/version/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/version/core/pydantic_utilities.py +++ b/seed/fastapi/version/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/fastapi/websocket/core/__init__.py b/seed/fastapi/websocket/core/__init__.py index f375cd27ae8..b40f82b07df 100644 --- a/seed/fastapi/websocket/core/__init__.py +++ b/seed/fastapi/websocket/core/__init__.py @@ -12,7 +12,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -28,7 +27,6 @@ "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "default_exception_handler", "fern_http_exception_handler", "http_exception_handler", diff --git a/seed/fastapi/websocket/core/pydantic_utilities.py b/seed/fastapi/websocket/core/pydantic_utilities.py index 9849f4fb453..142f9ee8db8 100644 --- a/seed/fastapi/websocket/core/pydantic_utilities.py +++ b/seed/fastapi/websocket/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -188,3 +184,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/alias-extends/src/seed/alias_extends/core/__init__.py b/seed/pydantic/alias-extends/src/seed/alias_extends/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/alias-extends/src/seed/alias_extends/core/__init__.py +++ b/seed/pydantic/alias-extends/src/seed/alias_extends/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/alias-extends/src/seed/alias_extends/core/pydantic_utilities.py b/seed/pydantic/alias-extends/src/seed/alias_extends/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/alias-extends/src/seed/alias_extends/core/pydantic_utilities.py +++ b/seed/pydantic/alias-extends/src/seed/alias_extends/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/alias/src/seed/alias/core/__init__.py b/seed/pydantic/alias/src/seed/alias/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/alias/src/seed/alias/core/__init__.py +++ b/seed/pydantic/alias/src/seed/alias/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py b/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py +++ b/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/__init__.py b/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/__init__.py +++ b/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/pydantic_utilities.py b/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/pydantic_utilities.py +++ b/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/audiences/src/seed/audiences/core/__init__.py b/seed/pydantic/audiences/src/seed/audiences/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/audiences/src/seed/audiences/core/__init__.py +++ b/seed/pydantic/audiences/src/seed/audiences/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py b/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py +++ b/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/__init__.py b/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/__init__.py +++ b/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/pydantic_utilities.py b/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/pydantic_utilities.py +++ b/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/__init__.py b/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/__init__.py +++ b/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/pydantic_utilities.py b/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/pydantic_utilities.py +++ b/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/basic-auth/src/seed/basic_auth/core/__init__.py b/seed/pydantic/basic-auth/src/seed/basic_auth/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/basic-auth/src/seed/basic_auth/core/__init__.py +++ b/seed/pydantic/basic-auth/src/seed/basic_auth/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/basic-auth/src/seed/basic_auth/core/pydantic_utilities.py b/seed/pydantic/basic-auth/src/seed/basic_auth/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/basic-auth/src/seed/basic_auth/core/pydantic_utilities.py +++ b/seed/pydantic/basic-auth/src/seed/basic_auth/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/__init__.py b/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/__init__.py +++ b/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/pydantic_utilities.py b/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/pydantic_utilities.py +++ b/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/bytes/src/seed/bytes/core/__init__.py b/seed/pydantic/bytes/src/seed/bytes/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/bytes/src/seed/bytes/core/__init__.py +++ b/seed/pydantic/bytes/src/seed/bytes/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py b/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py +++ b/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/circular-references-advanced/src/seed/api/core/__init__.py b/seed/pydantic/circular-references-advanced/src/seed/api/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/circular-references-advanced/src/seed/api/core/__init__.py +++ b/seed/pydantic/circular-references-advanced/src/seed/api/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/circular-references-advanced/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/circular-references-advanced/src/seed/api/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/circular-references-advanced/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/circular-references-advanced/src/seed/api/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/circular-references/src/seed/api/core/__init__.py b/seed/pydantic/circular-references/src/seed/api/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/circular-references/src/seed/api/core/__init__.py +++ b/seed/pydantic/circular-references/src/seed/api/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/circular-references/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/circular-references/src/seed/api/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/circular-references/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/circular-references/src/seed/api/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/code-samples/src/seed/code_samples/core/__init__.py b/seed/pydantic/code-samples/src/seed/code_samples/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/code-samples/src/seed/code_samples/core/__init__.py +++ b/seed/pydantic/code-samples/src/seed/code_samples/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/code-samples/src/seed/code_samples/core/pydantic_utilities.py b/seed/pydantic/code-samples/src/seed/code_samples/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/code-samples/src/seed/code_samples/core/pydantic_utilities.py +++ b/seed/pydantic/code-samples/src/seed/code_samples/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/custom-auth/src/seed/custom_auth/core/__init__.py b/seed/pydantic/custom-auth/src/seed/custom_auth/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/custom-auth/src/seed/custom_auth/core/__init__.py +++ b/seed/pydantic/custom-auth/src/seed/custom_auth/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/custom-auth/src/seed/custom_auth/core/pydantic_utilities.py b/seed/pydantic/custom-auth/src/seed/custom_auth/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/custom-auth/src/seed/custom_auth/core/pydantic_utilities.py +++ b/seed/pydantic/custom-auth/src/seed/custom_auth/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/enum/src/seed/enum/core/__init__.py b/seed/pydantic/enum/src/seed/enum/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/enum/src/seed/enum/core/__init__.py +++ b/seed/pydantic/enum/src/seed/enum/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py b/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py +++ b/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/error-property/src/seed/error_property/core/__init__.py b/seed/pydantic/error-property/src/seed/error_property/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/error-property/src/seed/error_property/core/__init__.py +++ b/seed/pydantic/error-property/src/seed/error_property/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/error-property/src/seed/error_property/core/pydantic_utilities.py b/seed/pydantic/error-property/src/seed/error_property/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/error-property/src/seed/error_property/core/pydantic_utilities.py +++ b/seed/pydantic/error-property/src/seed/error_property/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/examples/src/seed/examples/core/__init__.py b/seed/pydantic/examples/src/seed/examples/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/examples/src/seed/examples/core/__init__.py +++ b/seed/pydantic/examples/src/seed/examples/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py b/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py +++ b/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/__init__.py b/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/__init__.py +++ b/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/pydantic_utilities.py b/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/pydantic_utilities.py +++ b/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/__init__.py b/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/__init__.py +++ b/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/pydantic_utilities.py b/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/pydantic_utilities.py +++ b/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/extends/src/seed/extends/core/__init__.py b/seed/pydantic/extends/src/seed/extends/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/extends/src/seed/extends/core/__init__.py +++ b/seed/pydantic/extends/src/seed/extends/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py b/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py +++ b/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/extra-properties/src/seed/extra_properties/core/__init__.py b/seed/pydantic/extra-properties/src/seed/extra_properties/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/extra-properties/src/seed/extra_properties/core/__init__.py +++ b/seed/pydantic/extra-properties/src/seed/extra_properties/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/extra-properties/src/seed/extra_properties/core/pydantic_utilities.py b/seed/pydantic/extra-properties/src/seed/extra_properties/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/extra-properties/src/seed/extra_properties/core/pydantic_utilities.py +++ b/seed/pydantic/extra-properties/src/seed/extra_properties/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/file-download/src/seed/file_download/core/__init__.py b/seed/pydantic/file-download/src/seed/file_download/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/file-download/src/seed/file_download/core/__init__.py +++ b/seed/pydantic/file-download/src/seed/file_download/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/file-download/src/seed/file_download/core/pydantic_utilities.py b/seed/pydantic/file-download/src/seed/file_download/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/file-download/src/seed/file_download/core/pydantic_utilities.py +++ b/seed/pydantic/file-download/src/seed/file_download/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/file-upload/src/seed/file_upload/core/__init__.py b/seed/pydantic/file-upload/src/seed/file_upload/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/file-upload/src/seed/file_upload/core/__init__.py +++ b/seed/pydantic/file-upload/src/seed/file_upload/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/file-upload/src/seed/file_upload/core/pydantic_utilities.py b/seed/pydantic/file-upload/src/seed/file_upload/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/file-upload/src/seed/file_upload/core/pydantic_utilities.py +++ b/seed/pydantic/file-upload/src/seed/file_upload/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/folders/src/seed/api/core/__init__.py b/seed/pydantic/folders/src/seed/api/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/folders/src/seed/api/core/__init__.py +++ b/seed/pydantic/folders/src/seed/api/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/grpc-proto/src/seed/api/core/__init__.py b/seed/pydantic/grpc-proto/src/seed/api/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/grpc-proto/src/seed/api/core/__init__.py +++ b/seed/pydantic/grpc-proto/src/seed/api/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/grpc-proto/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/grpc-proto/src/seed/api/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/grpc-proto/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/grpc-proto/src/seed/api/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/grpc/src/seed/api/core/__init__.py b/seed/pydantic/grpc/src/seed/api/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/grpc/src/seed/api/core/__init__.py +++ b/seed/pydantic/grpc/src/seed/api/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/__init__.py b/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/__init__.py +++ b/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/pydantic_utilities.py b/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/pydantic_utilities.py +++ b/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/imdb/src/seed/api/core/__init__.py b/seed/pydantic/imdb/src/seed/api/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/imdb/src/seed/api/core/__init__.py +++ b/seed/pydantic/imdb/src/seed/api/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/literal/src/seed/literal/core/__init__.py b/seed/pydantic/literal/src/seed/literal/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/literal/src/seed/literal/core/__init__.py +++ b/seed/pydantic/literal/src/seed/literal/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py b/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py +++ b/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/mixed-case/src/seed/mixed_case/core/__init__.py b/seed/pydantic/mixed-case/src/seed/mixed_case/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/mixed-case/src/seed/mixed_case/core/__init__.py +++ b/seed/pydantic/mixed-case/src/seed/mixed_case/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/mixed-case/src/seed/mixed_case/core/pydantic_utilities.py b/seed/pydantic/mixed-case/src/seed/mixed_case/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/mixed-case/src/seed/mixed_case/core/pydantic_utilities.py +++ b/seed/pydantic/mixed-case/src/seed/mixed_case/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/__init__.py b/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/__init__.py +++ b/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/pydantic_utilities.py b/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/pydantic_utilities.py +++ b/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/__init__.py b/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/__init__.py +++ b/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/pydantic_utilities.py b/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/pydantic_utilities.py +++ b/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/__init__.py b/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/__init__.py +++ b/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/pydantic_utilities.py b/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/pydantic_utilities.py +++ b/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/no-environment/src/seed/no_environment/core/__init__.py b/seed/pydantic/no-environment/src/seed/no_environment/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/no-environment/src/seed/no_environment/core/__init__.py +++ b/seed/pydantic/no-environment/src/seed/no_environment/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/no-environment/src/seed/no_environment/core/pydantic_utilities.py b/seed/pydantic/no-environment/src/seed/no_environment/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/no-environment/src/seed/no_environment/core/pydantic_utilities.py +++ b/seed/pydantic/no-environment/src/seed/no_environment/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/__init__.py b/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/__init__.py +++ b/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/pydantic_utilities.py b/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/pydantic_utilities.py +++ b/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/__init__.py b/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/__init__.py +++ b/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/pydantic_utilities.py b/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/pydantic_utilities.py +++ b/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/__init__.py b/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/__init__.py +++ b/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/pydantic_utilities.py b/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/pydantic_utilities.py +++ b/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/__init__.py b/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/__init__.py +++ b/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/pydantic_utilities.py b/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/pydantic_utilities.py +++ b/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/object/src/seed/object/core/__init__.py b/seed/pydantic/object/src/seed/object/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/object/src/seed/object/core/__init__.py +++ b/seed/pydantic/object/src/seed/object/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py b/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py +++ b/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/__init__.py b/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/__init__.py +++ b/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/pydantic_utilities.py b/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/pydantic_utilities.py +++ b/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/optional/src/seed/objects_with_imports/core/__init__.py b/seed/pydantic/optional/src/seed/objects_with_imports/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/optional/src/seed/objects_with_imports/core/__init__.py +++ b/seed/pydantic/optional/src/seed/objects_with_imports/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/optional/src/seed/objects_with_imports/core/pydantic_utilities.py b/seed/pydantic/optional/src/seed/objects_with_imports/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/optional/src/seed/objects_with_imports/core/pydantic_utilities.py +++ b/seed/pydantic/optional/src/seed/objects_with_imports/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/package-yml/src/seed/package_yml/core/__init__.py b/seed/pydantic/package-yml/src/seed/package_yml/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/package-yml/src/seed/package_yml/core/__init__.py +++ b/seed/pydantic/package-yml/src/seed/package_yml/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/package-yml/src/seed/package_yml/core/pydantic_utilities.py b/seed/pydantic/package-yml/src/seed/package_yml/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/package-yml/src/seed/package_yml/core/pydantic_utilities.py +++ b/seed/pydantic/package-yml/src/seed/package_yml/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/pagination/src/seed/pagination/core/__init__.py b/seed/pydantic/pagination/src/seed/pagination/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/pagination/src/seed/pagination/core/__init__.py +++ b/seed/pydantic/pagination/src/seed/pagination/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py b/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py +++ b/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/plain-text/src/seed/plain_text/core/__init__.py b/seed/pydantic/plain-text/src/seed/plain_text/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/plain-text/src/seed/plain_text/core/__init__.py +++ b/seed/pydantic/plain-text/src/seed/plain_text/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/plain-text/src/seed/plain_text/core/pydantic_utilities.py b/seed/pydantic/plain-text/src/seed/plain_text/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/plain-text/src/seed/plain_text/core/pydantic_utilities.py +++ b/seed/pydantic/plain-text/src/seed/plain_text/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/query-parameters/src/seed/query_parameters/core/__init__.py b/seed/pydantic/query-parameters/src/seed/query_parameters/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/query-parameters/src/seed/query_parameters/core/__init__.py +++ b/seed/pydantic/query-parameters/src/seed/query_parameters/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/query-parameters/src/seed/query_parameters/core/pydantic_utilities.py b/seed/pydantic/query-parameters/src/seed/query_parameters/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/query-parameters/src/seed/query_parameters/core/pydantic_utilities.py +++ b/seed/pydantic/query-parameters/src/seed/query_parameters/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/__init__.py b/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/__init__.py +++ b/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/pydantic_utilities.py b/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/pydantic_utilities.py +++ b/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/response-property/src/seed/response_property/core/__init__.py b/seed/pydantic/response-property/src/seed/response_property/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/response-property/src/seed/response_property/core/__init__.py +++ b/seed/pydantic/response-property/src/seed/response_property/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/response-property/src/seed/response_property/core/pydantic_utilities.py b/seed/pydantic/response-property/src/seed/response_property/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/response-property/src/seed/response_property/core/pydantic_utilities.py +++ b/seed/pydantic/response-property/src/seed/response_property/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/simple-fhir/src/seed/api/core/__init__.py b/seed/pydantic/simple-fhir/src/seed/api/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/simple-fhir/src/seed/api/core/__init__.py +++ b/seed/pydantic/simple-fhir/src/seed/api/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/simple-fhir/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/simple-fhir/src/seed/api/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/simple-fhir/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/simple-fhir/src/seed/api/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/__init__.py b/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/__init__.py +++ b/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/pydantic_utilities.py b/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/pydantic_utilities.py +++ b/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/__init__.py b/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/__init__.py +++ b/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/pydantic_utilities.py b/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/pydantic_utilities.py +++ b/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/streaming-parameter/src/seed/streaming/core/__init__.py b/seed/pydantic/streaming-parameter/src/seed/streaming/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/streaming-parameter/src/seed/streaming/core/__init__.py +++ b/seed/pydantic/streaming-parameter/src/seed/streaming/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/streaming-parameter/src/seed/streaming/core/pydantic_utilities.py b/seed/pydantic/streaming-parameter/src/seed/streaming/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/streaming-parameter/src/seed/streaming/core/pydantic_utilities.py +++ b/seed/pydantic/streaming-parameter/src/seed/streaming/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/streaming/src/seed/streaming/core/__init__.py b/seed/pydantic/streaming/src/seed/streaming/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/streaming/src/seed/streaming/core/__init__.py +++ b/seed/pydantic/streaming/src/seed/streaming/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py b/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py +++ b/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/trace/src/seed/trace/core/__init__.py b/seed/pydantic/trace/src/seed/trace/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/trace/src/seed/trace/core/__init__.py +++ b/seed/pydantic/trace/src/seed/trace/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py b/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py +++ b/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/__init__.py b/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/__init__.py +++ b/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/pydantic_utilities.py b/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/pydantic_utilities.py +++ b/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/unions/src/seed/unions/core/__init__.py b/seed/pydantic/unions/src/seed/unions/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/unions/src/seed/unions/core/__init__.py +++ b/seed/pydantic/unions/src/seed/unions/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py b/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py +++ b/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/unknown/src/seed/unknown_as_any/core/__init__.py b/seed/pydantic/unknown/src/seed/unknown_as_any/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/unknown/src/seed/unknown_as_any/core/__init__.py +++ b/seed/pydantic/unknown/src/seed/unknown_as_any/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/unknown/src/seed/unknown_as_any/core/pydantic_utilities.py b/seed/pydantic/unknown/src/seed/unknown_as_any/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/unknown/src/seed/unknown_as_any/core/pydantic_utilities.py +++ b/seed/pydantic/unknown/src/seed/unknown_as_any/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/validation/src/seed/validation/core/__init__.py b/seed/pydantic/validation/src/seed/validation/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/validation/src/seed/validation/core/__init__.py +++ b/seed/pydantic/validation/src/seed/validation/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py b/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py +++ b/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/variables/src/seed/variables/core/__init__.py b/seed/pydantic/variables/src/seed/variables/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/variables/src/seed/variables/core/__init__.py +++ b/seed/pydantic/variables/src/seed/variables/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py b/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py +++ b/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/version-no-default/src/seed/version/core/__init__.py b/seed/pydantic/version-no-default/src/seed/version/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/version-no-default/src/seed/version/core/__init__.py +++ b/seed/pydantic/version-no-default/src/seed/version/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/version-no-default/src/seed/version/core/pydantic_utilities.py b/seed/pydantic/version-no-default/src/seed/version/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/version-no-default/src/seed/version/core/pydantic_utilities.py +++ b/seed/pydantic/version-no-default/src/seed/version/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/version/src/seed/version/core/__init__.py b/seed/pydantic/version/src/seed/version/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/version/src/seed/version/core/__init__.py +++ b/seed/pydantic/version/src/seed/version/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py b/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py +++ b/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/pydantic/websocket/src/seed/websocket/core/__init__.py b/seed/pydantic/websocket/src/seed/websocket/core/__init__.py index 85460274fba..9c7cd65aa25 100644 --- a/seed/pydantic/websocket/src/seed/websocket/core/__init__.py +++ b/seed/pydantic/websocket/src/seed/websocket/core/__init__.py @@ -5,7 +5,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -18,7 +17,6 @@ "IS_PYDANTIC_V2", "UniversalBaseModel", "UniversalRootModel", - "deep_union_pydantic_dicts", "parse_obj_as", "serialize_datetime", "universal_field_validator", diff --git a/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py b/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py +++ b/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/alias-extends/src/seed/core/__init__.py b/seed/python-sdk/alias-extends/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/alias-extends/src/seed/core/__init__.py +++ b/seed/python-sdk/alias-extends/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/alias-extends/src/seed/core/pydantic_utilities.py b/seed/python-sdk/alias-extends/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/alias-extends/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/alias-extends/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/alias/src/seed/core/__init__.py b/seed/python-sdk/alias/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/alias/src/seed/core/__init__.py +++ b/seed/python-sdk/alias/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py b/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/api-wide-base-path/src/seed/core/__init__.py b/seed/python-sdk/api-wide-base-path/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/api-wide-base-path/src/seed/core/__init__.py +++ b/seed/python-sdk/api-wide-base-path/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/api-wide-base-path/src/seed/core/pydantic_utilities.py b/seed/python-sdk/api-wide-base-path/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/api-wide-base-path/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/api-wide-base-path/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/audiences/src/seed/core/__init__.py b/seed/python-sdk/audiences/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/audiences/src/seed/core/__init__.py +++ b/seed/python-sdk/audiences/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py b/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/auth-environment-variables/src/seed/core/__init__.py b/seed/python-sdk/auth-environment-variables/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/auth-environment-variables/src/seed/core/__init__.py +++ b/seed/python-sdk/auth-environment-variables/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/auth-environment-variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/auth-environment-variables/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/auth-environment-variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/auth-environment-variables/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/basic-auth-environment-variables/src/seed/core/__init__.py b/seed/python-sdk/basic-auth-environment-variables/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/basic-auth-environment-variables/src/seed/core/__init__.py +++ b/seed/python-sdk/basic-auth-environment-variables/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/basic-auth/src/seed/core/__init__.py b/seed/python-sdk/basic-auth/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/basic-auth/src/seed/core/__init__.py +++ b/seed/python-sdk/basic-auth/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py b/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/bearer-token-environment-variable/src/seed/core/__init__.py b/seed/python-sdk/bearer-token-environment-variable/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/bearer-token-environment-variable/src/seed/core/__init__.py +++ b/seed/python-sdk/bearer-token-environment-variable/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/bearer-token-environment-variable/src/seed/core/pydantic_utilities.py b/seed/python-sdk/bearer-token-environment-variable/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/bearer-token-environment-variable/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/bearer-token-environment-variable/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/bytes/src/seed/core/__init__.py b/seed/python-sdk/bytes/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/bytes/src/seed/core/__init__.py +++ b/seed/python-sdk/bytes/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py b/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/circular-references-advanced/src/seed/core/__init__.py b/seed/python-sdk/circular-references-advanced/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/circular-references-advanced/src/seed/core/__init__.py +++ b/seed/python-sdk/circular-references-advanced/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py b/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/circular-references/src/seed/core/__init__.py b/seed/python-sdk/circular-references/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/circular-references/src/seed/core/__init__.py +++ b/seed/python-sdk/circular-references/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py b/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/code-samples/src/seed/core/__init__.py b/seed/python-sdk/code-samples/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/code-samples/src/seed/core/__init__.py +++ b/seed/python-sdk/code-samples/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/code-samples/src/seed/core/pydantic_utilities.py b/seed/python-sdk/code-samples/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/code-samples/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/code-samples/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/custom-auth/src/seed/core/__init__.py b/seed/python-sdk/custom-auth/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/custom-auth/src/seed/core/__init__.py +++ b/seed/python-sdk/custom-auth/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py b/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/enum/no-custom-config/src/seed/core/__init__.py b/seed/python-sdk/enum/no-custom-config/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/enum/no-custom-config/src/seed/core/__init__.py +++ b/seed/python-sdk/enum/no-custom-config/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/__init__.py b/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/__init__.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/enum/real-enum/src/seed/core/__init__.py b/seed/python-sdk/enum/real-enum/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/enum/real-enum/src/seed/core/__init__.py +++ b/seed/python-sdk/enum/real-enum/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/enum/strenum/src/seed/core/__init__.py b/seed/python-sdk/enum/strenum/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/enum/strenum/src/seed/core/__init__.py +++ b/seed/python-sdk/enum/strenum/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/error-property/src/seed/core/__init__.py b/seed/python-sdk/error-property/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/error-property/src/seed/core/__init__.py +++ b/seed/python-sdk/error-property/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py b/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/examples/client-filename/src/seed/core/__init__.py b/seed/python-sdk/examples/client-filename/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/examples/client-filename/src/seed/core/__init__.py +++ b/seed/python-sdk/examples/client-filename/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py b/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/examples/no-custom-config/src/seed/core/__init__.py b/seed/python-sdk/examples/no-custom-config/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/examples/no-custom-config/src/seed/core/__init__.py +++ b/seed/python-sdk/examples/no-custom-config/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/examples/readme/src/seed/core/__init__.py b/seed/python-sdk/examples/readme/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/examples/readme/src/seed/core/__init__.py +++ b/seed/python-sdk/examples/readme/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py b/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/__init__.py index e62bebe7ce4..226d7d5c439 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -40,7 +39,6 @@ "construct_type", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/exhaustive/union-utils/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/union-utils/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/exhaustive/union-utils/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/union-utils/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/extends/src/seed/core/__init__.py b/seed/python-sdk/extends/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/extends/src/seed/core/__init__.py +++ b/seed/python-sdk/extends/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py b/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/extra-properties/src/seed/core/__init__.py b/seed/python-sdk/extra-properties/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/extra-properties/src/seed/core/__init__.py +++ b/seed/python-sdk/extra-properties/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py b/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/file-download/src/seed/core/__init__.py b/seed/python-sdk/file-download/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/file-download/src/seed/core/__init__.py +++ b/seed/python-sdk/file-download/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/file-download/src/seed/core/pydantic_utilities.py b/seed/python-sdk/file-download/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/file-download/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/file-download/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/file-upload/src/seed/core/__init__.py b/seed/python-sdk/file-upload/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/file-upload/src/seed/core/__init__.py +++ b/seed/python-sdk/file-upload/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/file-upload/src/seed/core/pydantic_utilities.py b/seed/python-sdk/file-upload/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/file-upload/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/file-upload/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/folders/src/seed/core/__init__.py b/seed/python-sdk/folders/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/folders/src/seed/core/__init__.py +++ b/seed/python-sdk/folders/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py b/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/grpc-proto/src/seed/core/__init__.py b/seed/python-sdk/grpc-proto/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/grpc-proto/src/seed/core/__init__.py +++ b/seed/python-sdk/grpc-proto/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py b/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/grpc/src/seed/core/__init__.py b/seed/python-sdk/grpc/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/grpc/src/seed/core/__init__.py +++ b/seed/python-sdk/grpc/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py b/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/idempotency-headers/src/seed/core/__init__.py b/seed/python-sdk/idempotency-headers/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/idempotency-headers/src/seed/core/__init__.py +++ b/seed/python-sdk/idempotency-headers/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/idempotency-headers/src/seed/core/pydantic_utilities.py b/seed/python-sdk/idempotency-headers/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/idempotency-headers/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/idempotency-headers/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/imdb/src/seed/core/__init__.py b/seed/python-sdk/imdb/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/imdb/src/seed/core/__init__.py +++ b/seed/python-sdk/imdb/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py b/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/literal/no-custom-config/src/seed/core/__init__.py b/seed/python-sdk/literal/no-custom-config/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/literal/no-custom-config/src/seed/core/__init__.py +++ b/seed/python-sdk/literal/no-custom-config/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/__init__.py b/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/__init__.py +++ b/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py b/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/mixed-case/src/seed/core/__init__.py b/seed/python-sdk/mixed-case/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/mixed-case/src/seed/core/__init__.py +++ b/seed/python-sdk/mixed-case/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/mixed-case/src/seed/core/pydantic_utilities.py b/seed/python-sdk/mixed-case/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/mixed-case/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/mixed-case/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/multi-line-docs/src/seed/core/__init__.py b/seed/python-sdk/multi-line-docs/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/multi-line-docs/src/seed/core/__init__.py +++ b/seed/python-sdk/multi-line-docs/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py b/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/multi-url-environment-no-default/src/seed/core/__init__.py b/seed/python-sdk/multi-url-environment-no-default/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/multi-url-environment-no-default/src/seed/core/__init__.py +++ b/seed/python-sdk/multi-url-environment-no-default/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/multi-url-environment/src/seed/core/__init__.py b/seed/python-sdk/multi-url-environment/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/multi-url-environment/src/seed/core/__init__.py +++ b/seed/python-sdk/multi-url-environment/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py b/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/no-environment/src/seed/core/__init__.py b/seed/python-sdk/no-environment/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/no-environment/src/seed/core/__init__.py +++ b/seed/python-sdk/no-environment/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/no-environment/src/seed/core/pydantic_utilities.py b/seed/python-sdk/no-environment/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/no-environment/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/no-environment/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/oauth-client-credentials-default/src/seed/core/__init__.py b/seed/python-sdk/oauth-client-credentials-default/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/oauth-client-credentials-default/src/seed/core/__init__.py +++ b/seed/python-sdk/oauth-client-credentials-default/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/oauth-client-credentials-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/oauth-client-credentials-default/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/oauth-client-credentials-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/oauth-client-credentials-default/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/__init__.py b/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/__init__.py +++ b/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/__init__.py b/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/__init__.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py b/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/oauth-client-credentials/src/seed/core/__init__.py b/seed/python-sdk/oauth-client-credentials/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/oauth-client-credentials/src/seed/core/__init__.py +++ b/seed/python-sdk/oauth-client-credentials/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/oauth-client-credentials/src/seed/core/pydantic_utilities.py b/seed/python-sdk/oauth-client-credentials/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/oauth-client-credentials/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/oauth-client-credentials/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/object/src/seed/core/__init__.py b/seed/python-sdk/object/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/object/src/seed/core/__init__.py +++ b/seed/python-sdk/object/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/object/src/seed/core/pydantic_utilities.py b/seed/python-sdk/object/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/object/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/object/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/objects-with-imports/src/seed/core/__init__.py b/seed/python-sdk/objects-with-imports/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/objects-with-imports/src/seed/core/__init__.py +++ b/seed/python-sdk/objects-with-imports/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py b/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/optional/src/seed/core/__init__.py b/seed/python-sdk/optional/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/optional/src/seed/core/__init__.py +++ b/seed/python-sdk/optional/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py b/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/package-yml/src/seed/core/__init__.py b/seed/python-sdk/package-yml/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/package-yml/src/seed/core/__init__.py +++ b/seed/python-sdk/package-yml/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py b/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/pagination/src/seed/core/__init__.py b/seed/python-sdk/pagination/src/seed/core/__init__.py index 15442d42733..2fcdcefd748 100644 --- a/seed/python-sdk/pagination/src/seed/core/__init__.py +++ b/seed/python-sdk/pagination/src/seed/core/__init__.py @@ -11,7 +11,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -39,7 +38,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py b/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/plain-text/src/seed/core/__init__.py b/seed/python-sdk/plain-text/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/plain-text/src/seed/core/__init__.py +++ b/seed/python-sdk/plain-text/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py b/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/query-parameters/src/seed/core/__init__.py b/seed/python-sdk/query-parameters/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/query-parameters/src/seed/core/__init__.py +++ b/seed/python-sdk/query-parameters/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py b/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/reserved-keywords/src/seed/core/__init__.py b/seed/python-sdk/reserved-keywords/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/reserved-keywords/src/seed/core/__init__.py +++ b/seed/python-sdk/reserved-keywords/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py b/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/response-property/src/seed/core/__init__.py b/seed/python-sdk/response-property/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/response-property/src/seed/core/__init__.py +++ b/seed/python-sdk/response-property/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py b/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/simple-fhir/src/seed/core/__init__.py b/seed/python-sdk/simple-fhir/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/simple-fhir/src/seed/core/__init__.py +++ b/seed/python-sdk/simple-fhir/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py b/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/single-url-environment-default/src/seed/core/__init__.py b/seed/python-sdk/single-url-environment-default/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/single-url-environment-default/src/seed/core/__init__.py +++ b/seed/python-sdk/single-url-environment-default/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/single-url-environment-no-default/src/seed/core/__init__.py b/seed/python-sdk/single-url-environment-no-default/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/single-url-environment-no-default/src/seed/core/__init__.py +++ b/seed/python-sdk/single-url-environment-no-default/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/streaming-parameter/src/seed/core/__init__.py b/seed/python-sdk/streaming-parameter/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/streaming-parameter/src/seed/core/__init__.py +++ b/seed/python-sdk/streaming-parameter/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py b/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/streaming/no-custom-config/src/seed/core/__init__.py b/seed/python-sdk/streaming/no-custom-config/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/streaming/no-custom-config/src/seed/core/__init__.py +++ b/seed/python-sdk/streaming/no-custom-config/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/__init__.py b/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/__init__.py index e62bebe7ce4..226d7d5c439 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/__init__.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -40,7 +39,6 @@ "construct_type", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py b/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/trace/src/seed/core/__init__.py b/seed/python-sdk/trace/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/trace/src/seed/core/__init__.py +++ b/seed/python-sdk/trace/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py b/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/undiscriminated-unions/src/seed/core/__init__.py b/seed/python-sdk/undiscriminated-unions/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/undiscriminated-unions/src/seed/core/__init__.py +++ b/seed/python-sdk/undiscriminated-unions/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py b/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/unions/no-custom-config/src/seed/core/__init__.py b/seed/python-sdk/unions/no-custom-config/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/unions/no-custom-config/src/seed/core/__init__.py +++ b/seed/python-sdk/unions/no-custom-config/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/unions/union-naming-v1/src/seed/core/__init__.py b/seed/python-sdk/unions/union-naming-v1/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/unions/union-naming-v1/src/seed/core/__init__.py +++ b/seed/python-sdk/unions/union-naming-v1/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/unions/union-utils/src/seed/core/__init__.py b/seed/python-sdk/unions/union-utils/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/core/__init__.py +++ b/seed/python-sdk/unions/union-utils/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/unknown/src/seed/core/__init__.py b/seed/python-sdk/unknown/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/unknown/src/seed/core/__init__.py +++ b/seed/python-sdk/unknown/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/validation/no-custom-config/src/seed/core/__init__.py b/seed/python-sdk/validation/no-custom-config/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/validation/no-custom-config/src/seed/core/__init__.py +++ b/seed/python-sdk/validation/no-custom-config/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/validation/with-defaults/src/seed/core/__init__.py b/seed/python-sdk/validation/with-defaults/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/validation/with-defaults/src/seed/core/__init__.py +++ b/seed/python-sdk/validation/with-defaults/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py b/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/variables/src/seed/core/__init__.py b/seed/python-sdk/variables/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/variables/src/seed/core/__init__.py +++ b/seed/python-sdk/variables/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/version-no-default/src/seed/core/__init__.py b/seed/python-sdk/version-no-default/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/version-no-default/src/seed/core/__init__.py +++ b/seed/python-sdk/version-no-default/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/version-no-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/version-no-default/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/version-no-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/version-no-default/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/version/src/seed/core/__init__.py b/seed/python-sdk/version/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/version/src/seed/core/__init__.py +++ b/seed/python-sdk/version/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/version/src/seed/core/pydantic_utilities.py b/seed/python-sdk/version/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/version/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/version/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value diff --git a/seed/python-sdk/websocket/src/seed/core/__init__.py b/seed/python-sdk/websocket/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/websocket/src/seed/core/__init__.py +++ b/seed/python-sdk/websocket/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py b/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py index 06bc2b9e10c..8f03ff32094 100644 --- a/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +# This file was auto-generated by Fern from our API Definition. + # nopycln: file import datetime as dt import typing @@ -55,19 +57,6 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) -def deep_union_pydantic_dicts( - source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] -) -> typing.Dict[str, typing.Any]: - for key, value in source.items(): - if isinstance(value, dict): - node = destination.setdefault(key, {}) - deep_union_pydantic_dicts(value, node) - else: - destination[key] = value - - return destination - - def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -106,27 +95,34 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + """ + Override the default dict method to `exclude_unset` by default. This function patches + `exclude_unset` to work include fields within non-None default values. + """ + + _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) + for name, field in fields.items(): + if field not in _fields_set: + default = _get_field_default(field) + + # If the default values are non-null act like they've been set + # This effectively allows exclude_unset to work like exclude_none where + # the latter passes through intentionally set none values. + if default != None: + _fields_set.add(name) + kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - **kwargs, - } - kwargs_with_defaults_exclude_none: typing.Any = { - "by_alias": True, - "exclude_none": True, + "include": _fields_set, **kwargs, } if IS_PYDANTIC_V2: - return deep_union_pydantic_dicts( - super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 - super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 - ) + return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 else: - return deep_union_pydantic_dicts( - super().dict(**kwargs_with_defaults_exclude_unset), - super().dict(**kwargs_with_defaults_exclude_none), - ) + return super().dict(**kwargs_with_defaults_exclude_unset) if IS_PYDANTIC_V2: @@ -184,3 +180,29 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator + + +PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] + + +def _get_model_fields( + model: typing.Type["Model"], +) -> typing.Mapping[str, PydanticField]: + if IS_PYDANTIC_V2: + return model.model_fields # type: ignore # Pydantic v2 + else: + return model.__fields__ # type: ignore # Pydantic v1 + + +def _get_field_default(field: PydanticField) -> typing.Any: + try: + value = field.get_default() # type: ignore # Pydantic < v1.10.15 + except: + value = field.default + if IS_PYDANTIC_V2: + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None + return value + return value From 767aad9793ed5f3bbc4f0d420626eb86378f2a50 Mon Sep 17 00:00:00 2001 From: armandobelardo Date: Wed, 14 Aug 2024 07:23:52 -0400 Subject: [PATCH 3/7] update seed --- generators/python/core_utilities/fastapi/__init__.py | 6 +----- .../python/core_utilities/fastapi/pydantic_utilities.py | 4 ++-- .../python/core_utilities/pydantic/pydantic_utilities.py | 4 ++-- .../python/core_utilities/sdk/pydantic_utilities.py | 4 ++-- .../example_models/types/core/pydantic_utilities.py | 4 ++-- .../utils/union_utils/types/core/pydantic_utilities.py | 4 ++-- seed/fastapi/alias-extends/core/pydantic_utilities.py | 4 ++-- seed/fastapi/alias/core/pydantic_utilities.py | 4 ++-- .../api-wide-base-path/core/pydantic_utilities.py | 4 ++-- seed/fastapi/audiences/core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- seed/fastapi/basic-auth/core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- .../circular-references/core/pydantic_utilities.py | 4 ++-- seed/fastapi/code-samples/core/pydantic_utilities.py | 4 ++-- seed/fastapi/custom-auth/core/pydantic_utilities.py | 4 ++-- seed/fastapi/error-property/core/pydantic_utilities.py | 4 ++-- seed/fastapi/examples/core/pydantic_utilities.py | 4 ++-- .../include-validators/core/pydantic_utilities.py | 4 ++-- .../no-custom-config/core/pydantic_utilities.py | 4 ++-- .../exhaustive/pydantic-v1/core/pydantic_utilities.py | 4 ++-- .../exhaustive/pydantic-v2/core/pydantic_utilities.py | 4 ++-- .../skip-formatting/core/pydantic_utilities.py | 4 ++-- seed/fastapi/extends/core/pydantic_utilities.py | 4 ++-- seed/fastapi/extra-properties/core/pydantic_utilities.py | 4 ++-- seed/fastapi/folders/core/pydantic_utilities.py | 4 ++-- seed/fastapi/grpc-proto/core/pydantic_utilities.py | 4 ++-- seed/fastapi/grpc/core/pydantic_utilities.py | 4 ++-- .../idempotency-headers/core/pydantic_utilities.py | 4 ++-- .../imdb/async-handlers/core/pydantic_utilities.py | 4 ++-- .../includes-extra-fields/core/pydantic_utilities.py | 4 ++-- .../imdb/no-custom-config/core/pydantic_utilities.py | 4 ++-- seed/fastapi/mixed-case/core/pydantic_utilities.py | 4 ++-- seed/fastapi/multi-line-docs/core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- .../multi-url-environment/core/pydantic_utilities.py | 4 ++-- seed/fastapi/no-environment/core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- .../oauth-client-credentials/core/pydantic_utilities.py | 4 ++-- seed/fastapi/object/core/pydantic_utilities.py | 4 ++-- .../objects-with-imports/core/pydantic_utilities.py | 4 ++-- seed/fastapi/optional/core/pydantic_utilities.py | 4 ++-- seed/fastapi/package-yml/core/pydantic_utilities.py | 4 ++-- seed/fastapi/pagination/core/pydantic_utilities.py | 4 ++-- seed/fastapi/plain-text/core/pydantic_utilities.py | 4 ++-- .../fastapi/reserved-keywords/core/pydantic_utilities.py | 4 ++-- seed/fastapi/simple-fhir/core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- seed/fastapi/trace/core/pydantic_utilities.py | 4 ++-- .../undiscriminated-unions/core/pydantic_utilities.py | 4 ++-- seed/fastapi/unions/core/pydantic_utilities.py | 4 ++-- seed/fastapi/unknown/core/pydantic_utilities.py | 4 ++-- seed/fastapi/validation/core/pydantic_utilities.py | 4 ++-- seed/fastapi/variables/core/pydantic_utilities.py | 4 ++-- .../version-no-default/core/pydantic_utilities.py | 4 ++-- seed/fastapi/version/core/pydantic_utilities.py | 4 ++-- seed/fastapi/websocket/core/pydantic_utilities.py | 4 ++-- .../src/seed/alias_extends/core/pydantic_utilities.py | 4 ++-- .../alias/src/seed/alias/core/pydantic_utilities.py | 4 ++-- .../seed/api_wide_base_path/core/pydantic_utilities.py | 4 ++-- .../src/seed/audiences/core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- .../src/seed/basic_auth/core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- .../bytes/src/seed/bytes/core/pydantic_utilities.py | 4 ++-- .../src/seed/api/core/pydantic_utilities.py | 4 ++-- .../src/seed/api/core/pydantic_utilities.py | 4 ++-- .../src/seed/code_samples/core/pydantic_utilities.py | 4 ++-- .../src/seed/custom_auth/core/pydantic_utilities.py | 4 ++-- .../enum/src/seed/enum/core/pydantic_utilities.py | 4 ++-- .../src/seed/error_property/core/pydantic_utilities.py | 4 ++-- .../src/seed/examples/core/pydantic_utilities.py | 4 ++-- .../src/seed/exhaustive/core/pydantic_utilities.py | 4 ++-- .../src/seed/exhaustive/core/pydantic_utilities.py | 4 ++-- .../extends/src/seed/extends/core/pydantic_utilities.py | 4 ++-- .../src/seed/extra_properties/core/pydantic_utilities.py | 4 ++-- .../src/seed/file_download/core/pydantic_utilities.py | 4 ++-- .../src/seed/file_upload/core/pydantic_utilities.py | 4 ++-- .../folders/src/seed/api/core/pydantic_utilities.py | 4 ++-- .../grpc-proto/src/seed/api/core/pydantic_utilities.py | 4 ++-- .../grpc/src/seed/api/core/pydantic_utilities.py | 4 ++-- .../seed/idempotency_headers/core/pydantic_utilities.py | 4 ++-- .../imdb/src/seed/api/core/pydantic_utilities.py | 4 ++-- .../literal/src/seed/literal/core/pydantic_utilities.py | 4 ++-- .../src/seed/mixed_case/core/pydantic_utilities.py | 4 ++-- .../src/seed/multi_line_docs/core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- .../multi_url_environment/core/pydantic_utilities.py | 4 ++-- .../src/seed/no_environment/core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- .../oauth_client_credentials/core/pydantic_utilities.py | 4 ++-- .../oauth_client_credentials/core/pydantic_utilities.py | 4 ++-- .../object/src/seed/object/core/pydantic_utilities.py | 4 ++-- .../seed/objects_with_imports/core/pydantic_utilities.py | 4 ++-- .../seed/objects_with_imports/core/pydantic_utilities.py | 4 ++-- .../src/seed/package_yml/core/pydantic_utilities.py | 4 ++-- .../src/seed/pagination/core/pydantic_utilities.py | 4 ++-- .../src/seed/plain_text/core/pydantic_utilities.py | 4 ++-- .../src/seed/query_parameters/core/pydantic_utilities.py | 4 ++-- .../src/seed/nursery_api/core/pydantic_utilities.py | 4 ++-- .../seed/response_property/core/pydantic_utilities.py | 4 ++-- .../simple-fhir/src/seed/api/core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- .../core/pydantic_utilities.py | 4 ++-- .../src/seed/streaming/core/pydantic_utilities.py | 4 ++-- .../src/seed/streaming/core/pydantic_utilities.py | 4 ++-- .../trace/src/seed/trace/core/pydantic_utilities.py | 4 ++-- .../undiscriminated_unions/core/pydantic_utilities.py | 4 ++-- .../unions/src/seed/unions/core/pydantic_utilities.py | 4 ++-- .../src/seed/unknown_as_any/core/pydantic_utilities.py | 4 ++-- .../src/seed/validation/core/pydantic_utilities.py | 4 ++-- .../src/seed/variables/core/pydantic_utilities.py | 4 ++-- .../src/seed/version/core/pydantic_utilities.py | 4 ++-- .../version/src/seed/version/core/pydantic_utilities.py | 4 ++-- .../src/seed/websocket/core/pydantic_utilities.py | 4 ++-- .../alias-extends/src/seed/core/pydantic_utilities.py | 4 ++-- .../alias-extends/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../alias-extends/tests/utils/assets/models/shape.py | 6 ++---- .../alias-extends/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../python-sdk/alias/src/seed/core/pydantic_utilities.py | 4 ++-- .../python-sdk/alias/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- seed/python-sdk/alias/tests/utils/assets/models/shape.py | 6 ++---- .../python-sdk/alias/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../audiences/src/seed/core/pydantic_utilities.py | 4 ++-- .../audiences/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../audiences/tests/utils/assets/models/shape.py | 6 ++---- .../audiences/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../basic-auth/src/seed/core/pydantic_utilities.py | 4 ++-- .../basic-auth/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../basic-auth/tests/utils/assets/models/shape.py | 6 ++---- .../basic-auth/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../python-sdk/bytes/src/seed/core/pydantic_utilities.py | 4 ++-- .../python-sdk/bytes/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- seed/python-sdk/bytes/tests/utils/assets/models/shape.py | 6 ++---- .../python-sdk/bytes/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../code-samples/src/seed/core/pydantic_utilities.py | 4 ++-- .../code-samples/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../code-samples/tests/utils/assets/models/shape.py | 6 ++---- .../code-samples/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../custom-auth/src/seed/core/pydantic_utilities.py | 4 ++-- .../custom-auth/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../custom-auth/tests/utils/assets/models/shape.py | 6 ++---- .../custom-auth/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../no-custom-config/src/seed/core/pydantic_utilities.py | 4 ++-- .../no-custom-config/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../no-custom-config/tests/utils/assets/models/shape.py | 6 ++---- .../no-custom-config/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../enum/real-enum/src/seed/core/pydantic_utilities.py | 4 ++-- .../enum/real-enum/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../enum/real-enum/tests/utils/assets/models/shape.py | 6 ++---- .../enum/real-enum/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../enum/strenum/src/seed/core/pydantic_utilities.py | 4 ++-- .../enum/strenum/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../enum/strenum/tests/utils/assets/models/shape.py | 6 ++---- .../enum/strenum/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../error-property/src/seed/core/pydantic_utilities.py | 4 ++-- .../error-property/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../error-property/tests/utils/assets/models/shape.py | 6 ++---- .../error-property/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../client-filename/src/seed/core/pydantic_utilities.py | 4 ++-- .../client-filename/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../client-filename/tests/utils/assets/models/shape.py | 6 ++---- .../client-filename/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../no-custom-config/src/seed/core/pydantic_utilities.py | 4 ++-- .../no-custom-config/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../no-custom-config/tests/utils/assets/models/shape.py | 6 ++---- .../no-custom-config/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../examples/readme/src/seed/core/pydantic_utilities.py | 4 ++-- .../examples/readme/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../examples/readme/tests/utils/assets/models/shape.py | 6 ++---- .../examples/readme/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../extra_dev_dependencies/src/seed/core/__init__.py | 2 -- .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../improved_imports/src/seed/core/pydantic_utilities.py | 4 ++-- .../improved_imports/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../improved_imports/tests/utils/assets/models/shape.py | 6 ++---- .../improved_imports/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../infinite-timeout/src/seed/core/pydantic_utilities.py | 4 ++-- .../infinite-timeout/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../infinite-timeout/tests/utils/assets/models/shape.py | 6 ++---- .../infinite-timeout/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../no-custom-config/src/seed/core/pydantic_utilities.py | 4 ++-- .../no-custom-config/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../no-custom-config/tests/utils/assets/models/shape.py | 6 ++---- .../no-custom-config/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../pydantic-v1/src/seed/core/pydantic_utilities.py | 4 ++-- .../pydantic-v1/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../pydantic-v1/tests/utils/assets/models/shape.py | 6 ++---- .../pydantic-v1/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../union-utils/src/seed/core/pydantic_utilities.py | 4 ++-- .../union-utils/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../union-utils/tests/utils/assets/models/shape.py | 6 ++---- .../union-utils/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../extends/src/seed/core/pydantic_utilities.py | 4 ++-- .../extends/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../extends/tests/utils/assets/models/shape.py | 6 ++---- .../extends/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../extra-properties/src/seed/core/pydantic_utilities.py | 4 ++-- .../extra-properties/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../extra-properties/tests/utils/assets/models/shape.py | 6 ++---- .../extra-properties/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../file-download/src/seed/core/pydantic_utilities.py | 4 ++-- .../file-download/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../file-download/tests/utils/assets/models/shape.py | 6 ++---- .../file-download/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../file-upload/src/seed/core/pydantic_utilities.py | 4 ++-- .../file-upload/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../file-upload/tests/utils/assets/models/shape.py | 6 ++---- .../file-upload/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../folders/src/seed/core/pydantic_utilities.py | 4 ++-- .../folders/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../folders/tests/utils/assets/models/shape.py | 6 ++---- .../folders/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../grpc-proto/src/seed/core/pydantic_utilities.py | 4 ++-- .../grpc-proto/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../grpc-proto/tests/utils/assets/models/shape.py | 6 ++---- .../grpc-proto/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py | 4 ++-- seed/python-sdk/grpc/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- seed/python-sdk/grpc/tests/utils/assets/models/shape.py | 6 ++---- seed/python-sdk/grpc/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py | 4 ++-- seed/python-sdk/imdb/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- seed/python-sdk/imdb/tests/utils/assets/models/shape.py | 6 ++---- seed/python-sdk/imdb/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../no-custom-config/src/seed/core/pydantic_utilities.py | 4 ++-- .../no-custom-config/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../no-custom-config/tests/utils/assets/models/shape.py | 6 ++---- .../no-custom-config/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../mixed-case/src/seed/core/pydantic_utilities.py | 4 ++-- .../mixed-case/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../mixed-case/tests/utils/assets/models/shape.py | 6 ++---- .../mixed-case/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../multi-line-docs/src/seed/core/pydantic_utilities.py | 4 ++-- .../multi-line-docs/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../multi-line-docs/tests/utils/assets/models/shape.py | 6 ++---- .../multi-line-docs/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../no-environment/src/seed/core/pydantic_utilities.py | 4 ++-- .../no-environment/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../no-environment/tests/utils/assets/models/shape.py | 6 ++---- .../no-environment/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../object/src/seed/core/pydantic_utilities.py | 4 ++-- .../object/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../python-sdk/object/tests/utils/assets/models/shape.py | 6 ++---- .../object/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../optional/src/seed/core/pydantic_utilities.py | 4 ++-- .../optional/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../optional/tests/utils/assets/models/shape.py | 6 ++---- .../optional/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../package-yml/src/seed/core/pydantic_utilities.py | 4 ++-- .../package-yml/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../package-yml/tests/utils/assets/models/shape.py | 6 ++---- .../package-yml/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../pagination/src/seed/core/pydantic_utilities.py | 4 ++-- .../pagination/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../pagination/tests/utils/assets/models/shape.py | 6 ++---- .../pagination/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../plain-text/src/seed/core/pydantic_utilities.py | 4 ++-- .../plain-text/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../plain-text/tests/utils/assets/models/shape.py | 6 ++---- .../plain-text/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../query-parameters/src/seed/core/pydantic_utilities.py | 4 ++-- .../query-parameters/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../query-parameters/tests/utils/assets/models/shape.py | 6 ++---- .../query-parameters/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../reserved-keywords/tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../response-property/tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../simple-fhir/src/seed/core/pydantic_utilities.py | 4 ++-- .../simple-fhir/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../simple-fhir/tests/utils/assets/models/shape.py | 6 ++---- .../simple-fhir/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../no-custom-config/src/seed/core/pydantic_utilities.py | 4 ++-- .../no-custom-config/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../no-custom-config/tests/utils/assets/models/shape.py | 6 ++---- .../no-custom-config/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../python-sdk/trace/src/seed/core/pydantic_utilities.py | 4 ++-- .../python-sdk/trace/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- seed/python-sdk/trace/tests/utils/assets/models/shape.py | 6 ++---- .../python-sdk/trace/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../no-custom-config/src/seed/core/pydantic_utilities.py | 4 ++-- .../no-custom-config/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../no-custom-config/tests/utils/assets/models/shape.py | 6 ++---- .../no-custom-config/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../union-naming-v1/src/seed/core/pydantic_utilities.py | 4 ++-- .../union-naming-v1/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../union-naming-v1/tests/utils/assets/models/shape.py | 6 ++---- .../union-naming-v1/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../union-utils/src/seed/core/pydantic_utilities.py | 4 ++-- .../union-utils/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../union-utils/tests/utils/assets/models/shape.py | 6 ++---- .../union-utils/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../unknown/src/seed/core/pydantic_utilities.py | 4 ++-- .../unknown/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../unknown/tests/utils/assets/models/shape.py | 6 ++---- .../unknown/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../no-custom-config/src/seed/core/pydantic_utilities.py | 4 ++-- .../no-custom-config/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../no-custom-config/tests/utils/assets/models/shape.py | 6 ++---- .../no-custom-config/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../with-defaults/src/seed/core/pydantic_utilities.py | 4 ++-- .../with-defaults/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../with-defaults/tests/utils/assets/models/shape.py | 6 ++---- .../with-defaults/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../variables/src/seed/core/pydantic_utilities.py | 4 ++-- .../variables/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../variables/tests/utils/assets/models/shape.py | 6 ++---- .../variables/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../version/src/seed/core/pydantic_utilities.py | 4 ++-- .../version/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../version/tests/utils/assets/models/shape.py | 6 ++---- .../version/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../websocket/src/seed/core/pydantic_utilities.py | 4 ++-- .../websocket/tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../websocket/tests/utils/assets/models/shape.py | 6 ++---- .../websocket/tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - 690 files changed, 1134 insertions(+), 1383 deletions(-) diff --git a/generators/python/core_utilities/fastapi/__init__.py b/generators/python/core_utilities/fastapi/__init__.py index 8bee1fe7e16..a4b2bfba99c 100644 --- a/generators/python/core_utilities/fastapi/__init__.py +++ b/generators/python/core_utilities/fastapi/__init__.py @@ -1,10 +1,6 @@ from .datetime_utils import serialize_datetime from .exceptions import FernHTTPException, UnauthorizedException -from .pydantic_utilities import ( - IS_PYDANTIC_V2, - UniversalBaseModel, - parse_obj_as, -) +from .pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel, parse_obj_as from .route_args import route_args from .security import BearerToken diff --git a/generators/python/core_utilities/fastapi/pydantic_utilities.py b/generators/python/core_utilities/fastapi/pydantic_utilities.py index 2537c0101d9..15ac7d0634a 100644 --- a/generators/python/core_utilities/fastapi/pydantic_utilities.py +++ b/generators/python/core_utilities/fastapi/pydantic_utilities.py @@ -101,7 +101,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -118,7 +118,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/generators/python/core_utilities/pydantic/pydantic_utilities.py b/generators/python/core_utilities/pydantic/pydantic_utilities.py index 2537c0101d9..15ac7d0634a 100644 --- a/generators/python/core_utilities/pydantic/pydantic_utilities.py +++ b/generators/python/core_utilities/pydantic/pydantic_utilities.py @@ -101,7 +101,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -118,7 +118,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/generators/python/core_utilities/sdk/pydantic_utilities.py b/generators/python/core_utilities/sdk/pydantic_utilities.py index 2537c0101d9..15ac7d0634a 100644 --- a/generators/python/core_utilities/sdk/pydantic_utilities.py +++ b/generators/python/core_utilities/sdk/pydantic_utilities.py @@ -101,7 +101,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -118,7 +118,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/generators/python/tests/utils/example_models/types/core/pydantic_utilities.py b/generators/python/tests/utils/example_models/types/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/generators/python/tests/utils/example_models/types/core/pydantic_utilities.py +++ b/generators/python/tests/utils/example_models/types/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/generators/python/tests/utils/union_utils/types/core/pydantic_utilities.py b/generators/python/tests/utils/union_utils/types/core/pydantic_utilities.py index 142f9ee8db8..16a8c405280 100644 --- a/generators/python/tests/utils/union_utils/types/core/pydantic_utilities.py +++ b/generators/python/tests/utils/union_utils/types/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/alias-extends/core/pydantic_utilities.py b/seed/fastapi/alias-extends/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/alias-extends/core/pydantic_utilities.py +++ b/seed/fastapi/alias-extends/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/alias/core/pydantic_utilities.py b/seed/fastapi/alias/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/alias/core/pydantic_utilities.py +++ b/seed/fastapi/alias/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py b/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py +++ b/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/audiences/core/pydantic_utilities.py b/seed/fastapi/audiences/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/audiences/core/pydantic_utilities.py +++ b/seed/fastapi/audiences/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py b/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py b/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/basic-auth/core/pydantic_utilities.py b/seed/fastapi/basic-auth/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/basic-auth/core/pydantic_utilities.py +++ b/seed/fastapi/basic-auth/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py b/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py +++ b/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py b/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py +++ b/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/circular-references/core/pydantic_utilities.py b/seed/fastapi/circular-references/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/circular-references/core/pydantic_utilities.py +++ b/seed/fastapi/circular-references/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/code-samples/core/pydantic_utilities.py b/seed/fastapi/code-samples/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/code-samples/core/pydantic_utilities.py +++ b/seed/fastapi/code-samples/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/custom-auth/core/pydantic_utilities.py b/seed/fastapi/custom-auth/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/custom-auth/core/pydantic_utilities.py +++ b/seed/fastapi/custom-auth/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/error-property/core/pydantic_utilities.py b/seed/fastapi/error-property/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/error-property/core/pydantic_utilities.py +++ b/seed/fastapi/error-property/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/examples/core/pydantic_utilities.py b/seed/fastapi/examples/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/examples/core/pydantic_utilities.py +++ b/seed/fastapi/examples/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py b/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py b/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py b/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py b/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py b/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/extends/core/pydantic_utilities.py b/seed/fastapi/extends/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/extends/core/pydantic_utilities.py +++ b/seed/fastapi/extends/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/extra-properties/core/pydantic_utilities.py b/seed/fastapi/extra-properties/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/extra-properties/core/pydantic_utilities.py +++ b/seed/fastapi/extra-properties/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/folders/core/pydantic_utilities.py b/seed/fastapi/folders/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/folders/core/pydantic_utilities.py +++ b/seed/fastapi/folders/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/grpc-proto/core/pydantic_utilities.py b/seed/fastapi/grpc-proto/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/grpc-proto/core/pydantic_utilities.py +++ b/seed/fastapi/grpc-proto/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/grpc/core/pydantic_utilities.py b/seed/fastapi/grpc/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/grpc/core/pydantic_utilities.py +++ b/seed/fastapi/grpc/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/idempotency-headers/core/pydantic_utilities.py b/seed/fastapi/idempotency-headers/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/idempotency-headers/core/pydantic_utilities.py +++ b/seed/fastapi/idempotency-headers/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py b/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py b/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py b/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/mixed-case/core/pydantic_utilities.py b/seed/fastapi/mixed-case/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/mixed-case/core/pydantic_utilities.py +++ b/seed/fastapi/mixed-case/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/multi-line-docs/core/pydantic_utilities.py b/seed/fastapi/multi-line-docs/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/multi-line-docs/core/pydantic_utilities.py +++ b/seed/fastapi/multi-line-docs/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/multi-url-environment-no-default/core/pydantic_utilities.py b/seed/fastapi/multi-url-environment-no-default/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/multi-url-environment-no-default/core/pydantic_utilities.py +++ b/seed/fastapi/multi-url-environment-no-default/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/multi-url-environment/core/pydantic_utilities.py b/seed/fastapi/multi-url-environment/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/multi-url-environment/core/pydantic_utilities.py +++ b/seed/fastapi/multi-url-environment/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/no-environment/core/pydantic_utilities.py b/seed/fastapi/no-environment/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/no-environment/core/pydantic_utilities.py +++ b/seed/fastapi/no-environment/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/oauth-client-credentials-environment-variables/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials-environment-variables/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/oauth-client-credentials-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials-environment-variables/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/oauth-client-credentials-nested-root/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials-nested-root/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/oauth-client-credentials-nested-root/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials-nested-root/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/object/core/pydantic_utilities.py b/seed/fastapi/object/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/object/core/pydantic_utilities.py +++ b/seed/fastapi/object/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/objects-with-imports/core/pydantic_utilities.py b/seed/fastapi/objects-with-imports/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/objects-with-imports/core/pydantic_utilities.py +++ b/seed/fastapi/objects-with-imports/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/optional/core/pydantic_utilities.py b/seed/fastapi/optional/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/optional/core/pydantic_utilities.py +++ b/seed/fastapi/optional/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/package-yml/core/pydantic_utilities.py b/seed/fastapi/package-yml/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/package-yml/core/pydantic_utilities.py +++ b/seed/fastapi/package-yml/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/pagination/core/pydantic_utilities.py b/seed/fastapi/pagination/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/pagination/core/pydantic_utilities.py +++ b/seed/fastapi/pagination/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/plain-text/core/pydantic_utilities.py b/seed/fastapi/plain-text/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/plain-text/core/pydantic_utilities.py +++ b/seed/fastapi/plain-text/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/reserved-keywords/core/pydantic_utilities.py b/seed/fastapi/reserved-keywords/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/reserved-keywords/core/pydantic_utilities.py +++ b/seed/fastapi/reserved-keywords/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/simple-fhir/core/pydantic_utilities.py b/seed/fastapi/simple-fhir/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/simple-fhir/core/pydantic_utilities.py +++ b/seed/fastapi/simple-fhir/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py b/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py +++ b/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/single-url-environment-no-default/core/pydantic_utilities.py b/seed/fastapi/single-url-environment-no-default/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/single-url-environment-no-default/core/pydantic_utilities.py +++ b/seed/fastapi/single-url-environment-no-default/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/trace/core/pydantic_utilities.py b/seed/fastapi/trace/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/trace/core/pydantic_utilities.py +++ b/seed/fastapi/trace/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py b/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py +++ b/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/unions/core/pydantic_utilities.py b/seed/fastapi/unions/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/unions/core/pydantic_utilities.py +++ b/seed/fastapi/unions/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/unknown/core/pydantic_utilities.py b/seed/fastapi/unknown/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/unknown/core/pydantic_utilities.py +++ b/seed/fastapi/unknown/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/validation/core/pydantic_utilities.py b/seed/fastapi/validation/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/validation/core/pydantic_utilities.py +++ b/seed/fastapi/validation/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/variables/core/pydantic_utilities.py b/seed/fastapi/variables/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/variables/core/pydantic_utilities.py +++ b/seed/fastapi/variables/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/version-no-default/core/pydantic_utilities.py b/seed/fastapi/version-no-default/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/version-no-default/core/pydantic_utilities.py +++ b/seed/fastapi/version-no-default/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/version/core/pydantic_utilities.py b/seed/fastapi/version/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/version/core/pydantic_utilities.py +++ b/seed/fastapi/version/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/websocket/core/pydantic_utilities.py b/seed/fastapi/websocket/core/pydantic_utilities.py index 142f9ee8db8..e8649d712fb 100644 --- a/seed/fastapi/websocket/core/pydantic_utilities.py +++ b/seed/fastapi/websocket/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/alias-extends/src/seed/alias_extends/core/pydantic_utilities.py b/seed/pydantic/alias-extends/src/seed/alias_extends/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/alias-extends/src/seed/alias_extends/core/pydantic_utilities.py +++ b/seed/pydantic/alias-extends/src/seed/alias_extends/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py b/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py +++ b/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/pydantic_utilities.py b/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/pydantic_utilities.py +++ b/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py b/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py +++ b/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/pydantic_utilities.py b/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/pydantic_utilities.py +++ b/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/pydantic_utilities.py b/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/pydantic_utilities.py +++ b/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/basic-auth/src/seed/basic_auth/core/pydantic_utilities.py b/seed/pydantic/basic-auth/src/seed/basic_auth/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/basic-auth/src/seed/basic_auth/core/pydantic_utilities.py +++ b/seed/pydantic/basic-auth/src/seed/basic_auth/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/pydantic_utilities.py b/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/pydantic_utilities.py +++ b/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py b/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py +++ b/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/circular-references-advanced/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/circular-references-advanced/src/seed/api/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/circular-references-advanced/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/circular-references-advanced/src/seed/api/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/circular-references/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/circular-references/src/seed/api/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/circular-references/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/circular-references/src/seed/api/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/code-samples/src/seed/code_samples/core/pydantic_utilities.py b/seed/pydantic/code-samples/src/seed/code_samples/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/code-samples/src/seed/code_samples/core/pydantic_utilities.py +++ b/seed/pydantic/code-samples/src/seed/code_samples/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/custom-auth/src/seed/custom_auth/core/pydantic_utilities.py b/seed/pydantic/custom-auth/src/seed/custom_auth/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/custom-auth/src/seed/custom_auth/core/pydantic_utilities.py +++ b/seed/pydantic/custom-auth/src/seed/custom_auth/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py b/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py +++ b/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/error-property/src/seed/error_property/core/pydantic_utilities.py b/seed/pydantic/error-property/src/seed/error_property/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/error-property/src/seed/error_property/core/pydantic_utilities.py +++ b/seed/pydantic/error-property/src/seed/error_property/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py b/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py +++ b/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/pydantic_utilities.py b/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/pydantic_utilities.py +++ b/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/pydantic_utilities.py b/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/pydantic_utilities.py +++ b/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py b/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py +++ b/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/extra-properties/src/seed/extra_properties/core/pydantic_utilities.py b/seed/pydantic/extra-properties/src/seed/extra_properties/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/extra-properties/src/seed/extra_properties/core/pydantic_utilities.py +++ b/seed/pydantic/extra-properties/src/seed/extra_properties/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/file-download/src/seed/file_download/core/pydantic_utilities.py b/seed/pydantic/file-download/src/seed/file_download/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/file-download/src/seed/file_download/core/pydantic_utilities.py +++ b/seed/pydantic/file-download/src/seed/file_download/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/file-upload/src/seed/file_upload/core/pydantic_utilities.py b/seed/pydantic/file-upload/src/seed/file_upload/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/file-upload/src/seed/file_upload/core/pydantic_utilities.py +++ b/seed/pydantic/file-upload/src/seed/file_upload/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/grpc-proto/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/grpc-proto/src/seed/api/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/grpc-proto/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/grpc-proto/src/seed/api/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/pydantic_utilities.py b/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/pydantic_utilities.py +++ b/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py b/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py +++ b/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/mixed-case/src/seed/mixed_case/core/pydantic_utilities.py b/seed/pydantic/mixed-case/src/seed/mixed_case/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/mixed-case/src/seed/mixed_case/core/pydantic_utilities.py +++ b/seed/pydantic/mixed-case/src/seed/mixed_case/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/pydantic_utilities.py b/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/pydantic_utilities.py +++ b/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/pydantic_utilities.py b/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/pydantic_utilities.py +++ b/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/pydantic_utilities.py b/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/pydantic_utilities.py +++ b/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/no-environment/src/seed/no_environment/core/pydantic_utilities.py b/seed/pydantic/no-environment/src/seed/no_environment/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/no-environment/src/seed/no_environment/core/pydantic_utilities.py +++ b/seed/pydantic/no-environment/src/seed/no_environment/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/pydantic_utilities.py b/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/pydantic_utilities.py +++ b/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/pydantic_utilities.py b/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/pydantic_utilities.py +++ b/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/pydantic_utilities.py b/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/pydantic_utilities.py +++ b/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/pydantic_utilities.py b/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/pydantic_utilities.py +++ b/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py b/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py +++ b/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/pydantic_utilities.py b/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/pydantic_utilities.py +++ b/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/optional/src/seed/objects_with_imports/core/pydantic_utilities.py b/seed/pydantic/optional/src/seed/objects_with_imports/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/optional/src/seed/objects_with_imports/core/pydantic_utilities.py +++ b/seed/pydantic/optional/src/seed/objects_with_imports/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/package-yml/src/seed/package_yml/core/pydantic_utilities.py b/seed/pydantic/package-yml/src/seed/package_yml/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/package-yml/src/seed/package_yml/core/pydantic_utilities.py +++ b/seed/pydantic/package-yml/src/seed/package_yml/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py b/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py +++ b/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/plain-text/src/seed/plain_text/core/pydantic_utilities.py b/seed/pydantic/plain-text/src/seed/plain_text/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/plain-text/src/seed/plain_text/core/pydantic_utilities.py +++ b/seed/pydantic/plain-text/src/seed/plain_text/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/query-parameters/src/seed/query_parameters/core/pydantic_utilities.py b/seed/pydantic/query-parameters/src/seed/query_parameters/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/query-parameters/src/seed/query_parameters/core/pydantic_utilities.py +++ b/seed/pydantic/query-parameters/src/seed/query_parameters/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/pydantic_utilities.py b/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/pydantic_utilities.py +++ b/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/response-property/src/seed/response_property/core/pydantic_utilities.py b/seed/pydantic/response-property/src/seed/response_property/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/response-property/src/seed/response_property/core/pydantic_utilities.py +++ b/seed/pydantic/response-property/src/seed/response_property/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/simple-fhir/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/simple-fhir/src/seed/api/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/simple-fhir/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/simple-fhir/src/seed/api/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/pydantic_utilities.py b/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/pydantic_utilities.py +++ b/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/pydantic_utilities.py b/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/pydantic_utilities.py +++ b/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/streaming-parameter/src/seed/streaming/core/pydantic_utilities.py b/seed/pydantic/streaming-parameter/src/seed/streaming/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/streaming-parameter/src/seed/streaming/core/pydantic_utilities.py +++ b/seed/pydantic/streaming-parameter/src/seed/streaming/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py b/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py +++ b/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py b/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py +++ b/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/pydantic_utilities.py b/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/pydantic_utilities.py +++ b/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py b/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py +++ b/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/unknown/src/seed/unknown_as_any/core/pydantic_utilities.py b/seed/pydantic/unknown/src/seed/unknown_as_any/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/unknown/src/seed/unknown_as_any/core/pydantic_utilities.py +++ b/seed/pydantic/unknown/src/seed/unknown_as_any/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py b/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py +++ b/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py b/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py +++ b/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/version-no-default/src/seed/version/core/pydantic_utilities.py b/seed/pydantic/version-no-default/src/seed/version/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/version-no-default/src/seed/version/core/pydantic_utilities.py +++ b/seed/pydantic/version-no-default/src/seed/version/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py b/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py +++ b/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py b/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py +++ b/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/alias-extends/src/seed/core/pydantic_utilities.py b/seed/python-sdk/alias-extends/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/alias-extends/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/alias-extends/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/alias-extends/tests/utils/assets/models/circle.py b/seed/python-sdk/alias-extends/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/alias-extends/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/alias-extends/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/alias-extends/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/alias-extends/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/alias-extends/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/alias-extends/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/alias-extends/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/alias-extends/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/alias-extends/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/alias-extends/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/alias-extends/tests/utils/assets/models/shape.py b/seed/python-sdk/alias-extends/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/alias-extends/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/alias-extends/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/alias-extends/tests/utils/assets/models/square.py b/seed/python-sdk/alias-extends/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/alias-extends/tests/utils/assets/models/square.py +++ b/seed/python-sdk/alias-extends/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/alias-extends/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/alias-extends/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/alias-extends/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/alias-extends/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py b/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/alias/tests/utils/assets/models/circle.py b/seed/python-sdk/alias/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/alias/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/alias/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/alias/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/alias/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/alias/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/alias/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/alias/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/alias/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/alias/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/alias/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/alias/tests/utils/assets/models/shape.py b/seed/python-sdk/alias/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/alias/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/alias/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/alias/tests/utils/assets/models/square.py b/seed/python-sdk/alias/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/alias/tests/utils/assets/models/square.py +++ b/seed/python-sdk/alias/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/alias/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/alias/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/alias/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/alias/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/api-wide-base-path/src/seed/core/pydantic_utilities.py b/seed/python-sdk/api-wide-base-path/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/api-wide-base-path/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/api-wide-base-path/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/circle.py b/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/shape.py b/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/square.py b/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/square.py +++ b/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/api-wide-base-path/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py b/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/audiences/tests/utils/assets/models/circle.py b/seed/python-sdk/audiences/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/audiences/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/audiences/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/audiences/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/audiences/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/audiences/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/audiences/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/audiences/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/audiences/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/audiences/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/audiences/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/audiences/tests/utils/assets/models/shape.py b/seed/python-sdk/audiences/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/audiences/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/audiences/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/audiences/tests/utils/assets/models/square.py b/seed/python-sdk/audiences/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/audiences/tests/utils/assets/models/square.py +++ b/seed/python-sdk/audiences/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/audiences/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/audiences/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/audiences/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/audiences/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/auth-environment-variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/auth-environment-variables/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/auth-environment-variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/auth-environment-variables/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/circle.py b/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/shape.py b/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/square.py b/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/square.py +++ b/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/auth-environment-variables/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/circle.py b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/shape.py b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/square.py b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/square.py +++ b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py b/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/basic-auth/tests/utils/assets/models/circle.py b/seed/python-sdk/basic-auth/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/basic-auth/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/basic-auth/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/basic-auth/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/basic-auth/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/basic-auth/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/basic-auth/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/basic-auth/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/basic-auth/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/basic-auth/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/basic-auth/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/basic-auth/tests/utils/assets/models/shape.py b/seed/python-sdk/basic-auth/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/basic-auth/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/basic-auth/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/basic-auth/tests/utils/assets/models/square.py b/seed/python-sdk/basic-auth/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/basic-auth/tests/utils/assets/models/square.py +++ b/seed/python-sdk/basic-auth/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/basic-auth/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/basic-auth/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/basic-auth/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/basic-auth/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/bearer-token-environment-variable/src/seed/core/pydantic_utilities.py b/seed/python-sdk/bearer-token-environment-variable/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/bearer-token-environment-variable/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/bearer-token-environment-variable/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/circle.py b/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/shape.py b/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/square.py b/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/square.py +++ b/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/bearer-token-environment-variable/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py b/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/bytes/tests/utils/assets/models/circle.py b/seed/python-sdk/bytes/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/bytes/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/bytes/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/bytes/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/bytes/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/bytes/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/bytes/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/bytes/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/bytes/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/bytes/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/bytes/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/bytes/tests/utils/assets/models/shape.py b/seed/python-sdk/bytes/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/bytes/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/bytes/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/bytes/tests/utils/assets/models/square.py b/seed/python-sdk/bytes/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/bytes/tests/utils/assets/models/square.py +++ b/seed/python-sdk/bytes/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/bytes/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/bytes/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/bytes/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/bytes/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py b/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/circle.py b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/shape.py b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/square.py b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/square.py +++ b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py b/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/circular-references/tests/utils/assets/models/circle.py b/seed/python-sdk/circular-references/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/circular-references/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/circular-references/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/circular-references/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/circular-references/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/circular-references/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/circular-references/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/circular-references/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/circular-references/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/circular-references/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/circular-references/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/circular-references/tests/utils/assets/models/shape.py b/seed/python-sdk/circular-references/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/circular-references/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/circular-references/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/circular-references/tests/utils/assets/models/square.py b/seed/python-sdk/circular-references/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/circular-references/tests/utils/assets/models/square.py +++ b/seed/python-sdk/circular-references/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/circular-references/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/circular-references/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/circular-references/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/circular-references/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/code-samples/src/seed/core/pydantic_utilities.py b/seed/python-sdk/code-samples/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/code-samples/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/code-samples/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/code-samples/tests/utils/assets/models/circle.py b/seed/python-sdk/code-samples/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/code-samples/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/code-samples/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/code-samples/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/code-samples/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/code-samples/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/code-samples/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/code-samples/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/code-samples/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/code-samples/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/code-samples/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/code-samples/tests/utils/assets/models/shape.py b/seed/python-sdk/code-samples/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/code-samples/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/code-samples/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/code-samples/tests/utils/assets/models/square.py b/seed/python-sdk/code-samples/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/code-samples/tests/utils/assets/models/square.py +++ b/seed/python-sdk/code-samples/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/code-samples/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/code-samples/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/code-samples/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/code-samples/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py b/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/custom-auth/tests/utils/assets/models/circle.py b/seed/python-sdk/custom-auth/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/custom-auth/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/custom-auth/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/custom-auth/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/custom-auth/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/custom-auth/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/custom-auth/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/custom-auth/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/custom-auth/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/custom-auth/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/custom-auth/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/custom-auth/tests/utils/assets/models/shape.py b/seed/python-sdk/custom-auth/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/custom-auth/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/custom-auth/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/custom-auth/tests/utils/assets/models/square.py b/seed/python-sdk/custom-auth/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/custom-auth/tests/utils/assets/models/square.py +++ b/seed/python-sdk/custom-auth/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/custom-auth/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/custom-auth/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/custom-auth/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/custom-auth/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/circle.py b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/shape.py b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/square.py b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/square.py +++ b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/circle.py b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/shape.py b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/square.py b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/square.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/circle.py b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/shape.py b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/square.py b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/square.py +++ b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/enum/strenum/tests/utils/assets/models/circle.py b/seed/python-sdk/enum/strenum/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/enum/strenum/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/enum/strenum/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/strenum/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/enum/strenum/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/enum/strenum/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/enum/strenum/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/enum/strenum/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/enum/strenum/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/enum/strenum/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/enum/strenum/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/enum/strenum/tests/utils/assets/models/shape.py b/seed/python-sdk/enum/strenum/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/enum/strenum/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/enum/strenum/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/strenum/tests/utils/assets/models/square.py b/seed/python-sdk/enum/strenum/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/enum/strenum/tests/utils/assets/models/square.py +++ b/seed/python-sdk/enum/strenum/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/strenum/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/enum/strenum/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/enum/strenum/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/enum/strenum/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py b/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/error-property/tests/utils/assets/models/circle.py b/seed/python-sdk/error-property/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/error-property/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/error-property/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/error-property/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/error-property/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/error-property/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/error-property/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/error-property/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/error-property/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/error-property/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/error-property/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/error-property/tests/utils/assets/models/shape.py b/seed/python-sdk/error-property/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/error-property/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/error-property/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/error-property/tests/utils/assets/models/square.py b/seed/python-sdk/error-property/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/error-property/tests/utils/assets/models/square.py +++ b/seed/python-sdk/error-property/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/error-property/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/error-property/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/error-property/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/error-property/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py b/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/circle.py b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/shape.py b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/square.py b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/square.py +++ b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/circle.py b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/shape.py b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/square.py b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/square.py +++ b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py b/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/examples/readme/tests/utils/assets/models/circle.py b/seed/python-sdk/examples/readme/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/examples/readme/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/examples/readme/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/readme/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/examples/readme/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/examples/readme/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/examples/readme/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/examples/readme/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/examples/readme/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/examples/readme/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/examples/readme/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/examples/readme/tests/utils/assets/models/shape.py b/seed/python-sdk/examples/readme/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/examples/readme/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/examples/readme/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/readme/tests/utils/assets/models/square.py b/seed/python-sdk/examples/readme/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/examples/readme/tests/utils/assets/models/square.py +++ b/seed/python-sdk/examples/readme/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/readme/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/examples/readme/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/examples/readme/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/examples/readme/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/__init__.py index 5a0bee343d0..4213c349a1d 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/__init__.py @@ -10,7 +10,6 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, - deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -36,7 +35,6 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", - "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py b/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/extends/tests/utils/assets/models/circle.py b/seed/python-sdk/extends/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/extends/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/extends/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/extends/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/extends/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/extends/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/extends/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/extends/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/extends/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/extends/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/extends/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/extends/tests/utils/assets/models/shape.py b/seed/python-sdk/extends/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/extends/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/extends/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/extends/tests/utils/assets/models/square.py b/seed/python-sdk/extends/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/extends/tests/utils/assets/models/square.py +++ b/seed/python-sdk/extends/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/extends/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/extends/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/extends/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/extends/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py b/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/extra-properties/tests/utils/assets/models/circle.py b/seed/python-sdk/extra-properties/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/extra-properties/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/extra-properties/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/extra-properties/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/extra-properties/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/extra-properties/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/extra-properties/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/extra-properties/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/extra-properties/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/extra-properties/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/extra-properties/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/extra-properties/tests/utils/assets/models/shape.py b/seed/python-sdk/extra-properties/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/extra-properties/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/extra-properties/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/extra-properties/tests/utils/assets/models/square.py b/seed/python-sdk/extra-properties/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/extra-properties/tests/utils/assets/models/square.py +++ b/seed/python-sdk/extra-properties/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/extra-properties/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/extra-properties/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/extra-properties/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/extra-properties/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/file-download/src/seed/core/pydantic_utilities.py b/seed/python-sdk/file-download/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/file-download/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/file-download/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/file-download/tests/utils/assets/models/circle.py b/seed/python-sdk/file-download/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/file-download/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/file-download/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/file-download/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/file-download/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/file-download/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/file-download/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/file-download/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/file-download/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/file-download/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/file-download/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/file-download/tests/utils/assets/models/shape.py b/seed/python-sdk/file-download/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/file-download/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/file-download/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/file-download/tests/utils/assets/models/square.py b/seed/python-sdk/file-download/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/file-download/tests/utils/assets/models/square.py +++ b/seed/python-sdk/file-download/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/file-download/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/file-download/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/file-download/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/file-download/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/file-upload/src/seed/core/pydantic_utilities.py b/seed/python-sdk/file-upload/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/file-upload/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/file-upload/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/file-upload/tests/utils/assets/models/circle.py b/seed/python-sdk/file-upload/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/file-upload/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/file-upload/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/file-upload/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/file-upload/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/file-upload/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/file-upload/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/file-upload/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/file-upload/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/file-upload/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/file-upload/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/file-upload/tests/utils/assets/models/shape.py b/seed/python-sdk/file-upload/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/file-upload/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/file-upload/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/file-upload/tests/utils/assets/models/square.py b/seed/python-sdk/file-upload/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/file-upload/tests/utils/assets/models/square.py +++ b/seed/python-sdk/file-upload/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/file-upload/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/file-upload/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/file-upload/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/file-upload/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py b/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/folders/tests/utils/assets/models/circle.py b/seed/python-sdk/folders/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/folders/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/folders/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/folders/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/folders/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/folders/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/folders/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/folders/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/folders/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/folders/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/folders/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/folders/tests/utils/assets/models/shape.py b/seed/python-sdk/folders/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/folders/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/folders/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/folders/tests/utils/assets/models/square.py b/seed/python-sdk/folders/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/folders/tests/utils/assets/models/square.py +++ b/seed/python-sdk/folders/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/folders/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/folders/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/folders/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/folders/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py b/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/grpc-proto/tests/utils/assets/models/circle.py b/seed/python-sdk/grpc-proto/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/grpc-proto/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/grpc-proto/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/grpc-proto/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/grpc-proto/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/grpc-proto/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/grpc-proto/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/grpc-proto/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/grpc-proto/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/grpc-proto/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/grpc-proto/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/grpc-proto/tests/utils/assets/models/shape.py b/seed/python-sdk/grpc-proto/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/grpc-proto/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/grpc-proto/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/grpc-proto/tests/utils/assets/models/square.py b/seed/python-sdk/grpc-proto/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/grpc-proto/tests/utils/assets/models/square.py +++ b/seed/python-sdk/grpc-proto/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/grpc-proto/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/grpc-proto/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/grpc-proto/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/grpc-proto/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py b/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/grpc/tests/utils/assets/models/circle.py b/seed/python-sdk/grpc/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/grpc/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/grpc/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/grpc/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/grpc/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/grpc/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/grpc/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/grpc/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/grpc/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/grpc/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/grpc/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/grpc/tests/utils/assets/models/shape.py b/seed/python-sdk/grpc/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/grpc/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/grpc/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/grpc/tests/utils/assets/models/square.py b/seed/python-sdk/grpc/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/grpc/tests/utils/assets/models/square.py +++ b/seed/python-sdk/grpc/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/grpc/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/grpc/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/grpc/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/grpc/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/idempotency-headers/src/seed/core/pydantic_utilities.py b/seed/python-sdk/idempotency-headers/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/idempotency-headers/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/idempotency-headers/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/idempotency-headers/tests/utils/assets/models/circle.py b/seed/python-sdk/idempotency-headers/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/idempotency-headers/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/idempotency-headers/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/idempotency-headers/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/idempotency-headers/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/idempotency-headers/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/idempotency-headers/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/idempotency-headers/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/idempotency-headers/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/idempotency-headers/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/idempotency-headers/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/idempotency-headers/tests/utils/assets/models/shape.py b/seed/python-sdk/idempotency-headers/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/idempotency-headers/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/idempotency-headers/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/idempotency-headers/tests/utils/assets/models/square.py b/seed/python-sdk/idempotency-headers/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/idempotency-headers/tests/utils/assets/models/square.py +++ b/seed/python-sdk/idempotency-headers/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/idempotency-headers/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/idempotency-headers/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/idempotency-headers/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/idempotency-headers/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py b/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/imdb/tests/utils/assets/models/circle.py b/seed/python-sdk/imdb/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/imdb/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/imdb/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/imdb/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/imdb/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/imdb/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/imdb/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/imdb/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/imdb/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/imdb/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/imdb/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/imdb/tests/utils/assets/models/shape.py b/seed/python-sdk/imdb/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/imdb/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/imdb/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/imdb/tests/utils/assets/models/square.py b/seed/python-sdk/imdb/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/imdb/tests/utils/assets/models/square.py +++ b/seed/python-sdk/imdb/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/imdb/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/imdb/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/imdb/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/imdb/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/circle.py b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/shape.py b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/square.py b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/square.py +++ b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py b/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/circle.py b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/shape.py b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/square.py b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/square.py +++ b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/mixed-case/src/seed/core/pydantic_utilities.py b/seed/python-sdk/mixed-case/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/mixed-case/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/mixed-case/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/mixed-case/tests/utils/assets/models/circle.py b/seed/python-sdk/mixed-case/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/mixed-case/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/mixed-case/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/mixed-case/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/mixed-case/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/mixed-case/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/mixed-case/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/mixed-case/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/mixed-case/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/mixed-case/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/mixed-case/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/mixed-case/tests/utils/assets/models/shape.py b/seed/python-sdk/mixed-case/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/mixed-case/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/mixed-case/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/mixed-case/tests/utils/assets/models/square.py b/seed/python-sdk/mixed-case/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/mixed-case/tests/utils/assets/models/square.py +++ b/seed/python-sdk/mixed-case/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/mixed-case/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/mixed-case/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/mixed-case/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/mixed-case/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py b/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/circle.py b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/shape.py b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/square.py b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/square.py +++ b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/circle.py b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/shape.py b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/square.py b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/square.py +++ b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py b/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/circle.py b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/shape.py b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/square.py b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/square.py +++ b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/no-environment/src/seed/core/pydantic_utilities.py b/seed/python-sdk/no-environment/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/no-environment/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/no-environment/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/no-environment/tests/utils/assets/models/circle.py b/seed/python-sdk/no-environment/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/no-environment/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/no-environment/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/no-environment/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/no-environment/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/no-environment/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/no-environment/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/no-environment/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/no-environment/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/no-environment/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/no-environment/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/no-environment/tests/utils/assets/models/shape.py b/seed/python-sdk/no-environment/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/no-environment/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/no-environment/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/no-environment/tests/utils/assets/models/square.py b/seed/python-sdk/no-environment/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/no-environment/tests/utils/assets/models/square.py +++ b/seed/python-sdk/no-environment/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/no-environment/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/no-environment/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/no-environment/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/no-environment/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/oauth-client-credentials-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/oauth-client-credentials-default/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/oauth-client-credentials-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/oauth-client-credentials-default/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/circle.py b/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/shape.py b/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/square.py b/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/square.py +++ b/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/oauth-client-credentials-default/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/circle.py b/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/shape.py b/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/square.py b/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/square.py +++ b/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/oauth-client-credentials-environment-variables/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py b/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/circle.py b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/shape.py b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/square.py b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/square.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/oauth-client-credentials/src/seed/core/pydantic_utilities.py b/seed/python-sdk/oauth-client-credentials/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/oauth-client-credentials/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/oauth-client-credentials/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/circle.py b/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/shape.py b/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/square.py b/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/square.py +++ b/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/oauth-client-credentials/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/object/src/seed/core/pydantic_utilities.py b/seed/python-sdk/object/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/object/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/object/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/object/tests/utils/assets/models/circle.py b/seed/python-sdk/object/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/object/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/object/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/object/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/object/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/object/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/object/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/object/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/object/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/object/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/object/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/object/tests/utils/assets/models/shape.py b/seed/python-sdk/object/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/object/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/object/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/object/tests/utils/assets/models/square.py b/seed/python-sdk/object/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/object/tests/utils/assets/models/square.py +++ b/seed/python-sdk/object/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/object/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/object/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/object/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/object/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py b/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/circle.py b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/shape.py b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/square.py b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/square.py +++ b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py b/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/optional/tests/utils/assets/models/circle.py b/seed/python-sdk/optional/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/optional/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/optional/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/optional/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/optional/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/optional/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/optional/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/optional/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/optional/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/optional/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/optional/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/optional/tests/utils/assets/models/shape.py b/seed/python-sdk/optional/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/optional/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/optional/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/optional/tests/utils/assets/models/square.py b/seed/python-sdk/optional/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/optional/tests/utils/assets/models/square.py +++ b/seed/python-sdk/optional/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/optional/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/optional/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/optional/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/optional/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py b/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/package-yml/tests/utils/assets/models/circle.py b/seed/python-sdk/package-yml/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/package-yml/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/package-yml/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/package-yml/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/package-yml/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/package-yml/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/package-yml/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/package-yml/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/package-yml/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/package-yml/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/package-yml/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/package-yml/tests/utils/assets/models/shape.py b/seed/python-sdk/package-yml/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/package-yml/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/package-yml/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/package-yml/tests/utils/assets/models/square.py b/seed/python-sdk/package-yml/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/package-yml/tests/utils/assets/models/square.py +++ b/seed/python-sdk/package-yml/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/package-yml/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/package-yml/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/package-yml/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/package-yml/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py b/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/pagination/tests/utils/assets/models/circle.py b/seed/python-sdk/pagination/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/pagination/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/pagination/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/pagination/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/pagination/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/pagination/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/pagination/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/pagination/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/pagination/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/pagination/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/pagination/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/pagination/tests/utils/assets/models/shape.py b/seed/python-sdk/pagination/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/pagination/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/pagination/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/pagination/tests/utils/assets/models/square.py b/seed/python-sdk/pagination/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/pagination/tests/utils/assets/models/square.py +++ b/seed/python-sdk/pagination/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/pagination/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/pagination/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/pagination/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/pagination/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py b/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/plain-text/tests/utils/assets/models/circle.py b/seed/python-sdk/plain-text/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/plain-text/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/plain-text/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/plain-text/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/plain-text/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/plain-text/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/plain-text/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/plain-text/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/plain-text/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/plain-text/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/plain-text/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/plain-text/tests/utils/assets/models/shape.py b/seed/python-sdk/plain-text/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/plain-text/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/plain-text/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/plain-text/tests/utils/assets/models/square.py b/seed/python-sdk/plain-text/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/plain-text/tests/utils/assets/models/square.py +++ b/seed/python-sdk/plain-text/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/plain-text/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/plain-text/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/plain-text/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/plain-text/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py b/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/query-parameters/tests/utils/assets/models/circle.py b/seed/python-sdk/query-parameters/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/query-parameters/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/query-parameters/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/query-parameters/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/query-parameters/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/query-parameters/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/query-parameters/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/query-parameters/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/query-parameters/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/query-parameters/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/query-parameters/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/query-parameters/tests/utils/assets/models/shape.py b/seed/python-sdk/query-parameters/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/query-parameters/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/query-parameters/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/query-parameters/tests/utils/assets/models/square.py b/seed/python-sdk/query-parameters/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/query-parameters/tests/utils/assets/models/square.py +++ b/seed/python-sdk/query-parameters/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/query-parameters/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/query-parameters/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/query-parameters/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/query-parameters/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py b/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/circle.py b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/shape.py b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/square.py b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/square.py +++ b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py b/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/response-property/tests/utils/assets/models/circle.py b/seed/python-sdk/response-property/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/response-property/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/response-property/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/response-property/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/response-property/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/response-property/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/response-property/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/response-property/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/response-property/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/response-property/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/response-property/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/response-property/tests/utils/assets/models/shape.py b/seed/python-sdk/response-property/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/response-property/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/response-property/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/response-property/tests/utils/assets/models/square.py b/seed/python-sdk/response-property/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/response-property/tests/utils/assets/models/square.py +++ b/seed/python-sdk/response-property/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/response-property/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/response-property/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/response-property/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/response-property/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py b/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/simple-fhir/tests/utils/assets/models/circle.py b/seed/python-sdk/simple-fhir/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/simple-fhir/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/simple-fhir/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/simple-fhir/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/simple-fhir/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/simple-fhir/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/simple-fhir/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/simple-fhir/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/simple-fhir/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/simple-fhir/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/simple-fhir/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/simple-fhir/tests/utils/assets/models/shape.py b/seed/python-sdk/simple-fhir/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/simple-fhir/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/simple-fhir/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/simple-fhir/tests/utils/assets/models/square.py b/seed/python-sdk/simple-fhir/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/simple-fhir/tests/utils/assets/models/square.py +++ b/seed/python-sdk/simple-fhir/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/simple-fhir/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/simple-fhir/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/simple-fhir/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/simple-fhir/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/circle.py b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/shape.py b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/square.py b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/square.py +++ b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/circle.py b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/shape.py b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/square.py b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/square.py +++ b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py b/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/circle.py b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/shape.py b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/square.py b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/square.py +++ b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/circle.py b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/shape.py b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/square.py b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/square.py +++ b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py b/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/circle.py b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/shape.py b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/square.py b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/square.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py b/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/trace/tests/utils/assets/models/circle.py b/seed/python-sdk/trace/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/trace/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/trace/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/trace/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/trace/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/trace/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/trace/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/trace/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/trace/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/trace/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/trace/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/trace/tests/utils/assets/models/shape.py b/seed/python-sdk/trace/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/trace/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/trace/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/trace/tests/utils/assets/models/square.py b/seed/python-sdk/trace/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/trace/tests/utils/assets/models/square.py +++ b/seed/python-sdk/trace/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/trace/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/trace/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/trace/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/trace/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py b/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/circle.py b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/shape.py b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/square.py b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/square.py +++ b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/circle.py b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/shape.py b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/square.py b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/square.py +++ b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/circle.py b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/shape.py b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/square.py b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/square.py +++ b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/circle.py b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/shape.py b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/square.py b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/square.py +++ b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/unknown/tests/utils/assets/models/circle.py b/seed/python-sdk/unknown/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/unknown/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/unknown/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unknown/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/unknown/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/unknown/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/unknown/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/unknown/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/unknown/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/unknown/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/unknown/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/unknown/tests/utils/assets/models/shape.py b/seed/python-sdk/unknown/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/unknown/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/unknown/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unknown/tests/utils/assets/models/square.py b/seed/python-sdk/unknown/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/unknown/tests/utils/assets/models/square.py +++ b/seed/python-sdk/unknown/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unknown/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/unknown/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/unknown/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/unknown/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/circle.py b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/shape.py b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/square.py b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/square.py +++ b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py b/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/circle.py b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/shape.py b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/square.py b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/square.py +++ b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/variables/tests/utils/assets/models/circle.py b/seed/python-sdk/variables/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/variables/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/variables/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/variables/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/variables/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/variables/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/variables/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/variables/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/variables/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/variables/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/variables/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/variables/tests/utils/assets/models/shape.py b/seed/python-sdk/variables/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/variables/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/variables/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/variables/tests/utils/assets/models/square.py b/seed/python-sdk/variables/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/variables/tests/utils/assets/models/square.py +++ b/seed/python-sdk/variables/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/variables/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/variables/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/variables/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/variables/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/version-no-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/version-no-default/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/version-no-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/version-no-default/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/version-no-default/tests/utils/assets/models/circle.py b/seed/python-sdk/version-no-default/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/version-no-default/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/version-no-default/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/version-no-default/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/version-no-default/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/version-no-default/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/version-no-default/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/version-no-default/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/version-no-default/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/version-no-default/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/version-no-default/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/version-no-default/tests/utils/assets/models/shape.py b/seed/python-sdk/version-no-default/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/version-no-default/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/version-no-default/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/version-no-default/tests/utils/assets/models/square.py b/seed/python-sdk/version-no-default/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/version-no-default/tests/utils/assets/models/square.py +++ b/seed/python-sdk/version-no-default/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/version-no-default/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/version-no-default/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/version-no-default/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/version-no-default/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/version/src/seed/core/pydantic_utilities.py b/seed/python-sdk/version/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/version/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/version/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/version/tests/utils/assets/models/circle.py b/seed/python-sdk/version/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/version/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/version/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/version/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/version/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/version/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/version/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/version/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/version/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/version/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/version/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/version/tests/utils/assets/models/shape.py b/seed/python-sdk/version/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/version/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/version/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/version/tests/utils/assets/models/square.py b/seed/python-sdk/version/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/version/tests/utils/assets/models/square.py +++ b/seed/python-sdk/version/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/version/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/version/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/version/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/version/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py b/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bb9ac35814 100644 --- a/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/websocket/tests/utils/assets/models/circle.py b/seed/python-sdk/websocket/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/websocket/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/websocket/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/websocket/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/websocket/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/websocket/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/websocket/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/websocket/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/websocket/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/websocket/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/websocket/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/websocket/tests/utils/assets/models/shape.py b/seed/python-sdk/websocket/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/websocket/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/websocket/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/websocket/tests/utils/assets/models/square.py b/seed/python-sdk/websocket/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/websocket/tests/utils/assets/models/square.py +++ b/seed/python-sdk/websocket/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/websocket/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/websocket/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/websocket/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/websocket/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams From bf0c92b96951077fed68ec32641e7e01b6a8060b Mon Sep 17 00:00:00 2001 From: armandobelardo Date: Wed, 14 Aug 2024 07:40:39 -0400 Subject: [PATCH 4/7] update seed --- .../python/core_utilities/fastapi/pydantic_utilities.py | 2 +- .../python/core_utilities/pydantic/pydantic_utilities.py | 2 +- .../python/core_utilities/sdk/pydantic_utilities.py | 2 +- .../example_models/types/core/pydantic_utilities.py | 2 +- .../typeddict_models/types/core/pydantic_utilities.py | 4 ++-- seed/fastapi/alias-extends/core/pydantic_utilities.py | 2 +- seed/fastapi/alias/core/pydantic_utilities.py | 2 +- .../api-wide-base-path/core/pydantic_utilities.py | 2 +- seed/fastapi/audiences/core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- seed/fastapi/basic-auth/core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- .../circular-references/core/pydantic_utilities.py | 2 +- seed/fastapi/code-samples/core/pydantic_utilities.py | 2 +- seed/fastapi/custom-auth/core/pydantic_utilities.py | 2 +- seed/fastapi/error-property/core/pydantic_utilities.py | 2 +- seed/fastapi/examples/core/pydantic_utilities.py | 2 +- .../include-validators/core/pydantic_utilities.py | 2 +- .../no-custom-config/core/pydantic_utilities.py | 2 +- .../exhaustive/pydantic-v1/core/pydantic_utilities.py | 2 +- .../exhaustive/pydantic-v2/core/pydantic_utilities.py | 2 +- .../skip-formatting/core/pydantic_utilities.py | 2 +- seed/fastapi/extends/core/pydantic_utilities.py | 2 +- seed/fastapi/extra-properties/core/pydantic_utilities.py | 2 +- seed/fastapi/folders/core/pydantic_utilities.py | 2 +- seed/fastapi/grpc-proto/core/pydantic_utilities.py | 2 +- seed/fastapi/grpc/core/pydantic_utilities.py | 2 +- .../idempotency-headers/core/pydantic_utilities.py | 2 +- .../imdb/async-handlers/core/pydantic_utilities.py | 2 +- .../includes-extra-fields/core/pydantic_utilities.py | 2 +- .../imdb/no-custom-config/core/pydantic_utilities.py | 2 +- seed/fastapi/mixed-case/core/pydantic_utilities.py | 2 +- seed/fastapi/multi-line-docs/core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- .../multi-url-environment/core/pydantic_utilities.py | 2 +- seed/fastapi/no-environment/core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- .../oauth-client-credentials/core/pydantic_utilities.py | 2 +- seed/fastapi/object/core/pydantic_utilities.py | 2 +- .../objects-with-imports/core/pydantic_utilities.py | 2 +- seed/fastapi/optional/core/pydantic_utilities.py | 2 +- seed/fastapi/package-yml/core/pydantic_utilities.py | 2 +- seed/fastapi/pagination/core/pydantic_utilities.py | 2 +- seed/fastapi/plain-text/core/pydantic_utilities.py | 2 +- .../fastapi/reserved-keywords/core/pydantic_utilities.py | 2 +- seed/fastapi/simple-fhir/core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- seed/fastapi/trace/core/pydantic_utilities.py | 2 +- .../undiscriminated-unions/core/pydantic_utilities.py | 2 +- seed/fastapi/unions/core/pydantic_utilities.py | 2 +- seed/fastapi/unknown/core/pydantic_utilities.py | 2 +- seed/fastapi/validation/core/pydantic_utilities.py | 2 +- seed/fastapi/variables/core/pydantic_utilities.py | 2 +- .../version-no-default/core/pydantic_utilities.py | 2 +- seed/fastapi/version/core/pydantic_utilities.py | 2 +- seed/fastapi/websocket/core/pydantic_utilities.py | 2 +- .../src/seed/alias_extends/core/pydantic_utilities.py | 2 +- .../alias/src/seed/alias/core/pydantic_utilities.py | 2 +- .../seed/api_wide_base_path/core/pydantic_utilities.py | 2 +- .../src/seed/audiences/core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- .../src/seed/basic_auth/core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- .../bytes/src/seed/bytes/core/pydantic_utilities.py | 2 +- .../src/seed/api/core/pydantic_utilities.py | 2 +- .../src/seed/api/core/pydantic_utilities.py | 2 +- .../src/seed/code_samples/core/pydantic_utilities.py | 2 +- .../src/seed/custom_auth/core/pydantic_utilities.py | 2 +- .../enum/src/seed/enum/core/pydantic_utilities.py | 2 +- .../src/seed/error_property/core/pydantic_utilities.py | 2 +- .../src/seed/examples/core/pydantic_utilities.py | 2 +- .../src/seed/exhaustive/core/pydantic_utilities.py | 2 +- .../src/seed/exhaustive/core/pydantic_utilities.py | 2 +- .../extends/src/seed/extends/core/pydantic_utilities.py | 2 +- .../src/seed/extra_properties/core/pydantic_utilities.py | 2 +- .../src/seed/file_download/core/pydantic_utilities.py | 2 +- .../src/seed/file_upload/core/pydantic_utilities.py | 2 +- .../folders/src/seed/api/core/pydantic_utilities.py | 2 +- .../grpc-proto/src/seed/api/core/pydantic_utilities.py | 2 +- .../grpc/src/seed/api/core/pydantic_utilities.py | 2 +- .../seed/idempotency_headers/core/pydantic_utilities.py | 2 +- .../imdb/src/seed/api/core/pydantic_utilities.py | 2 +- .../literal/src/seed/literal/core/pydantic_utilities.py | 2 +- .../src/seed/mixed_case/core/pydantic_utilities.py | 2 +- .../src/seed/multi_line_docs/core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- .../multi_url_environment/core/pydantic_utilities.py | 2 +- .../src/seed/no_environment/core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- .../oauth_client_credentials/core/pydantic_utilities.py | 2 +- .../oauth_client_credentials/core/pydantic_utilities.py | 2 +- .../object/src/seed/object/core/pydantic_utilities.py | 2 +- .../seed/objects_with_imports/core/pydantic_utilities.py | 2 +- .../seed/objects_with_imports/core/pydantic_utilities.py | 2 +- .../src/seed/package_yml/core/pydantic_utilities.py | 2 +- .../src/seed/pagination/core/pydantic_utilities.py | 2 +- .../src/seed/plain_text/core/pydantic_utilities.py | 2 +- .../src/seed/query_parameters/core/pydantic_utilities.py | 2 +- .../src/seed/nursery_api/core/pydantic_utilities.py | 2 +- .../seed/response_property/core/pydantic_utilities.py | 2 +- .../simple-fhir/src/seed/api/core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- .../core/pydantic_utilities.py | 2 +- .../src/seed/streaming/core/pydantic_utilities.py | 2 +- .../src/seed/streaming/core/pydantic_utilities.py | 2 +- .../trace/src/seed/trace/core/pydantic_utilities.py | 2 +- .../undiscriminated_unions/core/pydantic_utilities.py | 2 +- .../unions/src/seed/unions/core/pydantic_utilities.py | 2 +- .../src/seed/unknown_as_any/core/pydantic_utilities.py | 2 +- .../src/seed/validation/core/pydantic_utilities.py | 2 +- .../src/seed/variables/core/pydantic_utilities.py | 2 +- .../src/seed/version/core/pydantic_utilities.py | 2 +- .../version/src/seed/version/core/pydantic_utilities.py | 2 +- .../src/seed/websocket/core/pydantic_utilities.py | 2 +- .../alias-extends/src/seed/core/pydantic_utilities.py | 2 +- .../python-sdk/alias/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../audiences/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../basic-auth/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../python-sdk/bytes/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../code-samples/src/seed/core/pydantic_utilities.py | 2 +- .../custom-auth/src/seed/core/pydantic_utilities.py | 2 +- .../no-custom-config/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../enum/real-enum/src/seed/core/pydantic_utilities.py | 2 +- .../enum/strenum/src/seed/core/pydantic_utilities.py | 2 +- .../error-property/src/seed/core/pydantic_utilities.py | 2 +- .../client-filename/src/seed/core/pydantic_utilities.py | 2 +- .../no-custom-config/src/seed/core/pydantic_utilities.py | 2 +- .../examples/readme/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 4 ++-- .../tests/utils/assets/models/circle.py | 2 +- .../tests/utils/assets/models/object_with_defaults.py | 1 + .../utils/assets/models/object_with_optional_field.py | 9 ++++----- .../tests/utils/assets/models/shape.py | 6 ++---- .../tests/utils/assets/models/square.py | 2 +- .../tests/utils/assets/models/undiscriminated_shape.py | 1 - .../src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../improved_imports/src/seed/core/pydantic_utilities.py | 2 +- .../infinite-timeout/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../no-custom-config/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../pydantic-v1/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../union-utils/src/seed/core/pydantic_utilities.py | 2 +- .../extends/src/seed/core/pydantic_utilities.py | 2 +- .../extra-properties/src/seed/core/pydantic_utilities.py | 2 +- .../file-download/src/seed/core/pydantic_utilities.py | 2 +- .../file-upload/src/seed/core/pydantic_utilities.py | 2 +- .../folders/src/seed/core/pydantic_utilities.py | 2 +- .../grpc-proto/src/seed/core/pydantic_utilities.py | 2 +- seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py | 2 +- .../no-custom-config/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../mixed-case/src/seed/core/pydantic_utilities.py | 2 +- .../multi-line-docs/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../no-environment/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../object/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../optional/src/seed/core/pydantic_utilities.py | 2 +- .../package-yml/src/seed/core/pydantic_utilities.py | 2 +- .../pagination/src/seed/core/pydantic_utilities.py | 2 +- .../plain-text/src/seed/core/pydantic_utilities.py | 2 +- .../query-parameters/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../simple-fhir/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../no-custom-config/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../python-sdk/trace/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../no-custom-config/src/seed/core/pydantic_utilities.py | 2 +- .../union-naming-v1/src/seed/core/pydantic_utilities.py | 2 +- .../union-utils/src/seed/core/pydantic_utilities.py | 2 +- .../unknown/src/seed/core/pydantic_utilities.py | 2 +- .../no-custom-config/src/seed/core/pydantic_utilities.py | 2 +- .../with-defaults/src/seed/core/pydantic_utilities.py | 2 +- .../variables/src/seed/core/pydantic_utilities.py | 2 +- .../src/seed/core/pydantic_utilities.py | 2 +- .../version/src/seed/core/pydantic_utilities.py | 2 +- .../websocket/src/seed/core/pydantic_utilities.py | 2 +- 209 files changed, 214 insertions(+), 217 deletions(-) diff --git a/generators/python/core_utilities/fastapi/pydantic_utilities.py b/generators/python/core_utilities/fastapi/pydantic_utilities.py index 15ac7d0634a..fc6909a2991 100644 --- a/generators/python/core_utilities/fastapi/pydantic_utilities.py +++ b/generators/python/core_utilities/fastapi/pydantic_utilities.py @@ -118,7 +118,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/generators/python/core_utilities/pydantic/pydantic_utilities.py b/generators/python/core_utilities/pydantic/pydantic_utilities.py index 15ac7d0634a..fc6909a2991 100644 --- a/generators/python/core_utilities/pydantic/pydantic_utilities.py +++ b/generators/python/core_utilities/pydantic/pydantic_utilities.py @@ -118,7 +118,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/generators/python/core_utilities/sdk/pydantic_utilities.py b/generators/python/core_utilities/sdk/pydantic_utilities.py index 15ac7d0634a..fc6909a2991 100644 --- a/generators/python/core_utilities/sdk/pydantic_utilities.py +++ b/generators/python/core_utilities/sdk/pydantic_utilities.py @@ -118,7 +118,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/generators/python/tests/utils/example_models/types/core/pydantic_utilities.py b/generators/python/tests/utils/example_models/types/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/generators/python/tests/utils/example_models/types/core/pydantic_utilities.py +++ b/generators/python/tests/utils/example_models/types/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/generators/python/tests/utils/typeddict_models/types/core/pydantic_utilities.py b/generators/python/tests/utils/typeddict_models/types/core/pydantic_utilities.py index 142f9ee8db8..16a8c405280 100644 --- a/generators/python/tests/utils/typeddict_models/types/core/pydantic_utilities.py +++ b/generators/python/tests/utils/typeddict_models/types/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/alias-extends/core/pydantic_utilities.py b/seed/fastapi/alias-extends/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/alias-extends/core/pydantic_utilities.py +++ b/seed/fastapi/alias-extends/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/alias/core/pydantic_utilities.py b/seed/fastapi/alias/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/alias/core/pydantic_utilities.py +++ b/seed/fastapi/alias/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py b/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py +++ b/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/audiences/core/pydantic_utilities.py b/seed/fastapi/audiences/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/audiences/core/pydantic_utilities.py +++ b/seed/fastapi/audiences/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py b/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py b/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/basic-auth/core/pydantic_utilities.py b/seed/fastapi/basic-auth/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/basic-auth/core/pydantic_utilities.py +++ b/seed/fastapi/basic-auth/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py b/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py +++ b/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py b/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py +++ b/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/circular-references/core/pydantic_utilities.py b/seed/fastapi/circular-references/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/circular-references/core/pydantic_utilities.py +++ b/seed/fastapi/circular-references/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/code-samples/core/pydantic_utilities.py b/seed/fastapi/code-samples/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/code-samples/core/pydantic_utilities.py +++ b/seed/fastapi/code-samples/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/custom-auth/core/pydantic_utilities.py b/seed/fastapi/custom-auth/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/custom-auth/core/pydantic_utilities.py +++ b/seed/fastapi/custom-auth/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/error-property/core/pydantic_utilities.py b/seed/fastapi/error-property/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/error-property/core/pydantic_utilities.py +++ b/seed/fastapi/error-property/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/examples/core/pydantic_utilities.py b/seed/fastapi/examples/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/examples/core/pydantic_utilities.py +++ b/seed/fastapi/examples/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py b/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py b/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py b/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py b/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py b/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/extends/core/pydantic_utilities.py b/seed/fastapi/extends/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/extends/core/pydantic_utilities.py +++ b/seed/fastapi/extends/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/extra-properties/core/pydantic_utilities.py b/seed/fastapi/extra-properties/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/extra-properties/core/pydantic_utilities.py +++ b/seed/fastapi/extra-properties/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/folders/core/pydantic_utilities.py b/seed/fastapi/folders/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/folders/core/pydantic_utilities.py +++ b/seed/fastapi/folders/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/grpc-proto/core/pydantic_utilities.py b/seed/fastapi/grpc-proto/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/grpc-proto/core/pydantic_utilities.py +++ b/seed/fastapi/grpc-proto/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/grpc/core/pydantic_utilities.py b/seed/fastapi/grpc/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/grpc/core/pydantic_utilities.py +++ b/seed/fastapi/grpc/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/idempotency-headers/core/pydantic_utilities.py b/seed/fastapi/idempotency-headers/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/idempotency-headers/core/pydantic_utilities.py +++ b/seed/fastapi/idempotency-headers/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py b/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py b/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py b/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/mixed-case/core/pydantic_utilities.py b/seed/fastapi/mixed-case/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/mixed-case/core/pydantic_utilities.py +++ b/seed/fastapi/mixed-case/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/multi-line-docs/core/pydantic_utilities.py b/seed/fastapi/multi-line-docs/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/multi-line-docs/core/pydantic_utilities.py +++ b/seed/fastapi/multi-line-docs/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/multi-url-environment-no-default/core/pydantic_utilities.py b/seed/fastapi/multi-url-environment-no-default/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/multi-url-environment-no-default/core/pydantic_utilities.py +++ b/seed/fastapi/multi-url-environment-no-default/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/multi-url-environment/core/pydantic_utilities.py b/seed/fastapi/multi-url-environment/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/multi-url-environment/core/pydantic_utilities.py +++ b/seed/fastapi/multi-url-environment/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/no-environment/core/pydantic_utilities.py b/seed/fastapi/no-environment/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/no-environment/core/pydantic_utilities.py +++ b/seed/fastapi/no-environment/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/oauth-client-credentials-environment-variables/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials-environment-variables/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/oauth-client-credentials-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials-environment-variables/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/oauth-client-credentials-nested-root/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials-nested-root/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/oauth-client-credentials-nested-root/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials-nested-root/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/object/core/pydantic_utilities.py b/seed/fastapi/object/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/object/core/pydantic_utilities.py +++ b/seed/fastapi/object/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/objects-with-imports/core/pydantic_utilities.py b/seed/fastapi/objects-with-imports/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/objects-with-imports/core/pydantic_utilities.py +++ b/seed/fastapi/objects-with-imports/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/optional/core/pydantic_utilities.py b/seed/fastapi/optional/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/optional/core/pydantic_utilities.py +++ b/seed/fastapi/optional/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/package-yml/core/pydantic_utilities.py b/seed/fastapi/package-yml/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/package-yml/core/pydantic_utilities.py +++ b/seed/fastapi/package-yml/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/pagination/core/pydantic_utilities.py b/seed/fastapi/pagination/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/pagination/core/pydantic_utilities.py +++ b/seed/fastapi/pagination/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/plain-text/core/pydantic_utilities.py b/seed/fastapi/plain-text/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/plain-text/core/pydantic_utilities.py +++ b/seed/fastapi/plain-text/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/reserved-keywords/core/pydantic_utilities.py b/seed/fastapi/reserved-keywords/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/reserved-keywords/core/pydantic_utilities.py +++ b/seed/fastapi/reserved-keywords/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/simple-fhir/core/pydantic_utilities.py b/seed/fastapi/simple-fhir/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/simple-fhir/core/pydantic_utilities.py +++ b/seed/fastapi/simple-fhir/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py b/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py +++ b/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/single-url-environment-no-default/core/pydantic_utilities.py b/seed/fastapi/single-url-environment-no-default/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/single-url-environment-no-default/core/pydantic_utilities.py +++ b/seed/fastapi/single-url-environment-no-default/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/trace/core/pydantic_utilities.py b/seed/fastapi/trace/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/trace/core/pydantic_utilities.py +++ b/seed/fastapi/trace/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py b/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py +++ b/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/unions/core/pydantic_utilities.py b/seed/fastapi/unions/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/unions/core/pydantic_utilities.py +++ b/seed/fastapi/unions/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/unknown/core/pydantic_utilities.py b/seed/fastapi/unknown/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/unknown/core/pydantic_utilities.py +++ b/seed/fastapi/unknown/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/validation/core/pydantic_utilities.py b/seed/fastapi/validation/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/validation/core/pydantic_utilities.py +++ b/seed/fastapi/validation/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/variables/core/pydantic_utilities.py b/seed/fastapi/variables/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/variables/core/pydantic_utilities.py +++ b/seed/fastapi/variables/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/version-no-default/core/pydantic_utilities.py b/seed/fastapi/version-no-default/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/version-no-default/core/pydantic_utilities.py +++ b/seed/fastapi/version-no-default/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/version/core/pydantic_utilities.py b/seed/fastapi/version/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/version/core/pydantic_utilities.py +++ b/seed/fastapi/version/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/fastapi/websocket/core/pydantic_utilities.py b/seed/fastapi/websocket/core/pydantic_utilities.py index e8649d712fb..16a8c405280 100644 --- a/seed/fastapi/websocket/core/pydantic_utilities.py +++ b/seed/fastapi/websocket/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/alias-extends/src/seed/alias_extends/core/pydantic_utilities.py b/seed/pydantic/alias-extends/src/seed/alias_extends/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/alias-extends/src/seed/alias_extends/core/pydantic_utilities.py +++ b/seed/pydantic/alias-extends/src/seed/alias_extends/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py b/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py +++ b/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/pydantic_utilities.py b/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/pydantic_utilities.py +++ b/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py b/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py +++ b/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/pydantic_utilities.py b/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/pydantic_utilities.py +++ b/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/pydantic_utilities.py b/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/pydantic_utilities.py +++ b/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/basic-auth/src/seed/basic_auth/core/pydantic_utilities.py b/seed/pydantic/basic-auth/src/seed/basic_auth/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/basic-auth/src/seed/basic_auth/core/pydantic_utilities.py +++ b/seed/pydantic/basic-auth/src/seed/basic_auth/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/pydantic_utilities.py b/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/pydantic_utilities.py +++ b/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py b/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py +++ b/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/circular-references-advanced/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/circular-references-advanced/src/seed/api/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/circular-references-advanced/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/circular-references-advanced/src/seed/api/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/circular-references/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/circular-references/src/seed/api/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/circular-references/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/circular-references/src/seed/api/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/code-samples/src/seed/code_samples/core/pydantic_utilities.py b/seed/pydantic/code-samples/src/seed/code_samples/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/code-samples/src/seed/code_samples/core/pydantic_utilities.py +++ b/seed/pydantic/code-samples/src/seed/code_samples/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/custom-auth/src/seed/custom_auth/core/pydantic_utilities.py b/seed/pydantic/custom-auth/src/seed/custom_auth/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/custom-auth/src/seed/custom_auth/core/pydantic_utilities.py +++ b/seed/pydantic/custom-auth/src/seed/custom_auth/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py b/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py +++ b/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/error-property/src/seed/error_property/core/pydantic_utilities.py b/seed/pydantic/error-property/src/seed/error_property/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/error-property/src/seed/error_property/core/pydantic_utilities.py +++ b/seed/pydantic/error-property/src/seed/error_property/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py b/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py +++ b/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/pydantic_utilities.py b/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/pydantic_utilities.py +++ b/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/pydantic_utilities.py b/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/pydantic_utilities.py +++ b/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py b/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py +++ b/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/extra-properties/src/seed/extra_properties/core/pydantic_utilities.py b/seed/pydantic/extra-properties/src/seed/extra_properties/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/extra-properties/src/seed/extra_properties/core/pydantic_utilities.py +++ b/seed/pydantic/extra-properties/src/seed/extra_properties/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/file-download/src/seed/file_download/core/pydantic_utilities.py b/seed/pydantic/file-download/src/seed/file_download/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/file-download/src/seed/file_download/core/pydantic_utilities.py +++ b/seed/pydantic/file-download/src/seed/file_download/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/file-upload/src/seed/file_upload/core/pydantic_utilities.py b/seed/pydantic/file-upload/src/seed/file_upload/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/file-upload/src/seed/file_upload/core/pydantic_utilities.py +++ b/seed/pydantic/file-upload/src/seed/file_upload/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/grpc-proto/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/grpc-proto/src/seed/api/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/grpc-proto/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/grpc-proto/src/seed/api/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/pydantic_utilities.py b/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/pydantic_utilities.py +++ b/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py b/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py +++ b/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/mixed-case/src/seed/mixed_case/core/pydantic_utilities.py b/seed/pydantic/mixed-case/src/seed/mixed_case/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/mixed-case/src/seed/mixed_case/core/pydantic_utilities.py +++ b/seed/pydantic/mixed-case/src/seed/mixed_case/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/pydantic_utilities.py b/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/pydantic_utilities.py +++ b/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/pydantic_utilities.py b/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/pydantic_utilities.py +++ b/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/pydantic_utilities.py b/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/pydantic_utilities.py +++ b/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/no-environment/src/seed/no_environment/core/pydantic_utilities.py b/seed/pydantic/no-environment/src/seed/no_environment/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/no-environment/src/seed/no_environment/core/pydantic_utilities.py +++ b/seed/pydantic/no-environment/src/seed/no_environment/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/pydantic_utilities.py b/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/pydantic_utilities.py +++ b/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/pydantic_utilities.py b/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/pydantic_utilities.py +++ b/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/pydantic_utilities.py b/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/pydantic_utilities.py +++ b/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/pydantic_utilities.py b/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/pydantic_utilities.py +++ b/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py b/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py +++ b/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/pydantic_utilities.py b/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/pydantic_utilities.py +++ b/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/optional/src/seed/objects_with_imports/core/pydantic_utilities.py b/seed/pydantic/optional/src/seed/objects_with_imports/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/optional/src/seed/objects_with_imports/core/pydantic_utilities.py +++ b/seed/pydantic/optional/src/seed/objects_with_imports/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/package-yml/src/seed/package_yml/core/pydantic_utilities.py b/seed/pydantic/package-yml/src/seed/package_yml/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/package-yml/src/seed/package_yml/core/pydantic_utilities.py +++ b/seed/pydantic/package-yml/src/seed/package_yml/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py b/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py +++ b/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/plain-text/src/seed/plain_text/core/pydantic_utilities.py b/seed/pydantic/plain-text/src/seed/plain_text/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/plain-text/src/seed/plain_text/core/pydantic_utilities.py +++ b/seed/pydantic/plain-text/src/seed/plain_text/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/query-parameters/src/seed/query_parameters/core/pydantic_utilities.py b/seed/pydantic/query-parameters/src/seed/query_parameters/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/query-parameters/src/seed/query_parameters/core/pydantic_utilities.py +++ b/seed/pydantic/query-parameters/src/seed/query_parameters/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/pydantic_utilities.py b/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/pydantic_utilities.py +++ b/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/response-property/src/seed/response_property/core/pydantic_utilities.py b/seed/pydantic/response-property/src/seed/response_property/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/response-property/src/seed/response_property/core/pydantic_utilities.py +++ b/seed/pydantic/response-property/src/seed/response_property/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/simple-fhir/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/simple-fhir/src/seed/api/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/simple-fhir/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/simple-fhir/src/seed/api/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/pydantic_utilities.py b/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/pydantic_utilities.py +++ b/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/pydantic_utilities.py b/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/pydantic_utilities.py +++ b/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/streaming-parameter/src/seed/streaming/core/pydantic_utilities.py b/seed/pydantic/streaming-parameter/src/seed/streaming/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/streaming-parameter/src/seed/streaming/core/pydantic_utilities.py +++ b/seed/pydantic/streaming-parameter/src/seed/streaming/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py b/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py +++ b/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py b/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py +++ b/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/pydantic_utilities.py b/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/pydantic_utilities.py +++ b/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py b/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py +++ b/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/unknown/src/seed/unknown_as_any/core/pydantic_utilities.py b/seed/pydantic/unknown/src/seed/unknown_as_any/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/unknown/src/seed/unknown_as_any/core/pydantic_utilities.py +++ b/seed/pydantic/unknown/src/seed/unknown_as_any/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py b/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py +++ b/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py b/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py +++ b/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/version-no-default/src/seed/version/core/pydantic_utilities.py b/seed/pydantic/version-no-default/src/seed/version/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/version-no-default/src/seed/version/core/pydantic_utilities.py +++ b/seed/pydantic/version-no-default/src/seed/version/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py b/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py +++ b/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py b/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py +++ b/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/alias-extends/src/seed/core/pydantic_utilities.py b/seed/python-sdk/alias-extends/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/alias-extends/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/alias-extends/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py b/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/api-wide-base-path/src/seed/core/pydantic_utilities.py b/seed/python-sdk/api-wide-base-path/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/api-wide-base-path/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/api-wide-base-path/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py b/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/auth-environment-variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/auth-environment-variables/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/auth-environment-variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/auth-environment-variables/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py b/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/bearer-token-environment-variable/src/seed/core/pydantic_utilities.py b/seed/python-sdk/bearer-token-environment-variable/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/bearer-token-environment-variable/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/bearer-token-environment-variable/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py b/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py b/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py b/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/code-samples/src/seed/core/pydantic_utilities.py b/seed/python-sdk/code-samples/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/code-samples/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/code-samples/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py b/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py b/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py b/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py b/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/pydantic_utilities.py index 8f03ff32094..6bf314ee12d 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/pydantic_utilities.py @@ -103,7 +103,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: _fields_set = self.__fields_set__ fields = _get_model_fields(self.__class__) for name, field in fields.items(): - if field not in _fields_set: + if name not in _fields_set: default = _get_field_default(field) # If the default values are non-null act like they've been set @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - return (super().model_dump(**kwargs_with_defaults_exclude_unset),) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/circle.py index 74ecf38c308..6522dc58c5a 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/object_with_defaults.py index a977b1d2aa1..ef14f7b2c9d 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/object_with_defaults.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions +import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/object_with_optional_field.py index 4086c2356b1..fc5a379b967 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/object_with_optional_field.py @@ -2,13 +2,12 @@ # This file was auto-generated by Fern from our API Definition. -import datetime as dt +import typing_extensions import typing -import uuid - import typing_extensions - from seed.core.serialization import FieldMetadata +import datetime as dt +import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -32,4 +31,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Any + any: typing.Optional[typing.Any] diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/shape.py index 7e70010a251..ae113ae0609 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/shape.py @@ -3,11 +3,9 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations - -import typing - import typing_extensions - +import typing_extensions +import typing from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/square.py index 71c7d25fd4a..7f6f79a3ddc 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions - +import typing_extensions from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/undiscriminated_shape.py index 99f12b300d1..68876a23c38 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/undiscriminated_shape.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing - from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py b/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py b/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/file-download/src/seed/core/pydantic_utilities.py b/seed/python-sdk/file-download/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/file-download/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/file-download/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/file-upload/src/seed/core/pydantic_utilities.py b/seed/python-sdk/file-upload/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/file-upload/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/file-upload/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py b/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py b/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py b/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/idempotency-headers/src/seed/core/pydantic_utilities.py b/seed/python-sdk/idempotency-headers/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/idempotency-headers/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/idempotency-headers/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py b/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py b/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/mixed-case/src/seed/core/pydantic_utilities.py b/seed/python-sdk/mixed-case/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/mixed-case/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/mixed-case/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py b/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py b/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/no-environment/src/seed/core/pydantic_utilities.py b/seed/python-sdk/no-environment/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/no-environment/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/no-environment/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/oauth-client-credentials-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/oauth-client-credentials-default/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/oauth-client-credentials-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/oauth-client-credentials-default/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py b/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/oauth-client-credentials/src/seed/core/pydantic_utilities.py b/seed/python-sdk/oauth-client-credentials/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/oauth-client-credentials/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/oauth-client-credentials/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/object/src/seed/core/pydantic_utilities.py b/seed/python-sdk/object/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/object/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/object/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py b/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py b/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py b/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py b/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py b/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py b/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py b/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py b/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py b/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py b/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py b/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py b/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py b/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py b/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/version-no-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/version-no-default/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/version-no-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/version-no-default/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/version/src/seed/core/pydantic_utilities.py b/seed/python-sdk/version/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/version/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/version/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) diff --git a/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py b/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py index 6bb9ac35814..6bf314ee12d 100644 --- a/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py @@ -120,7 +120,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: } if IS_PYDANTIC_V2: - super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 else: return super().dict(**kwargs_with_defaults_exclude_unset) From c82c97193c16bd57e75c1a70ed66a12436d45f05 Mon Sep 17 00:00:00 2001 From: armandobelardo Date: Wed, 14 Aug 2024 13:29:36 -0400 Subject: [PATCH 5/7] seed --- .../fastapi/pydantic_utilities.py | 4 +- .../pydantic/pydantic_utilities.py | 4 +- .../core_utilities/sdk/pydantic_utilities.py | 4 +- ...iscriminated_union_with_utils_generator.py | 22 ++++ .../types/core/pydantic_utilities.py | 4 +- .../python/tests/utils/test_union_utils.py | 3 - .../types/core/pydantic_utilities.py | 4 +- .../types/core/pydantic_utilities.py | 4 +- .../types/resources/types/shape.py | 6 + .../src/seed/core/pydantic_utilities.py | 4 +- .../alias/src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../bytes/src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/types/union/types/animal.py | 6 + .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../proto/google/api/field_behavior.proto | 104 ------------------ .../src/seed/core/pydantic_utilities.py | 4 +- .../grpc/src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../imdb/src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../trace/src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../union-utils/src/seed/types/types/union.py | 6 + .../types/types/union_with_base_properties.py | 6 + .../types/types/union_with_discriminant.py | 6 + .../seed/types/types/union_with_literal.py | 6 + .../types/types/union_with_optional_time.py | 6 + .../seed/types/types/union_with_primitive.py | 6 + .../types/types/union_with_single_element.py | 6 + .../src/seed/types/types/union_with_time.py | 6 + .../seed/types/types/union_with_unknown.py | 6 + .../src/seed/types/types/union_without_key.py | 6 + .../union-utils/src/seed/union/types/shape.py | 6 + .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- 103 files changed, 187 insertions(+), 368 deletions(-) delete mode 100644 seed/python-sdk/grpc-proto/.mock/proto/google/api/field_behavior.proto diff --git a/generators/python/core_utilities/fastapi/pydantic_utilities.py b/generators/python/core_utilities/fastapi/pydantic_utilities.py index fc6909a2991..7a0cc1511e9 100644 --- a/generators/python/core_utilities/fastapi/pydantic_utilities.py +++ b/generators/python/core_utilities/fastapi/pydantic_utilities.py @@ -1,5 +1,3 @@ -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -97,8 +95,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/generators/python/core_utilities/pydantic/pydantic_utilities.py b/generators/python/core_utilities/pydantic/pydantic_utilities.py index fc6909a2991..7a0cc1511e9 100644 --- a/generators/python/core_utilities/pydantic/pydantic_utilities.py +++ b/generators/python/core_utilities/pydantic/pydantic_utilities.py @@ -1,5 +1,3 @@ -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -97,8 +95,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/generators/python/core_utilities/sdk/pydantic_utilities.py b/generators/python/core_utilities/sdk/pydantic_utilities.py index fc6909a2991..7a0cc1511e9 100644 --- a/generators/python/core_utilities/sdk/pydantic_utilities.py +++ b/generators/python/core_utilities/sdk/pydantic_utilities.py @@ -1,5 +1,3 @@ -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -97,8 +95,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/generators/python/src/fern_python/generators/pydantic_model/type_declaration_handler/discriminated_union/discriminated_union_with_utils_generator.py b/generators/python/src/fern_python/generators/pydantic_model/type_declaration_handler/discriminated_union/discriminated_union_with_utils_generator.py index 16d56475792..040326b5168 100644 --- a/generators/python/src/fern_python/generators/pydantic_model/type_declaration_handler/discriminated_union/discriminated_union_with_utils_generator.py +++ b/generators/python/src/fern_python/generators/pydantic_model/type_declaration_handler/discriminated_union/discriminated_union_with_utils_generator.py @@ -1,3 +1,4 @@ +from re import A from typing import List, Optional, Set import fern.ir.resources as ir_types @@ -299,6 +300,27 @@ def generate(self) -> None: for type_id in forward_refed_types: external_pydantic_model.add_ghost_reference(type_id) + + def get_dict_method(writer: AST.NodeWriter) -> None: + writer.write_line("if IS_PYDANTIC_V2:") + with writer.indent(): + writer.write_line('return self.root.dict(**kwargs)') + writer.write_line("else:") + with writer.indent(): + writer.write_line('return self.__root__.dict(**kwargs)') + + external_pydantic_model.add_method_unsafe( + declaration=AST.FunctionDeclaration( + name="dict", + signature=AST.FunctionSignature( + parameters=[AST.FunctionParameter(name="**kwargs", type_hint=AST.TypeHint.any())], + return_type=AST.TypeHint.dict(AST.TypeHint.str_(), AST.TypeHint.any()), + ), + body=AST.CodeWriter(get_dict_method), + ) + ) + + external_pydantic_model.add_method_unsafe( get_visit_method( items=[ diff --git a/generators/python/tests/utils/example_models/types/core/pydantic_utilities.py b/generators/python/tests/utils/example_models/types/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/generators/python/tests/utils/example_models/types/core/pydantic_utilities.py +++ b/generators/python/tests/utils/example_models/types/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/generators/python/tests/utils/test_union_utils.py b/generators/python/tests/utils/test_union_utils.py index 3bc23a5a278..6ddabdfb961 100644 --- a/generators/python/tests/utils/test_union_utils.py +++ b/generators/python/tests/utils/test_union_utils.py @@ -14,6 +14,3 @@ def test_union_utils() -> None: assert is_circle assert circle.dict() == json.loads(dummy) - assert circle.json() == dummy - - print(circle.dict(), circle.json()) \ No newline at end of file diff --git a/generators/python/tests/utils/typeddict_models/types/core/pydantic_utilities.py b/generators/python/tests/utils/typeddict_models/types/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/generators/python/tests/utils/typeddict_models/types/core/pydantic_utilities.py +++ b/generators/python/tests/utils/typeddict_models/types/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/generators/python/tests/utils/union_utils/types/core/pydantic_utilities.py b/generators/python/tests/utils/union_utils/types/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/generators/python/tests/utils/union_utils/types/core/pydantic_utilities.py +++ b/generators/python/tests/utils/union_utils/types/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/generators/python/tests/utils/union_utils/types/resources/types/shape.py b/generators/python/tests/utils/union_utils/types/resources/types/shape.py index e934f59f679..026052115aa 100644 --- a/generators/python/tests/utils/union_utils/types/resources/types/shape.py +++ b/generators/python/tests/utils/union_utils/types/resources/types/shape.py @@ -72,6 +72,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, circle: typing.Callable[[resources_types_circle_Circle], T_Result], diff --git a/seed/python-sdk/alias-extends/src/seed/core/pydantic_utilities.py b/seed/python-sdk/alias-extends/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/alias-extends/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/alias-extends/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py b/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/api-wide-base-path/src/seed/core/pydantic_utilities.py b/seed/python-sdk/api-wide-base-path/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/api-wide-base-path/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/api-wide-base-path/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py b/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/auth-environment-variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/auth-environment-variables/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/auth-environment-variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/auth-environment-variables/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py b/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/bearer-token-environment-variable/src/seed/core/pydantic_utilities.py b/seed/python-sdk/bearer-token-environment-variable/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/bearer-token-environment-variable/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/bearer-token-environment-variable/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py b/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py b/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py b/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py b/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py b/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py b/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py b/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/exhaustive/union-utils/src/seed/types/union/types/animal.py b/seed/python-sdk/exhaustive/union-utils/src/seed/types/union/types/animal.py index be7852ebf72..9b437ed78fb 100644 --- a/seed/python-sdk/exhaustive/union-utils/src/seed/types/union/types/animal.py +++ b/seed/python-sdk/exhaustive/union-utils/src/seed/types/union/types/animal.py @@ -45,6 +45,12 @@ def get_as_union(self) -> typing.Union[_Animal.Dog, _Animal.Cat]: def get_as_union(self) -> typing.Union[_Animal.Dog, _Animal.Cat]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, dog: typing.Callable[[types_union_types_dog_Dog], T_Result], diff --git a/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py b/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py b/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/file-download/src/seed/core/pydantic_utilities.py b/seed/python-sdk/file-download/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/file-download/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/file-download/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/file-upload/src/seed/core/pydantic_utilities.py b/seed/python-sdk/file-upload/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/file-upload/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/file-upload/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py b/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/grpc-proto/.mock/proto/google/api/field_behavior.proto b/seed/python-sdk/grpc-proto/.mock/proto/google/api/field_behavior.proto deleted file mode 100644 index 128799c558d..00000000000 --- a/seed/python-sdk/grpc-proto/.mock/proto/google/api/field_behavior.proto +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api; - -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "FieldBehaviorProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.FieldOptions { - // A designation of a specific field behavior (required, output only, etc.) - // in protobuf messages. - // - // Examples: - // - // string name = 1 [(google.api.field_behavior) = REQUIRED]; - // State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - // google.protobuf.Duration ttl = 1 - // [(google.api.field_behavior) = INPUT_ONLY]; - // google.protobuf.Timestamp expire_time = 1 - // [(google.api.field_behavior) = OUTPUT_ONLY, - // (google.api.field_behavior) = IMMUTABLE]; - repeated google.api.FieldBehavior field_behavior = 1052; -} - -// An indicator of the behavior of a given field (for example, that a field -// is required in requests, or given as output but ignored as input). -// This **does not** change the behavior in protocol buffers itself; it only -// denotes the behavior and may affect how API tooling handles the field. -// -// Note: This enum **may** receive new values in the future. -enum FieldBehavior { - // Conventional default for enums. Do not use this. - FIELD_BEHAVIOR_UNSPECIFIED = 0; - - // Specifically denotes a field as optional. - // While all fields in protocol buffers are optional, this may be specified - // for emphasis if appropriate. - OPTIONAL = 1; - - // Denotes a field as required. - // This indicates that the field **must** be provided as part of the request, - // and failure to do so will cause an error (usually `INVALID_ARGUMENT`). - REQUIRED = 2; - - // Denotes a field as output only. - // This indicates that the field is provided in responses, but including the - // field in a request does nothing (the server *must* ignore it and - // *must not* throw an error as a result of the field's presence). - OUTPUT_ONLY = 3; - - // Denotes a field as input only. - // This indicates that the field is provided in requests, and the - // corresponding field is not included in output. - INPUT_ONLY = 4; - - // Denotes a field as immutable. - // This indicates that the field may be set once in a request to create a - // resource, but may not be changed thereafter. - IMMUTABLE = 5; - - // Denotes that a (repeated) field is an unordered list. - // This indicates that the service may provide the elements of the list - // in any arbitrary order, rather than the order the user originally - // provided. Additionally, the list's order may or may not be stable. - UNORDERED_LIST = 6; - - // Denotes that this field returns a non-empty default value if not set. - // This indicates that if the user provides the empty value in a request, - // a non-empty value will be returned. The user will not be aware of what - // non-empty value to expect. - NON_EMPTY_DEFAULT = 7; - - // Denotes that the field in a resource (a message annotated with - // google.api.resource) is used in the resource name to uniquely identify the - // resource. For AIP-compliant APIs, this should only be applied to the - // `name` field on the resource. - // - // This behavior should not be applied to references to other resources within - // the message. - // - // The identifier field of resources often have different field behavior - // depending on the request it is embedded in (e.g. for Create methods name - // is optional and unused, while for Update methods it is required). Instead - // of method-specific annotations, only `IDENTIFIER` is required. - IDENTIFIER = 8; -} \ No newline at end of file diff --git a/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py b/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py b/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/idempotency-headers/src/seed/core/pydantic_utilities.py b/seed/python-sdk/idempotency-headers/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/idempotency-headers/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/idempotency-headers/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py b/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py b/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/mixed-case/src/seed/core/pydantic_utilities.py b/seed/python-sdk/mixed-case/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/mixed-case/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/mixed-case/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py b/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py b/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/no-environment/src/seed/core/pydantic_utilities.py b/seed/python-sdk/no-environment/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/no-environment/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/no-environment/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/oauth-client-credentials-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/oauth-client-credentials-default/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/oauth-client-credentials-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/oauth-client-credentials-default/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/oauth-client-credentials-environment-variables/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py b/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/oauth-client-credentials/src/seed/core/pydantic_utilities.py b/seed/python-sdk/oauth-client-credentials/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/oauth-client-credentials/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/oauth-client-credentials/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/object/src/seed/core/pydantic_utilities.py b/seed/python-sdk/object/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/object/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/object/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py b/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py b/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py b/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py b/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py b/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py b/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py b/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py b/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py b/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py b/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py b/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py b/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py b/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union.py index 9d3f4887347..b6dfe9a1257 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union.py @@ -48,6 +48,12 @@ def get_as_union(self) -> typing.Union[_Union.Foo, _Union.Bar]: def get_as_union(self) -> typing.Union[_Union.Foo, _Union.Bar]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, foo: typing.Callable[[types_types_foo_Foo], T_Result], diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_base_properties.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_base_properties.py index 528bbf11f80..f5ae247a9ae 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_base_properties.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_base_properties.py @@ -69,6 +69,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, integer: typing.Callable[[int], T_Result], diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_discriminant.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_discriminant.py index de18727f449..7be98ba4bcd 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_discriminant.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_discriminant.py @@ -46,6 +46,12 @@ def get_as_union(self) -> typing.Union[_UnionWithDiscriminant.Foo, _UnionWithDis def get_as_union(self) -> typing.Union[_UnionWithDiscriminant.Foo, _UnionWithDiscriminant.Bar]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, foo: typing.Callable[[types_types_foo_Foo], T_Result], diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_literal.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_literal.py index c0618c1ea12..d2af7baac3b 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_literal.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_literal.py @@ -33,6 +33,12 @@ def get_as_union(self) -> typing.Union[_UnionWithLiteral.Fern]: def get_as_union(self) -> typing.Union[_UnionWithLiteral.Fern]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit(self, fern: typing.Callable[[typing.Literal["fern"]], T_Result]) -> T_Result: unioned_value = self.get_as_union() if unioned_value.type == "fern": diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_optional_time.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_optional_time.py index 642934e1560..bd80996b719 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_optional_time.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_optional_time.py @@ -47,6 +47,12 @@ def get_as_union(self) -> typing.Union[_UnionWithOptionalTime.Date, _UnionWithOp def get_as_union(self) -> typing.Union[_UnionWithOptionalTime.Date, _UnionWithOptionalTime.Dateimte]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, date: typing.Callable[[typing.Optional[dt.date]], T_Result], diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_primitive.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_primitive.py index 12fb115de9d..fcdc1758e91 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_primitive.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_primitive.py @@ -44,6 +44,12 @@ def get_as_union(self) -> typing.Union[_UnionWithPrimitive.Integer, _UnionWithPr def get_as_union(self) -> typing.Union[_UnionWithPrimitive.Integer, _UnionWithPrimitive.String]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit(self, integer: typing.Callable[[int], T_Result], string: typing.Callable[[str], T_Result]) -> T_Result: unioned_value = self.get_as_union() if unioned_value.type == "integer": diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_single_element.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_single_element.py index b235d8263b6..6a7bc84e91f 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_single_element.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_single_element.py @@ -37,6 +37,12 @@ def get_as_union(self) -> typing.Union[_UnionWithSingleElement.Foo]: def get_as_union(self) -> typing.Union[_UnionWithSingleElement.Foo]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit(self, foo: typing.Callable[[types_types_foo_Foo], T_Result]) -> T_Result: unioned_value = self.get_as_union() if unioned_value.type == "foo": diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_time.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_time.py index 41a01b2ca36..785c8f39f4a 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_time.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_time.py @@ -53,6 +53,12 @@ def get_as_union(self) -> typing.Union[_UnionWithTime.Value, _UnionWithTime.Date def get_as_union(self) -> typing.Union[_UnionWithTime.Value, _UnionWithTime.Date, _UnionWithTime.Datetime]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, value: typing.Callable[[int], T_Result], diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_unknown.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_unknown.py index 67bccf1bbec..a50b9b06a29 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_unknown.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_unknown.py @@ -45,6 +45,12 @@ def get_as_union(self) -> typing.Union[_UnionWithUnknown.Foo, _UnionWithUnknown. def get_as_union(self) -> typing.Union[_UnionWithUnknown.Foo, _UnionWithUnknown.Unknown]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, foo: typing.Callable[[types_types_foo_Foo], T_Result], unknown: typing.Callable[[], T_Result] ) -> T_Result: diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_without_key.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_without_key.py index 5b45b23327f..3ecae1641de 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_without_key.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_without_key.py @@ -45,6 +45,12 @@ def get_as_union(self) -> typing.Union[_UnionWithoutKey.Foo, _UnionWithoutKey.Ba def get_as_union(self) -> typing.Union[_UnionWithoutKey.Foo, _UnionWithoutKey.Bar]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, foo: typing.Callable[[types_types_foo_Foo], T_Result], diff --git a/seed/python-sdk/unions/union-utils/src/seed/union/types/shape.py b/seed/python-sdk/unions/union-utils/src/seed/union/types/shape.py index 79999ae2835..dda7645f483 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/union/types/shape.py +++ b/seed/python-sdk/unions/union-utils/src/seed/union/types/shape.py @@ -45,6 +45,12 @@ def get_as_union(self) -> typing.Union[_Shape.Circle, _Shape.Square]: def get_as_union(self) -> typing.Union[_Shape.Circle, _Shape.Square]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, circle: typing.Callable[[union_types_circle_Circle], T_Result], diff --git a/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py b/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/version-no-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/version-no-default/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/version-no-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/version-no-default/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/version/src/seed/core/pydantic_utilities.py b/seed/python-sdk/version/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/version/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/version/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py b/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: From e594654ef89c34b57908d3415fa1ad6aa9c09440 Mon Sep 17 00:00:00 2001 From: armandobelardo Date: Wed, 14 Aug 2024 14:46:41 -0400 Subject: [PATCH 6/7] seed again... --- .../fastapi/pydantic_utilities.py | 2 +- .../pydantic/pydantic_utilities.py | 2 +- ...iscriminated_union_with_utils_generator.py | 23 ++-- .../alias-extends/core/pydantic_utilities.py | 4 +- seed/fastapi/alias/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../audiences/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../basic-auth/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../resources/ast/types/container_value.py | 6 + .../resources/ast/types/field_value.py | 6 + .../core/pydantic_utilities.py | 4 +- .../resources/ast/types/container_value.py | 6 + .../resources/ast/types/field_value.py | 6 + .../custom-auth/core/pydantic_utilities.py | 4 +- .../error-property/core/pydantic_utilities.py | 4 +- .../examples/core/pydantic_utilities.py | 4 +- .../commons/resources/types/types/data.py | 6 + .../resources/types/types/event_info.py | 6 + .../resources/types/types/exception.py | 6 + .../resources/types/types/metadata.py | 6 + .../examples/resources/types/types/test.py | 6 + .../core/pydantic_utilities.py | 4 +- .../types/resources/union/types/animal.py | 6 + .../core/pydantic_utilities.py | 4 +- .../types/resources/union/types/animal.py | 6 + .../pydantic-v1/core/pydantic_utilities.py | 4 +- .../types/resources/union/types/animal.py | 6 + .../pydantic-v2/core/pydantic_utilities.py | 4 +- .../types/resources/union/types/animal.py | 6 + .../core/pydantic_utilities.py | 4 +- .../types/resources/union/types/animal.py | 6 + .../extends/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../folders/core/pydantic_utilities.py | 4 +- .../proto/google/api/field_behavior.proto | 104 ------------------ .../grpc-proto/core/pydantic_utilities.py | 4 +- seed/fastapi/grpc/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../async-handlers/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../mixed-case/core/pydantic_utilities.py | 4 +- .../resources/service/types/resource.py | 6 + .../core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../no-environment/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../fastapi/object/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../optional/core/pydantic_utilities.py | 4 +- .../package-yml/core/pydantic_utilities.py | 4 +- .../pagination/core/pydantic_utilities.py | 4 +- .../plain-text/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../simple-fhir/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- seed/fastapi/trace/core/pydantic_utilities.py | 4 +- .../trace/resources/admin/types/test.py | 6 + .../commons/types/debug_variable_value.py | 6 + .../resources/commons/types/variable_type.py | 6 + .../resources/commons/types/variable_value.py | 6 + .../types/playlist_id_not_found_error_body.py | 6 + .../problem/types/create_problem_error.py | 6 + .../problem/types/create_problem_response.py | 6 + .../types/problem_description_board.py | 6 + .../submission/types/actual_result.py | 6 + .../submission/types/code_execution_update.py | 6 + .../resources/submission/types/error_info.py | 6 + .../submission/types/exception_v_2.py | 6 + .../submission/types/invalid_request_cause.py | 6 + .../submission/types/submission_request.py | 6 + .../submission/types/submission_response.py | 6 + .../types/submission_status_for_test_case.py | 6 + .../submission/types/submission_status_v_2.py | 6 + .../submission/types/submission_type_state.py | 6 + .../submission/types/test_case_grade.py | 6 + .../types/test_submission_status.py | 6 + .../types/test_submission_update_info.py | 6 + .../types/workspace_submission_status.py | 6 + .../types/workspace_submission_update_info.py | 6 + .../problem/types/assert_correctness_check.py | 6 + .../resources/problem/types/custom_files.py | 6 + .../problem/types/function_signature.py | 6 + .../problem/types/test_case_function.py | 6 + ...t_case_implementation_description_board.py | 6 + .../test_case_implementation_reference.py | 6 + .../problem/types/assert_correctness_check.py | 6 + .../resources/problem/types/custom_files.py | 6 + .../problem/types/function_signature.py | 6 + .../problem/types/test_case_function.py | 6 + ...t_case_implementation_description_board.py | 6 + .../test_case_implementation_reference.py | 6 + .../core/pydantic_utilities.py | 4 +- .../fastapi/unions/core/pydantic_utilities.py | 4 +- .../unions/resources/types/types/union.py | 6 + .../types/types/union_with_base_properties.py | 6 + .../types/types/union_with_discriminant.py | 6 + .../types/types/union_with_literal.py | 6 + .../types/types/union_with_optional_time.py | 6 + .../types/types/union_with_primitive.py | 6 + .../types/types/union_with_single_element.py | 6 + .../resources/types/types/union_with_time.py | 6 + .../types/types/union_with_unknown.py | 6 + .../types/types/union_without_key.py | 6 + .../unions/resources/union/types/shape.py | 6 + .../unknown/core/pydantic_utilities.py | 4 +- .../validation/core/pydantic_utilities.py | 4 +- .../variables/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../version/core/pydantic_utilities.py | 4 +- .../websocket/core/pydantic_utilities.py | 4 +- .../alias_extends/core/pydantic_utilities.py | 4 +- .../src/seed/alias/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../seed/audiences/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../basic_auth/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../src/seed/bytes/core/pydantic_utilities.py | 4 +- .../src/seed/api/core/pydantic_utilities.py | 4 +- .../src/seed/api/core/pydantic_utilities.py | 4 +- .../custom_auth/core/pydantic_utilities.py | 4 +- .../src/seed/enum/core/pydantic_utilities.py | 4 +- .../error_property/core/pydantic_utilities.py | 4 +- .../seed/examples/core/pydantic_utilities.py | 4 +- .../exhaustive/core/pydantic_utilities.py | 4 +- .../exhaustive/core/pydantic_utilities.py | 4 +- .../seed/extends/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../file_download/core/pydantic_utilities.py | 4 +- .../file_upload/core/pydantic_utilities.py | 4 +- .../src/seed/api/core/pydantic_utilities.py | 4 +- .../proto/google/api/field_behavior.proto | 104 ------------------ .../src/seed/api/core/pydantic_utilities.py | 4 +- .../src/seed/api/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../src/seed/api/core/pydantic_utilities.py | 4 +- .../seed/literal/core/pydantic_utilities.py | 4 +- .../mixed_case/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../no_environment/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../seed/object/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../package_yml/core/pydantic_utilities.py | 4 +- .../pagination/core/pydantic_utilities.py | 4 +- .../plain_text/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../nursery_api/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../src/seed/api/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../seed/streaming/core/pydantic_utilities.py | 4 +- .../seed/streaming/core/pydantic_utilities.py | 4 +- .../src/seed/trace/core/pydantic_utilities.py | 4 +- .../core/pydantic_utilities.py | 4 +- .../seed/unions/core/pydantic_utilities.py | 4 +- .../unknown_as_any/core/pydantic_utilities.py | 4 +- .../validation/core/pydantic_utilities.py | 4 +- .../seed/variables/core/pydantic_utilities.py | 4 +- .../seed/version/core/pydantic_utilities.py | 4 +- .../seed/version/core/pydantic_utilities.py | 4 +- .../seed/websocket/core/pydantic_utilities.py | 4 +- 180 files changed, 492 insertions(+), 565 deletions(-) delete mode 100644 seed/fastapi/grpc-proto/.mock/proto/google/api/field_behavior.proto delete mode 100644 seed/pydantic/grpc-proto/.mock/proto/google/api/field_behavior.proto diff --git a/generators/python/core_utilities/fastapi/pydantic_utilities.py b/generators/python/core_utilities/fastapi/pydantic_utilities.py index 7a0cc1511e9..d723949ecec 100644 --- a/generators/python/core_utilities/fastapi/pydantic_utilities.py +++ b/generators/python/core_utilities/fastapi/pydantic_utilities.py @@ -96,7 +96,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: `exclude_unset` to work include fields within non-None default values. """ _fields_set = self.__fields_set__ - + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/generators/python/core_utilities/pydantic/pydantic_utilities.py b/generators/python/core_utilities/pydantic/pydantic_utilities.py index 7a0cc1511e9..d723949ecec 100644 --- a/generators/python/core_utilities/pydantic/pydantic_utilities.py +++ b/generators/python/core_utilities/pydantic/pydantic_utilities.py @@ -96,7 +96,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: `exclude_unset` to work include fields within non-None default values. """ _fields_set = self.__fields_set__ - + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/generators/python/src/fern_python/generators/pydantic_model/type_declaration_handler/discriminated_union/discriminated_union_with_utils_generator.py b/generators/python/src/fern_python/generators/pydantic_model/type_declaration_handler/discriminated_union/discriminated_union_with_utils_generator.py index 040326b5168..e57d6e8b7ba 100644 --- a/generators/python/src/fern_python/generators/pydantic_model/type_declaration_handler/discriminated_union/discriminated_union_with_utils_generator.py +++ b/generators/python/src/fern_python/generators/pydantic_model/type_declaration_handler/discriminated_union/discriminated_union_with_utils_generator.py @@ -1,4 +1,3 @@ -from re import A from typing import List, Optional, Set import fern.ir.resources as ir_types @@ -300,26 +299,24 @@ def generate(self) -> None: for type_id in forward_refed_types: external_pydantic_model.add_ghost_reference(type_id) - def get_dict_method(writer: AST.NodeWriter) -> None: writer.write_line("if IS_PYDANTIC_V2:") with writer.indent(): - writer.write_line('return self.root.dict(**kwargs)') + writer.write_line("return self.root.dict(**kwargs)") writer.write_line("else:") with writer.indent(): - writer.write_line('return self.__root__.dict(**kwargs)') - + writer.write_line("return self.__root__.dict(**kwargs)") + external_pydantic_model.add_method_unsafe( declaration=AST.FunctionDeclaration( - name="dict", - signature=AST.FunctionSignature( - parameters=[AST.FunctionParameter(name="**kwargs", type_hint=AST.TypeHint.any())], - return_type=AST.TypeHint.dict(AST.TypeHint.str_(), AST.TypeHint.any()), - ), - body=AST.CodeWriter(get_dict_method), - ) + name="dict", + signature=AST.FunctionSignature( + parameters=[AST.FunctionParameter(name="**kwargs", type_hint=AST.TypeHint.any())], + return_type=AST.TypeHint.dict(AST.TypeHint.str_(), AST.TypeHint.any()), + ), + body=AST.CodeWriter(get_dict_method), + ) ) - external_pydantic_model.add_method_unsafe( get_visit_method( diff --git a/seed/fastapi/alias-extends/core/pydantic_utilities.py b/seed/fastapi/alias-extends/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/alias-extends/core/pydantic_utilities.py +++ b/seed/fastapi/alias-extends/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/alias/core/pydantic_utilities.py b/seed/fastapi/alias/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/alias/core/pydantic_utilities.py +++ b/seed/fastapi/alias/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py b/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py +++ b/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/audiences/core/pydantic_utilities.py b/seed/fastapi/audiences/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/audiences/core/pydantic_utilities.py +++ b/seed/fastapi/audiences/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py b/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py b/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/basic-auth/core/pydantic_utilities.py b/seed/fastapi/basic-auth/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/basic-auth/core/pydantic_utilities.py +++ b/seed/fastapi/basic-auth/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py b/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py +++ b/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py b/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py +++ b/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/circular-references-advanced/resources/ast/types/container_value.py b/seed/fastapi/circular-references-advanced/resources/ast/types/container_value.py index 9fa08538d8a..f17fda2e2f0 100644 --- a/seed/fastapi/circular-references-advanced/resources/ast/types/container_value.py +++ b/seed/fastapi/circular-references-advanced/resources/ast/types/container_value.py @@ -56,6 +56,12 @@ def get_as_union( ) -> typing.Union[_ContainerValue.List, _ContainerValue.Optional]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, list_: typing.Callable[[typing.List["FieldValue"]], T_Result], diff --git a/seed/fastapi/circular-references-advanced/resources/ast/types/field_value.py b/seed/fastapi/circular-references-advanced/resources/ast/types/field_value.py index 26082444ac3..7d8a89b4aa5 100644 --- a/seed/fastapi/circular-references-advanced/resources/ast/types/field_value.py +++ b/seed/fastapi/circular-references-advanced/resources/ast/types/field_value.py @@ -98,6 +98,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, primitive_value: typing.Callable[ diff --git a/seed/fastapi/circular-references/core/pydantic_utilities.py b/seed/fastapi/circular-references/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/circular-references/core/pydantic_utilities.py +++ b/seed/fastapi/circular-references/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/circular-references/resources/ast/types/container_value.py b/seed/fastapi/circular-references/resources/ast/types/container_value.py index 9fa08538d8a..f17fda2e2f0 100644 --- a/seed/fastapi/circular-references/resources/ast/types/container_value.py +++ b/seed/fastapi/circular-references/resources/ast/types/container_value.py @@ -56,6 +56,12 @@ def get_as_union( ) -> typing.Union[_ContainerValue.List, _ContainerValue.Optional]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, list_: typing.Callable[[typing.List["FieldValue"]], T_Result], diff --git a/seed/fastapi/circular-references/resources/ast/types/field_value.py b/seed/fastapi/circular-references/resources/ast/types/field_value.py index 26082444ac3..7d8a89b4aa5 100644 --- a/seed/fastapi/circular-references/resources/ast/types/field_value.py +++ b/seed/fastapi/circular-references/resources/ast/types/field_value.py @@ -98,6 +98,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, primitive_value: typing.Callable[ diff --git a/seed/fastapi/custom-auth/core/pydantic_utilities.py b/seed/fastapi/custom-auth/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/custom-auth/core/pydantic_utilities.py +++ b/seed/fastapi/custom-auth/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/error-property/core/pydantic_utilities.py b/seed/fastapi/error-property/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/error-property/core/pydantic_utilities.py +++ b/seed/fastapi/error-property/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/examples/core/pydantic_utilities.py b/seed/fastapi/examples/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/examples/core/pydantic_utilities.py +++ b/seed/fastapi/examples/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/examples/resources/commons/resources/types/types/data.py b/seed/fastapi/examples/resources/commons/resources/types/types/data.py index e5b5ccfd724..53d9715459c 100644 --- a/seed/fastapi/examples/resources/commons/resources/types/types/data.py +++ b/seed/fastapi/examples/resources/commons/resources/types/types/data.py @@ -54,6 +54,12 @@ def get_as_union(self) -> typing.Union[_Data.String, _Data.Base64]: def get_as_union(self) -> typing.Union[_Data.String, _Data.Base64]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, string: typing.Callable[[str], T_Result], diff --git a/seed/fastapi/examples/resources/commons/resources/types/types/event_info.py b/seed/fastapi/examples/resources/commons/resources/types/types/event_info.py index e4935a5a601..32e55ae0212 100644 --- a/seed/fastapi/examples/resources/commons/resources/types/types/event_info.py +++ b/seed/fastapi/examples/resources/commons/resources/types/types/event_info.py @@ -72,6 +72,12 @@ def get_as_union(self) -> typing.Union[_EventInfo.Metadata, _EventInfo.Tag]: def get_as_union(self) -> typing.Union[_EventInfo.Metadata, _EventInfo.Tag]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, metadata: typing.Callable[ diff --git a/seed/fastapi/examples/resources/types/types/exception.py b/seed/fastapi/examples/resources/types/types/exception.py index 424694d26c2..4752dd12478 100644 --- a/seed/fastapi/examples/resources/types/types/exception.py +++ b/seed/fastapi/examples/resources/types/types/exception.py @@ -67,6 +67,12 @@ def get_as_union(self) -> typing.Union[_Exception.Generic, _Exception.Timeout]: def get_as_union(self) -> typing.Union[_Exception.Generic, _Exception.Timeout]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, generic: typing.Callable[[ExceptionInfo], T_Result], diff --git a/seed/fastapi/examples/resources/types/types/metadata.py b/seed/fastapi/examples/resources/types/types/metadata.py index 802b73c13a5..fa00d52ed5b 100644 --- a/seed/fastapi/examples/resources/types/types/metadata.py +++ b/seed/fastapi/examples/resources/types/types/metadata.py @@ -54,6 +54,12 @@ def get_as_union(self) -> typing.Union[_Metadata.Html, _Metadata.Markdown]: def get_as_union(self) -> typing.Union[_Metadata.Html, _Metadata.Markdown]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, html: typing.Callable[[str], T_Result], diff --git a/seed/fastapi/examples/resources/types/types/test.py b/seed/fastapi/examples/resources/types/types/test.py index 2ca75041be0..3db70306dbe 100644 --- a/seed/fastapi/examples/resources/types/types/test.py +++ b/seed/fastapi/examples/resources/types/types/test.py @@ -52,6 +52,12 @@ def get_as_union(self) -> typing.Union[_Test.And, _Test.Or]: def get_as_union(self) -> typing.Union[_Test.And, _Test.Or]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, and_: typing.Callable[[bool], T_Result], diff --git a/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py b/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/exhaustive/include-validators/resources/types/resources/union/types/animal.py b/seed/fastapi/exhaustive/include-validators/resources/types/resources/union/types/animal.py index b8b29f47d36..d47b4babd4b 100644 --- a/seed/fastapi/exhaustive/include-validators/resources/types/resources/union/types/animal.py +++ b/seed/fastapi/exhaustive/include-validators/resources/types/resources/union/types/animal.py @@ -56,6 +56,12 @@ def get_as_union(self) -> typing.Union[_Animal.Dog, _Animal.Cat]: def get_as_union(self) -> typing.Union[_Animal.Dog, _Animal.Cat]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, dog: typing.Callable[[resources_types_resources_union_types_dog_Dog], T_Result], diff --git a/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py b/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/exhaustive/no-custom-config/resources/types/resources/union/types/animal.py b/seed/fastapi/exhaustive/no-custom-config/resources/types/resources/union/types/animal.py index 7a0a3e38c24..8519bb90188 100644 --- a/seed/fastapi/exhaustive/no-custom-config/resources/types/resources/union/types/animal.py +++ b/seed/fastapi/exhaustive/no-custom-config/resources/types/resources/union/types/animal.py @@ -55,6 +55,12 @@ def get_as_union(self) -> typing.Union[_Animal.Dog, _Animal.Cat]: def get_as_union(self) -> typing.Union[_Animal.Dog, _Animal.Cat]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, dog: typing.Callable[[resources_types_resources_union_types_dog_Dog], T_Result], diff --git a/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py b/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/exhaustive/pydantic-v1/resources/types/resources/union/types/animal.py b/seed/fastapi/exhaustive/pydantic-v1/resources/types/resources/union/types/animal.py index 7a0a3e38c24..8519bb90188 100644 --- a/seed/fastapi/exhaustive/pydantic-v1/resources/types/resources/union/types/animal.py +++ b/seed/fastapi/exhaustive/pydantic-v1/resources/types/resources/union/types/animal.py @@ -55,6 +55,12 @@ def get_as_union(self) -> typing.Union[_Animal.Dog, _Animal.Cat]: def get_as_union(self) -> typing.Union[_Animal.Dog, _Animal.Cat]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, dog: typing.Callable[[resources_types_resources_union_types_dog_Dog], T_Result], diff --git a/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py b/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/exhaustive/pydantic-v2/resources/types/resources/union/types/animal.py b/seed/fastapi/exhaustive/pydantic-v2/resources/types/resources/union/types/animal.py index 7a0a3e38c24..8519bb90188 100644 --- a/seed/fastapi/exhaustive/pydantic-v2/resources/types/resources/union/types/animal.py +++ b/seed/fastapi/exhaustive/pydantic-v2/resources/types/resources/union/types/animal.py @@ -55,6 +55,12 @@ def get_as_union(self) -> typing.Union[_Animal.Dog, _Animal.Cat]: def get_as_union(self) -> typing.Union[_Animal.Dog, _Animal.Cat]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, dog: typing.Callable[[resources_types_resources_union_types_dog_Dog], T_Result], diff --git a/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py b/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/exhaustive/skip-formatting/resources/types/resources/union/types/animal.py b/seed/fastapi/exhaustive/skip-formatting/resources/types/resources/union/types/animal.py index 7a0a3e38c24..8519bb90188 100644 --- a/seed/fastapi/exhaustive/skip-formatting/resources/types/resources/union/types/animal.py +++ b/seed/fastapi/exhaustive/skip-formatting/resources/types/resources/union/types/animal.py @@ -55,6 +55,12 @@ def get_as_union(self) -> typing.Union[_Animal.Dog, _Animal.Cat]: def get_as_union(self) -> typing.Union[_Animal.Dog, _Animal.Cat]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, dog: typing.Callable[[resources_types_resources_union_types_dog_Dog], T_Result], diff --git a/seed/fastapi/extends/core/pydantic_utilities.py b/seed/fastapi/extends/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/extends/core/pydantic_utilities.py +++ b/seed/fastapi/extends/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/extra-properties/core/pydantic_utilities.py b/seed/fastapi/extra-properties/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/extra-properties/core/pydantic_utilities.py +++ b/seed/fastapi/extra-properties/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/folders/core/pydantic_utilities.py b/seed/fastapi/folders/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/folders/core/pydantic_utilities.py +++ b/seed/fastapi/folders/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/grpc-proto/.mock/proto/google/api/field_behavior.proto b/seed/fastapi/grpc-proto/.mock/proto/google/api/field_behavior.proto deleted file mode 100644 index 128799c558d..00000000000 --- a/seed/fastapi/grpc-proto/.mock/proto/google/api/field_behavior.proto +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api; - -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "FieldBehaviorProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.FieldOptions { - // A designation of a specific field behavior (required, output only, etc.) - // in protobuf messages. - // - // Examples: - // - // string name = 1 [(google.api.field_behavior) = REQUIRED]; - // State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - // google.protobuf.Duration ttl = 1 - // [(google.api.field_behavior) = INPUT_ONLY]; - // google.protobuf.Timestamp expire_time = 1 - // [(google.api.field_behavior) = OUTPUT_ONLY, - // (google.api.field_behavior) = IMMUTABLE]; - repeated google.api.FieldBehavior field_behavior = 1052; -} - -// An indicator of the behavior of a given field (for example, that a field -// is required in requests, or given as output but ignored as input). -// This **does not** change the behavior in protocol buffers itself; it only -// denotes the behavior and may affect how API tooling handles the field. -// -// Note: This enum **may** receive new values in the future. -enum FieldBehavior { - // Conventional default for enums. Do not use this. - FIELD_BEHAVIOR_UNSPECIFIED = 0; - - // Specifically denotes a field as optional. - // While all fields in protocol buffers are optional, this may be specified - // for emphasis if appropriate. - OPTIONAL = 1; - - // Denotes a field as required. - // This indicates that the field **must** be provided as part of the request, - // and failure to do so will cause an error (usually `INVALID_ARGUMENT`). - REQUIRED = 2; - - // Denotes a field as output only. - // This indicates that the field is provided in responses, but including the - // field in a request does nothing (the server *must* ignore it and - // *must not* throw an error as a result of the field's presence). - OUTPUT_ONLY = 3; - - // Denotes a field as input only. - // This indicates that the field is provided in requests, and the - // corresponding field is not included in output. - INPUT_ONLY = 4; - - // Denotes a field as immutable. - // This indicates that the field may be set once in a request to create a - // resource, but may not be changed thereafter. - IMMUTABLE = 5; - - // Denotes that a (repeated) field is an unordered list. - // This indicates that the service may provide the elements of the list - // in any arbitrary order, rather than the order the user originally - // provided. Additionally, the list's order may or may not be stable. - UNORDERED_LIST = 6; - - // Denotes that this field returns a non-empty default value if not set. - // This indicates that if the user provides the empty value in a request, - // a non-empty value will be returned. The user will not be aware of what - // non-empty value to expect. - NON_EMPTY_DEFAULT = 7; - - // Denotes that the field in a resource (a message annotated with - // google.api.resource) is used in the resource name to uniquely identify the - // resource. For AIP-compliant APIs, this should only be applied to the - // `name` field on the resource. - // - // This behavior should not be applied to references to other resources within - // the message. - // - // The identifier field of resources often have different field behavior - // depending on the request it is embedded in (e.g. for Create methods name - // is optional and unused, while for Update methods it is required). Instead - // of method-specific annotations, only `IDENTIFIER` is required. - IDENTIFIER = 8; -} \ No newline at end of file diff --git a/seed/fastapi/grpc-proto/core/pydantic_utilities.py b/seed/fastapi/grpc-proto/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/grpc-proto/core/pydantic_utilities.py +++ b/seed/fastapi/grpc-proto/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/grpc/core/pydantic_utilities.py b/seed/fastapi/grpc/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/grpc/core/pydantic_utilities.py +++ b/seed/fastapi/grpc/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/idempotency-headers/core/pydantic_utilities.py b/seed/fastapi/idempotency-headers/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/idempotency-headers/core/pydantic_utilities.py +++ b/seed/fastapi/idempotency-headers/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py b/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py b/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py b/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/mixed-case/core/pydantic_utilities.py b/seed/fastapi/mixed-case/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/mixed-case/core/pydantic_utilities.py +++ b/seed/fastapi/mixed-case/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/mixed-case/resources/service/types/resource.py b/seed/fastapi/mixed-case/resources/service/types/resource.py index 0fb785b417a..646e1f0f72b 100644 --- a/seed/fastapi/mixed-case/resources/service/types/resource.py +++ b/seed/fastapi/mixed-case/resources/service/types/resource.py @@ -79,6 +79,12 @@ def get_as_union(self) -> typing.Union[_Resource.User, _Resource.Organization]: def get_as_union(self) -> typing.Union[_Resource.User, _Resource.Organization]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, user: typing.Callable[[resources_service_types_user_User], T_Result], diff --git a/seed/fastapi/multi-line-docs/core/pydantic_utilities.py b/seed/fastapi/multi-line-docs/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/multi-line-docs/core/pydantic_utilities.py +++ b/seed/fastapi/multi-line-docs/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/multi-url-environment-no-default/core/pydantic_utilities.py b/seed/fastapi/multi-url-environment-no-default/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/multi-url-environment-no-default/core/pydantic_utilities.py +++ b/seed/fastapi/multi-url-environment-no-default/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/multi-url-environment/core/pydantic_utilities.py b/seed/fastapi/multi-url-environment/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/multi-url-environment/core/pydantic_utilities.py +++ b/seed/fastapi/multi-url-environment/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/no-environment/core/pydantic_utilities.py b/seed/fastapi/no-environment/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/no-environment/core/pydantic_utilities.py +++ b/seed/fastapi/no-environment/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/oauth-client-credentials-environment-variables/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials-environment-variables/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/oauth-client-credentials-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials-environment-variables/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/oauth-client-credentials-nested-root/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials-nested-root/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/oauth-client-credentials-nested-root/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials-nested-root/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/object/core/pydantic_utilities.py b/seed/fastapi/object/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/object/core/pydantic_utilities.py +++ b/seed/fastapi/object/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/objects-with-imports/core/pydantic_utilities.py b/seed/fastapi/objects-with-imports/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/objects-with-imports/core/pydantic_utilities.py +++ b/seed/fastapi/objects-with-imports/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/optional/core/pydantic_utilities.py b/seed/fastapi/optional/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/optional/core/pydantic_utilities.py +++ b/seed/fastapi/optional/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/package-yml/core/pydantic_utilities.py b/seed/fastapi/package-yml/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/package-yml/core/pydantic_utilities.py +++ b/seed/fastapi/package-yml/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/pagination/core/pydantic_utilities.py b/seed/fastapi/pagination/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/pagination/core/pydantic_utilities.py +++ b/seed/fastapi/pagination/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/plain-text/core/pydantic_utilities.py b/seed/fastapi/plain-text/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/plain-text/core/pydantic_utilities.py +++ b/seed/fastapi/plain-text/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/reserved-keywords/core/pydantic_utilities.py b/seed/fastapi/reserved-keywords/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/reserved-keywords/core/pydantic_utilities.py +++ b/seed/fastapi/reserved-keywords/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/simple-fhir/core/pydantic_utilities.py b/seed/fastapi/simple-fhir/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/simple-fhir/core/pydantic_utilities.py +++ b/seed/fastapi/simple-fhir/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py b/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py +++ b/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/single-url-environment-no-default/core/pydantic_utilities.py b/seed/fastapi/single-url-environment-no-default/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/single-url-environment-no-default/core/pydantic_utilities.py +++ b/seed/fastapi/single-url-environment-no-default/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/trace/core/pydantic_utilities.py b/seed/fastapi/trace/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/trace/core/pydantic_utilities.py +++ b/seed/fastapi/trace/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/trace/resources/admin/types/test.py b/seed/fastapi/trace/resources/admin/types/test.py index eaee36ee9da..1943ad70ac1 100644 --- a/seed/fastapi/trace/resources/admin/types/test.py +++ b/seed/fastapi/trace/resources/admin/types/test.py @@ -44,6 +44,12 @@ def get_as_union(self) -> typing.Union[_Test.And, _Test.Or]: def get_as_union(self) -> typing.Union[_Test.And, _Test.Or]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, and_: typing.Callable[[bool], T_Result], diff --git a/seed/fastapi/trace/resources/commons/types/debug_variable_value.py b/seed/fastapi/trace/resources/commons/types/debug_variable_value.py index ee07f693466..e06425ba632 100644 --- a/seed/fastapi/trace/resources/commons/types/debug_variable_value.py +++ b/seed/fastapi/trace/resources/commons/types/debug_variable_value.py @@ -266,6 +266,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, integer_value: typing.Callable[[int], T_Result], diff --git a/seed/fastapi/trace/resources/commons/types/variable_type.py b/seed/fastapi/trace/resources/commons/types/variable_type.py index c8010511286..c6b64a16e7b 100644 --- a/seed/fastapi/trace/resources/commons/types/variable_type.py +++ b/seed/fastapi/trace/resources/commons/types/variable_type.py @@ -172,6 +172,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, integer_type: typing.Callable[[], T_Result], diff --git a/seed/fastapi/trace/resources/commons/types/variable_value.py b/seed/fastapi/trace/resources/commons/types/variable_value.py index 572e3edc9a3..768ad036c61 100644 --- a/seed/fastapi/trace/resources/commons/types/variable_value.py +++ b/seed/fastapi/trace/resources/commons/types/variable_value.py @@ -227,6 +227,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, integer_value: typing.Callable[[int], T_Result], diff --git a/seed/fastapi/trace/resources/playlist/types/playlist_id_not_found_error_body.py b/seed/fastapi/trace/resources/playlist/types/playlist_id_not_found_error_body.py index 666680a5963..0c820939ab2 100644 --- a/seed/fastapi/trace/resources/playlist/types/playlist_id_not_found_error_body.py +++ b/seed/fastapi/trace/resources/playlist/types/playlist_id_not_found_error_body.py @@ -43,6 +43,12 @@ def get_as_union(self) -> typing.Union[_PlaylistIdNotFoundErrorBody.PlaylistId]: def get_as_union(self) -> typing.Union[_PlaylistIdNotFoundErrorBody.PlaylistId]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, playlist_id: typing.Callable[ diff --git a/seed/fastapi/trace/resources/problem/types/create_problem_error.py b/seed/fastapi/trace/resources/problem/types/create_problem_error.py index a0d4a4de33b..1465d876107 100644 --- a/seed/fastapi/trace/resources/problem/types/create_problem_error.py +++ b/seed/fastapi/trace/resources/problem/types/create_problem_error.py @@ -41,6 +41,12 @@ def get_as_union(self) -> typing.Union[_CreateProblemError.Generic]: def get_as_union(self) -> typing.Union[_CreateProblemError.Generic]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, generic: typing.Callable[[GenericCreateProblemError], T_Result] ) -> T_Result: diff --git a/seed/fastapi/trace/resources/problem/types/create_problem_response.py b/seed/fastapi/trace/resources/problem/types/create_problem_response.py index d56d2b51a8b..05b1f02fadc 100644 --- a/seed/fastapi/trace/resources/problem/types/create_problem_response.py +++ b/seed/fastapi/trace/resources/problem/types/create_problem_response.py @@ -60,6 +60,12 @@ def get_as_union( ) -> typing.Union[_CreateProblemResponse.Success, _CreateProblemResponse.Error]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, success: typing.Callable[[ProblemId], T_Result], diff --git a/seed/fastapi/trace/resources/problem/types/problem_description_board.py b/seed/fastapi/trace/resources/problem/types/problem_description_board.py index 95b149e79fd..241ff268a6b 100644 --- a/seed/fastapi/trace/resources/problem/types/problem_description_board.py +++ b/seed/fastapi/trace/resources/problem/types/problem_description_board.py @@ -87,6 +87,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, html: typing.Callable[[str], T_Result], diff --git a/seed/fastapi/trace/resources/submission/types/actual_result.py b/seed/fastapi/trace/resources/submission/types/actual_result.py index 7d02147ae79..c44440ece24 100644 --- a/seed/fastapi/trace/resources/submission/types/actual_result.py +++ b/seed/fastapi/trace/resources/submission/types/actual_result.py @@ -83,6 +83,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, value: typing.Callable[[VariableValue], T_Result], diff --git a/seed/fastapi/trace/resources/submission/types/code_execution_update.py b/seed/fastapi/trace/resources/submission/types/code_execution_update.py index 483ba680a4f..88039b1f713 100644 --- a/seed/fastapi/trace/resources/submission/types/code_execution_update.py +++ b/seed/fastapi/trace/resources/submission/types/code_execution_update.py @@ -250,6 +250,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, building_executor: typing.Callable[[BuildingExecutorResponse], T_Result], diff --git a/seed/fastapi/trace/resources/submission/types/error_info.py b/seed/fastapi/trace/resources/submission/types/error_info.py index 7721905003f..8715b38ca75 100644 --- a/seed/fastapi/trace/resources/submission/types/error_info.py +++ b/seed/fastapi/trace/resources/submission/types/error_info.py @@ -106,6 +106,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, compile_error: typing.Callable[ diff --git a/seed/fastapi/trace/resources/submission/types/exception_v_2.py b/seed/fastapi/trace/resources/submission/types/exception_v_2.py index c265af53bc4..8c4cc8953d9 100644 --- a/seed/fastapi/trace/resources/submission/types/exception_v_2.py +++ b/seed/fastapi/trace/resources/submission/types/exception_v_2.py @@ -59,6 +59,12 @@ def get_as_union( ) -> typing.Union[_ExceptionV2.Generic, _ExceptionV2.Timeout]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, generic: typing.Callable[[ExceptionInfo], T_Result], diff --git a/seed/fastapi/trace/resources/submission/types/invalid_request_cause.py b/seed/fastapi/trace/resources/submission/types/invalid_request_cause.py index 49220332f2c..263a4f71fcb 100644 --- a/seed/fastapi/trace/resources/submission/types/invalid_request_cause.py +++ b/seed/fastapi/trace/resources/submission/types/invalid_request_cause.py @@ -110,6 +110,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, submission_id_not_found: typing.Callable[ diff --git a/seed/fastapi/trace/resources/submission/types/submission_request.py b/seed/fastapi/trace/resources/submission/types/submission_request.py index c8142c9e584..91d77cd4523 100644 --- a/seed/fastapi/trace/resources/submission/types/submission_request.py +++ b/seed/fastapi/trace/resources/submission/types/submission_request.py @@ -141,6 +141,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, initialize_problem_request: typing.Callable[ diff --git a/seed/fastapi/trace/resources/submission/types/submission_response.py b/seed/fastapi/trace/resources/submission/types/submission_response.py index cb481401e5f..09e8208a780 100644 --- a/seed/fastapi/trace/resources/submission/types/submission_response.py +++ b/seed/fastapi/trace/resources/submission/types/submission_response.py @@ -155,6 +155,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, server_initialized: typing.Callable[[], T_Result], diff --git a/seed/fastapi/trace/resources/submission/types/submission_status_for_test_case.py b/seed/fastapi/trace/resources/submission/types/submission_status_for_test_case.py index a54e476bc02..382898f7ddd 100644 --- a/seed/fastapi/trace/resources/submission/types/submission_status_for_test_case.py +++ b/seed/fastapi/trace/resources/submission/types/submission_status_for_test_case.py @@ -97,6 +97,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, graded: typing.Callable[[TestCaseResultWithStdout], T_Result], diff --git a/seed/fastapi/trace/resources/submission/types/submission_status_v_2.py b/seed/fastapi/trace/resources/submission/types/submission_status_v_2.py index 1788935114f..7c2380af2c3 100644 --- a/seed/fastapi/trace/resources/submission/types/submission_status_v_2.py +++ b/seed/fastapi/trace/resources/submission/types/submission_status_v_2.py @@ -67,6 +67,12 @@ def get_as_union( ) -> typing.Union[_SubmissionStatusV2.Test, _SubmissionStatusV2.Workspace]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, test: typing.Callable[[TestSubmissionStatusV2], T_Result], diff --git a/seed/fastapi/trace/resources/submission/types/submission_type_state.py b/seed/fastapi/trace/resources/submission/types/submission_type_state.py index 4ac02d9e1e9..6a6cda2ee7d 100644 --- a/seed/fastapi/trace/resources/submission/types/submission_type_state.py +++ b/seed/fastapi/trace/resources/submission/types/submission_type_state.py @@ -67,6 +67,12 @@ def get_as_union( ) -> typing.Union[_SubmissionTypeState.Test, _SubmissionTypeState.Workspace]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, test: typing.Callable[[TestSubmissionState], T_Result], diff --git a/seed/fastapi/trace/resources/submission/types/test_case_grade.py b/seed/fastapi/trace/resources/submission/types/test_case_grade.py index 42e11eb0419..a883324f042 100644 --- a/seed/fastapi/trace/resources/submission/types/test_case_grade.py +++ b/seed/fastapi/trace/resources/submission/types/test_case_grade.py @@ -67,6 +67,12 @@ def get_as_union( ) -> typing.Union[_TestCaseGrade.Hidden, _TestCaseGrade.NonHidden]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, hidden: typing.Callable[[TestCaseHiddenGrade], T_Result], diff --git a/seed/fastapi/trace/resources/submission/types/test_submission_status.py b/seed/fastapi/trace/resources/submission/types/test_submission_status.py index 312e621005d..8b5b756050a 100644 --- a/seed/fastapi/trace/resources/submission/types/test_submission_status.py +++ b/seed/fastapi/trace/resources/submission/types/test_submission_status.py @@ -107,6 +107,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, stopped: typing.Callable[[], T_Result], diff --git a/seed/fastapi/trace/resources/submission/types/test_submission_update_info.py b/seed/fastapi/trace/resources/submission/types/test_submission_update_info.py index 3e833bc9766..ef3bffae3eb 100644 --- a/seed/fastapi/trace/resources/submission/types/test_submission_update_info.py +++ b/seed/fastapi/trace/resources/submission/types/test_submission_update_info.py @@ -140,6 +140,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, running: typing.Callable[[RunningSubmissionState], T_Result], diff --git a/seed/fastapi/trace/resources/submission/types/workspace_submission_status.py b/seed/fastapi/trace/resources/submission/types/workspace_submission_status.py index 2c8060d8ea6..a10dcebb650 100644 --- a/seed/fastapi/trace/resources/submission/types/workspace_submission_status.py +++ b/seed/fastapi/trace/resources/submission/types/workspace_submission_status.py @@ -123,6 +123,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, stopped: typing.Callable[[], T_Result], diff --git a/seed/fastapi/trace/resources/submission/types/workspace_submission_update_info.py b/seed/fastapi/trace/resources/submission/types/workspace_submission_update_info.py index ee38493c0c3..66d6b2ff861 100644 --- a/seed/fastapi/trace/resources/submission/types/workspace_submission_update_info.py +++ b/seed/fastapi/trace/resources/submission/types/workspace_submission_update_info.py @@ -156,6 +156,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, running: typing.Callable[[RunningSubmissionState], T_Result], diff --git a/seed/fastapi/trace/resources/v_2/resources/problem/types/assert_correctness_check.py b/seed/fastapi/trace/resources/v_2/resources/problem/types/assert_correctness_check.py index 6c1eb98c338..9c5f0c28c7d 100644 --- a/seed/fastapi/trace/resources/v_2/resources/problem/types/assert_correctness_check.py +++ b/seed/fastapi/trace/resources/v_2/resources/problem/types/assert_correctness_check.py @@ -81,6 +81,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, deep_equality: typing.Callable[[DeepEqualityCorrectnessCheck], T_Result], diff --git a/seed/fastapi/trace/resources/v_2/resources/problem/types/custom_files.py b/seed/fastapi/trace/resources/v_2/resources/problem/types/custom_files.py index 4f758405bc2..4c116f4ba4c 100644 --- a/seed/fastapi/trace/resources/v_2/resources/problem/types/custom_files.py +++ b/seed/fastapi/trace/resources/v_2/resources/problem/types/custom_files.py @@ -55,6 +55,12 @@ def get_as_union(self) -> typing.Union[_CustomFiles.Basic, _CustomFiles.Custom]: def get_as_union(self) -> typing.Union[_CustomFiles.Basic, _CustomFiles.Custom]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, basic: typing.Callable[[BasicCustomFiles], T_Result], diff --git a/seed/fastapi/trace/resources/v_2/resources/problem/types/function_signature.py b/seed/fastapi/trace/resources/v_2/resources/problem/types/function_signature.py index f8dd57b0e71..414a2d425a6 100644 --- a/seed/fastapi/trace/resources/v_2/resources/problem/types/function_signature.py +++ b/seed/fastapi/trace/resources/v_2/resources/problem/types/function_signature.py @@ -102,6 +102,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, void: typing.Callable[[VoidFunctionSignature], T_Result], diff --git a/seed/fastapi/trace/resources/v_2/resources/problem/types/test_case_function.py b/seed/fastapi/trace/resources/v_2/resources/problem/types/test_case_function.py index baead6c882a..14143f1ee0b 100644 --- a/seed/fastapi/trace/resources/v_2/resources/problem/types/test_case_function.py +++ b/seed/fastapi/trace/resources/v_2/resources/problem/types/test_case_function.py @@ -71,6 +71,12 @@ def get_as_union( ) -> typing.Union[_TestCaseFunction.WithActualResult, _TestCaseFunction.Custom]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, with_actual_result: typing.Callable[ diff --git a/seed/fastapi/trace/resources/v_2/resources/problem/types/test_case_implementation_description_board.py b/seed/fastapi/trace/resources/v_2/resources/problem/types/test_case_implementation_description_board.py index 437f0e88f03..fde43638322 100644 --- a/seed/fastapi/trace/resources/v_2/resources/problem/types/test_case_implementation_description_board.py +++ b/seed/fastapi/trace/resources/v_2/resources/problem/types/test_case_implementation_description_board.py @@ -79,6 +79,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, html: typing.Callable[[str], T_Result], diff --git a/seed/fastapi/trace/resources/v_2/resources/problem/types/test_case_implementation_reference.py b/seed/fastapi/trace/resources/v_2/resources/problem/types/test_case_implementation_reference.py index 7d027bf59a3..5af7447a713 100644 --- a/seed/fastapi/trace/resources/v_2/resources/problem/types/test_case_implementation_reference.py +++ b/seed/fastapi/trace/resources/v_2/resources/problem/types/test_case_implementation_reference.py @@ -82,6 +82,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, template_id: typing.Callable[[TestCaseTemplateId], T_Result], diff --git a/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/assert_correctness_check.py b/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/assert_correctness_check.py index 7a89d23bd5a..d89ffe35e8f 100644 --- a/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/assert_correctness_check.py +++ b/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/assert_correctness_check.py @@ -81,6 +81,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, deep_equality: typing.Callable[[DeepEqualityCorrectnessCheck], T_Result], diff --git a/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/custom_files.py b/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/custom_files.py index 5829511c99e..793da91bf99 100644 --- a/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/custom_files.py +++ b/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/custom_files.py @@ -55,6 +55,12 @@ def get_as_union(self) -> typing.Union[_CustomFiles.Basic, _CustomFiles.Custom]: def get_as_union(self) -> typing.Union[_CustomFiles.Basic, _CustomFiles.Custom]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, basic: typing.Callable[[BasicCustomFiles], T_Result], diff --git a/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/function_signature.py b/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/function_signature.py index 56699e050a7..986e6685d75 100644 --- a/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/function_signature.py +++ b/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/function_signature.py @@ -102,6 +102,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, void: typing.Callable[[VoidFunctionSignature], T_Result], diff --git a/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/test_case_function.py b/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/test_case_function.py index c82422f608c..b46f1e772c3 100644 --- a/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/test_case_function.py +++ b/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/test_case_function.py @@ -71,6 +71,12 @@ def get_as_union( ) -> typing.Union[_TestCaseFunction.WithActualResult, _TestCaseFunction.Custom]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, with_actual_result: typing.Callable[ diff --git a/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/test_case_implementation_description_board.py b/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/test_case_implementation_description_board.py index 8d798240d22..7048054b970 100644 --- a/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/test_case_implementation_description_board.py +++ b/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/test_case_implementation_description_board.py @@ -79,6 +79,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, html: typing.Callable[[str], T_Result], diff --git a/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/test_case_implementation_reference.py b/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/test_case_implementation_reference.py index 43d71f2ecc2..78926968ffe 100644 --- a/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/test_case_implementation_reference.py +++ b/seed/fastapi/trace/resources/v_2/resources/v_3/resources/problem/types/test_case_implementation_reference.py @@ -82,6 +82,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, template_id: typing.Callable[[TestCaseTemplateId], T_Result], diff --git a/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py b/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py +++ b/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/unions/core/pydantic_utilities.py b/seed/fastapi/unions/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/unions/core/pydantic_utilities.py +++ b/seed/fastapi/unions/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/unions/resources/types/types/union.py b/seed/fastapi/unions/resources/types/types/union.py index 5921a16820b..31eba314778 100644 --- a/seed/fastapi/unions/resources/types/types/union.py +++ b/seed/fastapi/unions/resources/types/types/union.py @@ -50,6 +50,12 @@ def get_as_union(self) -> typing.Union[_Union.Foo, _Union.Bar]: def get_as_union(self) -> typing.Union[_Union.Foo, _Union.Bar]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, foo: typing.Callable[[resources_types_types_foo_Foo], T_Result], diff --git a/seed/fastapi/unions/resources/types/types/union_with_base_properties.py b/seed/fastapi/unions/resources/types/types/union_with_base_properties.py index 5cfbbe26ace..d2ba7902acc 100644 --- a/seed/fastapi/unions/resources/types/types/union_with_base_properties.py +++ b/seed/fastapi/unions/resources/types/types/union_with_base_properties.py @@ -89,6 +89,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, integer: typing.Callable[[int], T_Result], diff --git a/seed/fastapi/unions/resources/types/types/union_with_discriminant.py b/seed/fastapi/unions/resources/types/types/union_with_discriminant.py index 3b71ca351bb..0fe4cca9acb 100644 --- a/seed/fastapi/unions/resources/types/types/union_with_discriminant.py +++ b/seed/fastapi/unions/resources/types/types/union_with_discriminant.py @@ -60,6 +60,12 @@ def get_as_union( ) -> typing.Union[_UnionWithDiscriminant.Foo, _UnionWithDiscriminant.Bar]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, foo: typing.Callable[[resources_types_types_foo_Foo], T_Result], diff --git a/seed/fastapi/unions/resources/types/types/union_with_literal.py b/seed/fastapi/unions/resources/types/types/union_with_literal.py index 976223bdda9..85bbcba2bf8 100644 --- a/seed/fastapi/unions/resources/types/types/union_with_literal.py +++ b/seed/fastapi/unions/resources/types/types/union_with_literal.py @@ -36,6 +36,12 @@ def get_as_union(self) -> typing.Union[_UnionWithLiteral.Fern]: def get_as_union(self) -> typing.Union[_UnionWithLiteral.Fern]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, fern: typing.Callable[[typing.Literal["fern"]], T_Result] ) -> T_Result: diff --git a/seed/fastapi/unions/resources/types/types/union_with_optional_time.py b/seed/fastapi/unions/resources/types/types/union_with_optional_time.py index ea97c18a6f5..ecdd12d6c76 100644 --- a/seed/fastapi/unions/resources/types/types/union_with_optional_time.py +++ b/seed/fastapi/unions/resources/types/types/union_with_optional_time.py @@ -59,6 +59,12 @@ def get_as_union( ) -> typing.Union[_UnionWithOptionalTime.Date, _UnionWithOptionalTime.Dateimte]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, date: typing.Callable[[typing.Optional[dt.date]], T_Result], diff --git a/seed/fastapi/unions/resources/types/types/union_with_primitive.py b/seed/fastapi/unions/resources/types/types/union_with_primitive.py index 57476767eac..348695a898e 100644 --- a/seed/fastapi/unions/resources/types/types/union_with_primitive.py +++ b/seed/fastapi/unions/resources/types/types/union_with_primitive.py @@ -58,6 +58,12 @@ def get_as_union( ) -> typing.Union[_UnionWithPrimitive.Integer, _UnionWithPrimitive.String]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, integer: typing.Callable[[int], T_Result], diff --git a/seed/fastapi/unions/resources/types/types/union_with_single_element.py b/seed/fastapi/unions/resources/types/types/union_with_single_element.py index 0c9d1b2b3b3..8e412796d3a 100644 --- a/seed/fastapi/unions/resources/types/types/union_with_single_element.py +++ b/seed/fastapi/unions/resources/types/types/union_with_single_element.py @@ -40,6 +40,12 @@ def get_as_union(self) -> typing.Union[_UnionWithSingleElement.Foo]: def get_as_union(self) -> typing.Union[_UnionWithSingleElement.Foo]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, foo: typing.Callable[[resources_types_types_foo_Foo], T_Result] ) -> T_Result: diff --git a/seed/fastapi/unions/resources/types/types/union_with_time.py b/seed/fastapi/unions/resources/types/types/union_with_time.py index f2d2e6b80a3..fa9b3bb4bc3 100644 --- a/seed/fastapi/unions/resources/types/types/union_with_time.py +++ b/seed/fastapi/unions/resources/types/types/union_with_time.py @@ -71,6 +71,12 @@ def get_as_union( ]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, value: typing.Callable[[int], T_Result], diff --git a/seed/fastapi/unions/resources/types/types/union_with_unknown.py b/seed/fastapi/unions/resources/types/types/union_with_unknown.py index 9ed88ed2313..d187ae45262 100644 --- a/seed/fastapi/unions/resources/types/types/union_with_unknown.py +++ b/seed/fastapi/unions/resources/types/types/union_with_unknown.py @@ -57,6 +57,12 @@ def get_as_union( ) -> typing.Union[_UnionWithUnknown.Foo, _UnionWithUnknown.Unknown]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, foo: typing.Callable[[resources_types_types_foo_Foo], T_Result], diff --git a/seed/fastapi/unions/resources/types/types/union_without_key.py b/seed/fastapi/unions/resources/types/types/union_without_key.py index 60967fd21a1..de6ff9ef2a9 100644 --- a/seed/fastapi/unions/resources/types/types/union_without_key.py +++ b/seed/fastapi/unions/resources/types/types/union_without_key.py @@ -63,6 +63,12 @@ def get_as_union( ) -> typing.Union[_UnionWithoutKey.Foo, _UnionWithoutKey.Bar]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, foo: typing.Callable[[resources_types_types_foo_Foo], T_Result], diff --git a/seed/fastapi/unions/resources/union/types/shape.py b/seed/fastapi/unions/resources/union/types/shape.py index 081b37e5237..0735986e167 100644 --- a/seed/fastapi/unions/resources/union/types/shape.py +++ b/seed/fastapi/unions/resources/union/types/shape.py @@ -55,6 +55,12 @@ def get_as_union(self) -> typing.Union[_Shape.Circle, _Shape.Square]: def get_as_union(self) -> typing.Union[_Shape.Circle, _Shape.Square]: return self.__root__ + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + if IS_PYDANTIC_V2: + return self.root.dict(**kwargs) + else: + return self.__root__.dict(**kwargs) + def visit( self, circle: typing.Callable[[resources_union_types_circle_Circle], T_Result], diff --git a/seed/fastapi/unknown/core/pydantic_utilities.py b/seed/fastapi/unknown/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/unknown/core/pydantic_utilities.py +++ b/seed/fastapi/unknown/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/validation/core/pydantic_utilities.py b/seed/fastapi/validation/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/validation/core/pydantic_utilities.py +++ b/seed/fastapi/validation/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/variables/core/pydantic_utilities.py b/seed/fastapi/variables/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/variables/core/pydantic_utilities.py +++ b/seed/fastapi/variables/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/version-no-default/core/pydantic_utilities.py b/seed/fastapi/version-no-default/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/version-no-default/core/pydantic_utilities.py +++ b/seed/fastapi/version-no-default/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/version/core/pydantic_utilities.py b/seed/fastapi/version/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/version/core/pydantic_utilities.py +++ b/seed/fastapi/version/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/fastapi/websocket/core/pydantic_utilities.py b/seed/fastapi/websocket/core/pydantic_utilities.py index 16a8c405280..8008250b7a3 100644 --- a/seed/fastapi/websocket/core/pydantic_utilities.py +++ b/seed/fastapi/websocket/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/alias-extends/src/seed/alias_extends/core/pydantic_utilities.py b/seed/pydantic/alias-extends/src/seed/alias_extends/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/alias-extends/src/seed/alias_extends/core/pydantic_utilities.py +++ b/seed/pydantic/alias-extends/src/seed/alias_extends/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py b/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py +++ b/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/pydantic_utilities.py b/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/pydantic_utilities.py +++ b/seed/pydantic/api-wide-base-path/src/seed/api_wide_base_path/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py b/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py +++ b/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/pydantic_utilities.py b/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/pydantic_utilities.py +++ b/seed/pydantic/auth-environment-variables/src/seed/auth_environment_variables/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/pydantic_utilities.py b/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/pydantic_utilities.py +++ b/seed/pydantic/basic-auth-environment-variables/src/seed/basic_auth_environment_variables/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/basic-auth/src/seed/basic_auth/core/pydantic_utilities.py b/seed/pydantic/basic-auth/src/seed/basic_auth/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/basic-auth/src/seed/basic_auth/core/pydantic_utilities.py +++ b/seed/pydantic/basic-auth/src/seed/basic_auth/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/pydantic_utilities.py b/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/pydantic_utilities.py +++ b/seed/pydantic/bearer-token-environment-variable/src/seed/bearer_token_environment_variable/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py b/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py +++ b/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/circular-references-advanced/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/circular-references-advanced/src/seed/api/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/circular-references-advanced/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/circular-references-advanced/src/seed/api/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/circular-references/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/circular-references/src/seed/api/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/circular-references/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/circular-references/src/seed/api/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/custom-auth/src/seed/custom_auth/core/pydantic_utilities.py b/seed/pydantic/custom-auth/src/seed/custom_auth/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/custom-auth/src/seed/custom_auth/core/pydantic_utilities.py +++ b/seed/pydantic/custom-auth/src/seed/custom_auth/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py b/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py +++ b/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/error-property/src/seed/error_property/core/pydantic_utilities.py b/seed/pydantic/error-property/src/seed/error_property/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/error-property/src/seed/error_property/core/pydantic_utilities.py +++ b/seed/pydantic/error-property/src/seed/error_property/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py b/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py +++ b/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/pydantic_utilities.py b/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/pydantic_utilities.py +++ b/seed/pydantic/exhaustive/pydantic-v1/src/seed/exhaustive/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/pydantic_utilities.py b/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/pydantic_utilities.py +++ b/seed/pydantic/exhaustive/pydantic-v2/src/seed/exhaustive/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py b/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py +++ b/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/extra-properties/src/seed/extra_properties/core/pydantic_utilities.py b/seed/pydantic/extra-properties/src/seed/extra_properties/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/extra-properties/src/seed/extra_properties/core/pydantic_utilities.py +++ b/seed/pydantic/extra-properties/src/seed/extra_properties/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/file-download/src/seed/file_download/core/pydantic_utilities.py b/seed/pydantic/file-download/src/seed/file_download/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/file-download/src/seed/file_download/core/pydantic_utilities.py +++ b/seed/pydantic/file-download/src/seed/file_download/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/file-upload/src/seed/file_upload/core/pydantic_utilities.py b/seed/pydantic/file-upload/src/seed/file_upload/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/file-upload/src/seed/file_upload/core/pydantic_utilities.py +++ b/seed/pydantic/file-upload/src/seed/file_upload/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/grpc-proto/.mock/proto/google/api/field_behavior.proto b/seed/pydantic/grpc-proto/.mock/proto/google/api/field_behavior.proto deleted file mode 100644 index 128799c558d..00000000000 --- a/seed/pydantic/grpc-proto/.mock/proto/google/api/field_behavior.proto +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api; - -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "FieldBehaviorProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.FieldOptions { - // A designation of a specific field behavior (required, output only, etc.) - // in protobuf messages. - // - // Examples: - // - // string name = 1 [(google.api.field_behavior) = REQUIRED]; - // State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - // google.protobuf.Duration ttl = 1 - // [(google.api.field_behavior) = INPUT_ONLY]; - // google.protobuf.Timestamp expire_time = 1 - // [(google.api.field_behavior) = OUTPUT_ONLY, - // (google.api.field_behavior) = IMMUTABLE]; - repeated google.api.FieldBehavior field_behavior = 1052; -} - -// An indicator of the behavior of a given field (for example, that a field -// is required in requests, or given as output but ignored as input). -// This **does not** change the behavior in protocol buffers itself; it only -// denotes the behavior and may affect how API tooling handles the field. -// -// Note: This enum **may** receive new values in the future. -enum FieldBehavior { - // Conventional default for enums. Do not use this. - FIELD_BEHAVIOR_UNSPECIFIED = 0; - - // Specifically denotes a field as optional. - // While all fields in protocol buffers are optional, this may be specified - // for emphasis if appropriate. - OPTIONAL = 1; - - // Denotes a field as required. - // This indicates that the field **must** be provided as part of the request, - // and failure to do so will cause an error (usually `INVALID_ARGUMENT`). - REQUIRED = 2; - - // Denotes a field as output only. - // This indicates that the field is provided in responses, but including the - // field in a request does nothing (the server *must* ignore it and - // *must not* throw an error as a result of the field's presence). - OUTPUT_ONLY = 3; - - // Denotes a field as input only. - // This indicates that the field is provided in requests, and the - // corresponding field is not included in output. - INPUT_ONLY = 4; - - // Denotes a field as immutable. - // This indicates that the field may be set once in a request to create a - // resource, but may not be changed thereafter. - IMMUTABLE = 5; - - // Denotes that a (repeated) field is an unordered list. - // This indicates that the service may provide the elements of the list - // in any arbitrary order, rather than the order the user originally - // provided. Additionally, the list's order may or may not be stable. - UNORDERED_LIST = 6; - - // Denotes that this field returns a non-empty default value if not set. - // This indicates that if the user provides the empty value in a request, - // a non-empty value will be returned. The user will not be aware of what - // non-empty value to expect. - NON_EMPTY_DEFAULT = 7; - - // Denotes that the field in a resource (a message annotated with - // google.api.resource) is used in the resource name to uniquely identify the - // resource. For AIP-compliant APIs, this should only be applied to the - // `name` field on the resource. - // - // This behavior should not be applied to references to other resources within - // the message. - // - // The identifier field of resources often have different field behavior - // depending on the request it is embedded in (e.g. for Create methods name - // is optional and unused, while for Update methods it is required). Instead - // of method-specific annotations, only `IDENTIFIER` is required. - IDENTIFIER = 8; -} \ No newline at end of file diff --git a/seed/pydantic/grpc-proto/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/grpc-proto/src/seed/api/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/grpc-proto/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/grpc-proto/src/seed/api/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/pydantic_utilities.py b/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/pydantic_utilities.py +++ b/seed/pydantic/idempotency-headers/src/seed/idempotency_headers/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py b/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py +++ b/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/mixed-case/src/seed/mixed_case/core/pydantic_utilities.py b/seed/pydantic/mixed-case/src/seed/mixed_case/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/mixed-case/src/seed/mixed_case/core/pydantic_utilities.py +++ b/seed/pydantic/mixed-case/src/seed/mixed_case/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/pydantic_utilities.py b/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/pydantic_utilities.py +++ b/seed/pydantic/multi-line-docs/src/seed/multi_line_docs/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/pydantic_utilities.py b/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/pydantic_utilities.py +++ b/seed/pydantic/multi-url-environment-no-default/src/seed/multi_url_environment_no_default/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/pydantic_utilities.py b/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/pydantic_utilities.py +++ b/seed/pydantic/multi-url-environment/src/seed/multi_url_environment/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/no-environment/src/seed/no_environment/core/pydantic_utilities.py b/seed/pydantic/no-environment/src/seed/no_environment/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/no-environment/src/seed/no_environment/core/pydantic_utilities.py +++ b/seed/pydantic/no-environment/src/seed/no_environment/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/pydantic_utilities.py b/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/pydantic_utilities.py +++ b/seed/pydantic/oauth-client-credentials-default/src/seed/oauth_client_credentials_default/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/pydantic_utilities.py b/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/pydantic_utilities.py +++ b/seed/pydantic/oauth-client-credentials-environment-variables/src/seed/oauth_client_credentials_environment_variables/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/pydantic_utilities.py b/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/pydantic_utilities.py +++ b/seed/pydantic/oauth-client-credentials-nested-root/src/seed/oauth_client_credentials/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/pydantic_utilities.py b/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/pydantic_utilities.py +++ b/seed/pydantic/oauth-client-credentials/src/seed/oauth_client_credentials/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py b/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py +++ b/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/pydantic_utilities.py b/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/pydantic_utilities.py +++ b/seed/pydantic/objects-with-imports/src/seed/objects_with_imports/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/optional/src/seed/objects_with_imports/core/pydantic_utilities.py b/seed/pydantic/optional/src/seed/objects_with_imports/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/optional/src/seed/objects_with_imports/core/pydantic_utilities.py +++ b/seed/pydantic/optional/src/seed/objects_with_imports/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/package-yml/src/seed/package_yml/core/pydantic_utilities.py b/seed/pydantic/package-yml/src/seed/package_yml/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/package-yml/src/seed/package_yml/core/pydantic_utilities.py +++ b/seed/pydantic/package-yml/src/seed/package_yml/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py b/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py +++ b/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/plain-text/src/seed/plain_text/core/pydantic_utilities.py b/seed/pydantic/plain-text/src/seed/plain_text/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/plain-text/src/seed/plain_text/core/pydantic_utilities.py +++ b/seed/pydantic/plain-text/src/seed/plain_text/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/query-parameters/src/seed/query_parameters/core/pydantic_utilities.py b/seed/pydantic/query-parameters/src/seed/query_parameters/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/query-parameters/src/seed/query_parameters/core/pydantic_utilities.py +++ b/seed/pydantic/query-parameters/src/seed/query_parameters/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/pydantic_utilities.py b/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/pydantic_utilities.py +++ b/seed/pydantic/reserved-keywords/src/seed/nursery_api/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/response-property/src/seed/response_property/core/pydantic_utilities.py b/seed/pydantic/response-property/src/seed/response_property/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/response-property/src/seed/response_property/core/pydantic_utilities.py +++ b/seed/pydantic/response-property/src/seed/response_property/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/simple-fhir/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/simple-fhir/src/seed/api/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/simple-fhir/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/simple-fhir/src/seed/api/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/pydantic_utilities.py b/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/pydantic_utilities.py +++ b/seed/pydantic/single-url-environment-default/src/seed/single_url_environment_default/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/pydantic_utilities.py b/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/pydantic_utilities.py +++ b/seed/pydantic/single-url-environment-no-default/src/seed/single_url_environment_no_default/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/streaming-parameter/src/seed/streaming/core/pydantic_utilities.py b/seed/pydantic/streaming-parameter/src/seed/streaming/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/streaming-parameter/src/seed/streaming/core/pydantic_utilities.py +++ b/seed/pydantic/streaming-parameter/src/seed/streaming/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py b/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py +++ b/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py b/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py +++ b/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/pydantic_utilities.py b/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/pydantic_utilities.py +++ b/seed/pydantic/undiscriminated-unions/src/seed/undiscriminated_unions/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py b/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py +++ b/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/unknown/src/seed/unknown_as_any/core/pydantic_utilities.py b/seed/pydantic/unknown/src/seed/unknown_as_any/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/unknown/src/seed/unknown_as_any/core/pydantic_utilities.py +++ b/seed/pydantic/unknown/src/seed/unknown_as_any/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py b/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py +++ b/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py b/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py +++ b/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/version-no-default/src/seed/version/core/pydantic_utilities.py b/seed/pydantic/version-no-default/src/seed/version/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/version-no-default/src/seed/version/core/pydantic_utilities.py +++ b/seed/pydantic/version-no-default/src/seed/version/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py b/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py +++ b/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py b/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py index 6bf314ee12d..eb429181594 100644 --- a/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py +++ b/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py @@ -1,7 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -# This file was auto-generated by Fern from our API Definition. - # nopycln: file import datetime as dt import typing @@ -99,8 +97,8 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: From 3db56d682c0e2bb3ba043f836a4d62c5a38e3427 Mon Sep 17 00:00:00 2001 From: armandobelardo Date: Wed, 14 Aug 2024 15:22:51 -0400 Subject: [PATCH 7/7] seed --- .../core_utilities/sdk/pydantic_utilities.py | 2 +- pnpm-lock.yaml | 13 ---- .../audiences/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../audiences/src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../basic-auth/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../basic-auth/src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../custom-auth/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../enum/real-enum/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../real-enum/src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../enum/strenum/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../strenum/src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../error-property/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../client-filename/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../examples/readme/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../readme/src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../readme/tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../readme/tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../pydantic-v1/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../union-utils/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../src/seed/types/union/types/animal.py | 6 -- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../folders/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../folders/src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../grpc-proto/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../grpc-proto/src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../multi-line-docs/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../package-yml/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../pagination/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../pagination/src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../plain-text/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../plain-text/src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../simple-fhir/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../trace/src/seed/core/__init__.py | 2 + .../trace/src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../trace/src/seed/core/query_encoder.py | 45 +++++++++--- .../trace/tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../trace/tests/utils/assets/models/shape.py | 6 +- .../trace/tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../trace/tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../union-naming-v1/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../union-utils/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../union-utils/src/seed/types/types/union.py | 6 -- .../types/types/union_with_base_properties.py | 6 -- .../types/types/union_with_discriminant.py | 6 -- .../seed/types/types/union_with_literal.py | 6 -- .../types/types/union_with_optional_time.py | 6 -- .../seed/types/types/union_with_primitive.py | 6 -- .../types/types/union_with_single_element.py | 6 -- .../src/seed/types/types/union_with_time.py | 6 -- .../seed/types/types/union_with_unknown.py | 6 -- .../src/seed/types/types/union_without_key.py | 6 -- .../union-utils/src/seed/union/types/shape.py | 6 -- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../unknown/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../unknown/src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../with-defaults/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../variables/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../variables/src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- .../websocket/src/seed/core/__init__.py | 2 + .../src/seed/core/pydantic_utilities.py | 72 +++++++------------ .../websocket/src/seed/core/query_encoder.py | 45 +++++++++--- .../tests/utils/assets/models/circle.py | 2 +- .../assets/models/object_with_defaults.py | 1 - .../models/object_with_optional_field.py | 9 +-- .../tests/utils/assets/models/shape.py | 6 +- .../tests/utils/assets/models/square.py | 2 +- .../assets/models/undiscriminated_shape.py | 1 + .../tests/utils/test_query_encoding.py | 34 ++++++--- 614 files changed, 6061 insertions(+), 4466 deletions(-) diff --git a/generators/python/core_utilities/sdk/pydantic_utilities.py b/generators/python/core_utilities/sdk/pydantic_utilities.py index 7a0cc1511e9..d723949ecec 100644 --- a/generators/python/core_utilities/sdk/pydantic_utilities.py +++ b/generators/python/core_utilities/sdk/pydantic_utilities.py @@ -96,7 +96,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: `exclude_unset` to work include fields within non-None default values. """ _fields_set = self.__fields_set__ - + fields = _get_model_fields(self.__class__) for name, field in fields.items(): if name not in _fields_set: diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c7f56965a68..173cf4ba0fd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3177,19 +3177,6 @@ importers: specifier: 4.6.4 version: 4.6.4 - packages/cli/cli/dist/dev: {} - - packages/cli/cli/dist/local: - devDependencies: - globals: - specifier: link:@types/vitest/globals - version: link:@types/vitest/globals - vitest: - specifier: ^2.0.5 - version: 2.0.5(@types/node@18.7.18)(jsdom@20.0.3)(sass@1.72.0)(terser@5.31.5) - - packages/cli/cli/dist/prod: {} - packages/cli/configuration: dependencies: '@fern-api/core-utils': diff --git a/seed/python-sdk/audiences/src/seed/core/__init__.py b/seed/python-sdk/audiences/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/audiences/src/seed/core/__init__.py +++ b/seed/python-sdk/audiences/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py b/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/audiences/src/seed/core/query_encoder.py b/seed/python-sdk/audiences/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/audiences/src/seed/core/query_encoder.py +++ b/seed/python-sdk/audiences/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/audiences/tests/utils/assets/models/circle.py b/seed/python-sdk/audiences/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/audiences/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/audiences/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/audiences/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/audiences/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/audiences/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/audiences/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/audiences/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/audiences/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/audiences/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/audiences/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/audiences/tests/utils/assets/models/shape.py b/seed/python-sdk/audiences/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/audiences/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/audiences/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/audiences/tests/utils/assets/models/square.py b/seed/python-sdk/audiences/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/audiences/tests/utils/assets/models/square.py +++ b/seed/python-sdk/audiences/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/audiences/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/audiences/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/audiences/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/audiences/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/audiences/tests/utils/test_query_encoding.py b/seed/python-sdk/audiences/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/audiences/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/audiences/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/basic-auth-environment-variables/src/seed/core/__init__.py b/seed/python-sdk/basic-auth-environment-variables/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/basic-auth-environment-variables/src/seed/core/__init__.py +++ b/seed/python-sdk/basic-auth-environment-variables/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/basic-auth-environment-variables/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/basic-auth-environment-variables/src/seed/core/query_encoder.py b/seed/python-sdk/basic-auth-environment-variables/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/basic-auth-environment-variables/src/seed/core/query_encoder.py +++ b/seed/python-sdk/basic-auth-environment-variables/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/circle.py b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/shape.py b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/square.py b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/square.py +++ b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/basic-auth-environment-variables/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/basic-auth-environment-variables/tests/utils/test_query_encoding.py b/seed/python-sdk/basic-auth-environment-variables/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/basic-auth-environment-variables/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/basic-auth-environment-variables/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/basic-auth/src/seed/core/__init__.py b/seed/python-sdk/basic-auth/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/basic-auth/src/seed/core/__init__.py +++ b/seed/python-sdk/basic-auth/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py b/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/basic-auth/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/basic-auth/src/seed/core/query_encoder.py b/seed/python-sdk/basic-auth/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/basic-auth/src/seed/core/query_encoder.py +++ b/seed/python-sdk/basic-auth/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/basic-auth/tests/utils/assets/models/circle.py b/seed/python-sdk/basic-auth/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/basic-auth/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/basic-auth/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/basic-auth/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/basic-auth/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/basic-auth/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/basic-auth/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/basic-auth/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/basic-auth/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/basic-auth/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/basic-auth/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/basic-auth/tests/utils/assets/models/shape.py b/seed/python-sdk/basic-auth/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/basic-auth/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/basic-auth/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/basic-auth/tests/utils/assets/models/square.py b/seed/python-sdk/basic-auth/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/basic-auth/tests/utils/assets/models/square.py +++ b/seed/python-sdk/basic-auth/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/basic-auth/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/basic-auth/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/basic-auth/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/basic-auth/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/basic-auth/tests/utils/test_query_encoding.py b/seed/python-sdk/basic-auth/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/basic-auth/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/basic-auth/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/circular-references-advanced/src/seed/core/__init__.py b/seed/python-sdk/circular-references-advanced/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/circular-references-advanced/src/seed/core/__init__.py +++ b/seed/python-sdk/circular-references-advanced/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py b/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/circular-references-advanced/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/circular-references-advanced/src/seed/core/query_encoder.py b/seed/python-sdk/circular-references-advanced/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/circular-references-advanced/src/seed/core/query_encoder.py +++ b/seed/python-sdk/circular-references-advanced/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/circle.py b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/shape.py b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/square.py b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/square.py +++ b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/circular-references-advanced/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/circular-references-advanced/tests/utils/test_query_encoding.py b/seed/python-sdk/circular-references-advanced/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/circular-references-advanced/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/circular-references-advanced/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/circular-references/src/seed/core/__init__.py b/seed/python-sdk/circular-references/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/circular-references/src/seed/core/__init__.py +++ b/seed/python-sdk/circular-references/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py b/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/circular-references/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/circular-references/src/seed/core/query_encoder.py b/seed/python-sdk/circular-references/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/circular-references/src/seed/core/query_encoder.py +++ b/seed/python-sdk/circular-references/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/circular-references/tests/utils/assets/models/circle.py b/seed/python-sdk/circular-references/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/circular-references/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/circular-references/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/circular-references/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/circular-references/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/circular-references/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/circular-references/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/circular-references/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/circular-references/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/circular-references/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/circular-references/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/circular-references/tests/utils/assets/models/shape.py b/seed/python-sdk/circular-references/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/circular-references/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/circular-references/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/circular-references/tests/utils/assets/models/square.py b/seed/python-sdk/circular-references/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/circular-references/tests/utils/assets/models/square.py +++ b/seed/python-sdk/circular-references/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/circular-references/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/circular-references/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/circular-references/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/circular-references/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/circular-references/tests/utils/test_query_encoding.py b/seed/python-sdk/circular-references/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/circular-references/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/circular-references/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/custom-auth/src/seed/core/__init__.py b/seed/python-sdk/custom-auth/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/custom-auth/src/seed/core/__init__.py +++ b/seed/python-sdk/custom-auth/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py b/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/custom-auth/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/custom-auth/src/seed/core/query_encoder.py b/seed/python-sdk/custom-auth/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/custom-auth/src/seed/core/query_encoder.py +++ b/seed/python-sdk/custom-auth/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/custom-auth/tests/utils/assets/models/circle.py b/seed/python-sdk/custom-auth/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/custom-auth/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/custom-auth/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/custom-auth/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/custom-auth/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/custom-auth/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/custom-auth/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/custom-auth/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/custom-auth/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/custom-auth/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/custom-auth/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/custom-auth/tests/utils/assets/models/shape.py b/seed/python-sdk/custom-auth/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/custom-auth/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/custom-auth/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/custom-auth/tests/utils/assets/models/square.py b/seed/python-sdk/custom-auth/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/custom-auth/tests/utils/assets/models/square.py +++ b/seed/python-sdk/custom-auth/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/custom-auth/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/custom-auth/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/custom-auth/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/custom-auth/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/custom-auth/tests/utils/test_query_encoding.py b/seed/python-sdk/custom-auth/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/custom-auth/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/custom-auth/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/enum/no-custom-config/src/seed/core/__init__.py b/seed/python-sdk/enum/no-custom-config/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/enum/no-custom-config/src/seed/core/__init__.py +++ b/seed/python-sdk/enum/no-custom-config/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/no-custom-config/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/enum/no-custom-config/src/seed/core/query_encoder.py b/seed/python-sdk/enum/no-custom-config/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/enum/no-custom-config/src/seed/core/query_encoder.py +++ b/seed/python-sdk/enum/no-custom-config/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/circle.py b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/shape.py b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/square.py b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/square.py +++ b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/enum/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/enum/no-custom-config/tests/utils/test_query_encoding.py b/seed/python-sdk/enum/no-custom-config/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/enum/no-custom-config/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/enum/no-custom-config/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/__init__.py b/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/__init__.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/query_encoder.py b/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/query_encoder.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/circle.py b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/shape.py b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/square.py b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/square.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/test_query_encoding.py b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/enum/real-enum-forward-compat/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/enum/real-enum/src/seed/core/__init__.py b/seed/python-sdk/enum/real-enum/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/enum/real-enum/src/seed/core/__init__.py +++ b/seed/python-sdk/enum/real-enum/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/real-enum/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/enum/real-enum/src/seed/core/query_encoder.py b/seed/python-sdk/enum/real-enum/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/enum/real-enum/src/seed/core/query_encoder.py +++ b/seed/python-sdk/enum/real-enum/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/circle.py b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/shape.py b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/square.py b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/square.py +++ b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/enum/real-enum/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/enum/real-enum/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/enum/real-enum/tests/utils/test_query_encoding.py b/seed/python-sdk/enum/real-enum/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/enum/real-enum/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/enum/real-enum/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/enum/strenum/src/seed/core/__init__.py b/seed/python-sdk/enum/strenum/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/enum/strenum/src/seed/core/__init__.py +++ b/seed/python-sdk/enum/strenum/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py b/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/enum/strenum/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/enum/strenum/src/seed/core/query_encoder.py b/seed/python-sdk/enum/strenum/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/enum/strenum/src/seed/core/query_encoder.py +++ b/seed/python-sdk/enum/strenum/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/enum/strenum/tests/utils/assets/models/circle.py b/seed/python-sdk/enum/strenum/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/enum/strenum/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/enum/strenum/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/strenum/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/enum/strenum/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/enum/strenum/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/enum/strenum/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/enum/strenum/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/enum/strenum/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/enum/strenum/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/enum/strenum/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/enum/strenum/tests/utils/assets/models/shape.py b/seed/python-sdk/enum/strenum/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/enum/strenum/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/enum/strenum/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/strenum/tests/utils/assets/models/square.py b/seed/python-sdk/enum/strenum/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/enum/strenum/tests/utils/assets/models/square.py +++ b/seed/python-sdk/enum/strenum/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/enum/strenum/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/enum/strenum/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/enum/strenum/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/enum/strenum/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/enum/strenum/tests/utils/test_query_encoding.py b/seed/python-sdk/enum/strenum/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/enum/strenum/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/enum/strenum/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/error-property/src/seed/core/__init__.py b/seed/python-sdk/error-property/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/error-property/src/seed/core/__init__.py +++ b/seed/python-sdk/error-property/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py b/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/error-property/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/error-property/src/seed/core/query_encoder.py b/seed/python-sdk/error-property/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/error-property/src/seed/core/query_encoder.py +++ b/seed/python-sdk/error-property/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/error-property/tests/utils/assets/models/circle.py b/seed/python-sdk/error-property/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/error-property/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/error-property/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/error-property/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/error-property/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/error-property/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/error-property/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/error-property/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/error-property/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/error-property/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/error-property/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/error-property/tests/utils/assets/models/shape.py b/seed/python-sdk/error-property/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/error-property/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/error-property/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/error-property/tests/utils/assets/models/square.py b/seed/python-sdk/error-property/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/error-property/tests/utils/assets/models/square.py +++ b/seed/python-sdk/error-property/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/error-property/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/error-property/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/error-property/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/error-property/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/error-property/tests/utils/test_query_encoding.py b/seed/python-sdk/error-property/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/error-property/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/error-property/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/examples/client-filename/src/seed/core/__init__.py b/seed/python-sdk/examples/client-filename/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/examples/client-filename/src/seed/core/__init__.py +++ b/seed/python-sdk/examples/client-filename/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py b/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/examples/client-filename/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/examples/client-filename/src/seed/core/query_encoder.py b/seed/python-sdk/examples/client-filename/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/examples/client-filename/src/seed/core/query_encoder.py +++ b/seed/python-sdk/examples/client-filename/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/circle.py b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/shape.py b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/square.py b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/square.py +++ b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/examples/client-filename/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/examples/client-filename/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/examples/client-filename/tests/utils/test_query_encoding.py b/seed/python-sdk/examples/client-filename/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/examples/client-filename/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/examples/client-filename/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/examples/no-custom-config/src/seed/core/__init__.py b/seed/python-sdk/examples/no-custom-config/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/examples/no-custom-config/src/seed/core/__init__.py +++ b/seed/python-sdk/examples/no-custom-config/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/examples/no-custom-config/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/examples/no-custom-config/src/seed/core/query_encoder.py b/seed/python-sdk/examples/no-custom-config/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/examples/no-custom-config/src/seed/core/query_encoder.py +++ b/seed/python-sdk/examples/no-custom-config/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/circle.py b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/shape.py b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/square.py b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/square.py +++ b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/examples/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/examples/no-custom-config/tests/utils/test_query_encoding.py b/seed/python-sdk/examples/no-custom-config/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/examples/no-custom-config/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/examples/no-custom-config/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/examples/readme/src/seed/core/__init__.py b/seed/python-sdk/examples/readme/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/examples/readme/src/seed/core/__init__.py +++ b/seed/python-sdk/examples/readme/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py b/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/examples/readme/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/examples/readme/src/seed/core/query_encoder.py b/seed/python-sdk/examples/readme/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/examples/readme/src/seed/core/query_encoder.py +++ b/seed/python-sdk/examples/readme/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/examples/readme/tests/utils/assets/models/circle.py b/seed/python-sdk/examples/readme/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/examples/readme/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/examples/readme/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/readme/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/examples/readme/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/examples/readme/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/examples/readme/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/examples/readme/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/examples/readme/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/examples/readme/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/examples/readme/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/examples/readme/tests/utils/assets/models/shape.py b/seed/python-sdk/examples/readme/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/examples/readme/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/examples/readme/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/readme/tests/utils/assets/models/square.py b/seed/python-sdk/examples/readme/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/examples/readme/tests/utils/assets/models/square.py +++ b/seed/python-sdk/examples/readme/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/examples/readme/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/examples/readme/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/examples/readme/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/examples/readme/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/examples/readme/tests/utils/test_query_encoding.py b/seed/python-sdk/examples/readme/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/examples/readme/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/examples/readme/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/query_encoder.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/query_encoder.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/test_query_encoding.py b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/exhaustive/deps_with_min_python_version/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/query_encoder.py b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/query_encoder.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/test_query_encoding.py b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/exhaustive/extra_dependencies/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/query_encoder.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/query_encoder.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/test_query_encoding.py b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/exhaustive/extra_dev_dependencies/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/query_encoder.py b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/query_encoder.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/test_query_encoding.py b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/exhaustive/five-second-timeout/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/query_encoder.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/query_encoder.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/test_query_encoding.py b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/exhaustive/follow_redirects_by_default/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/query_encoder.py b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/exhaustive/improved_imports/src/seed/core/query_encoder.py +++ b/seed/python-sdk/exhaustive/improved_imports/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/improved_imports/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/improved_imports/tests/utils/test_query_encoding.py b/seed/python-sdk/exhaustive/improved_imports/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/exhaustive/improved_imports/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/exhaustive/improved_imports/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/query_encoder.py b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/query_encoder.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/test_query_encoding.py b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/exhaustive/infinite-timeout/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/query_encoder.py b/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/query_encoder.py +++ b/seed/python-sdk/exhaustive/inline_request_params/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/test_query_encoding.py b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/exhaustive/inline_request_params/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/exhaustive/inline_request_params/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/query_encoder.py b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/query_encoder.py +++ b/seed/python-sdk/exhaustive/no-custom-config/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/test_query_encoding.py b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/exhaustive/no-custom-config/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/exhaustive/no-custom-config/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/query_encoder.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/query_encoder.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/test_query_encoding.py b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/exhaustive/pydantic-extra-fields/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/query_encoder.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/query_encoder.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/test_query_encoding.py b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/exhaustive/pydantic-v1-wrapped/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/query_encoder.py b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/query_encoder.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/test_query_encoding.py b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/exhaustive/pydantic-v1/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/__init__.py index 226d7d5c439..e62bebe7ce4 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -39,6 +40,7 @@ "construct_type", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/query_encoder.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/query_encoder.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/test_query_encoding.py b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/exhaustive/skip-pydantic-validation/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/exhaustive/union-utils/src/seed/core/__init__.py b/seed/python-sdk/exhaustive/union-utils/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/exhaustive/union-utils/src/seed/core/__init__.py +++ b/seed/python-sdk/exhaustive/union-utils/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py b/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/exhaustive/union-utils/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/exhaustive/union-utils/src/seed/core/query_encoder.py b/seed/python-sdk/exhaustive/union-utils/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/exhaustive/union-utils/src/seed/core/query_encoder.py +++ b/seed/python-sdk/exhaustive/union-utils/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/exhaustive/union-utils/src/seed/types/union/types/animal.py b/seed/python-sdk/exhaustive/union-utils/src/seed/types/union/types/animal.py index 9b437ed78fb..be7852ebf72 100644 --- a/seed/python-sdk/exhaustive/union-utils/src/seed/types/union/types/animal.py +++ b/seed/python-sdk/exhaustive/union-utils/src/seed/types/union/types/animal.py @@ -45,12 +45,6 @@ def get_as_union(self) -> typing.Union[_Animal.Dog, _Animal.Cat]: def get_as_union(self) -> typing.Union[_Animal.Dog, _Animal.Cat]: return self.__root__ - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - if IS_PYDANTIC_V2: - return self.root.dict(**kwargs) - else: - return self.__root__.dict(**kwargs) - def visit( self, dog: typing.Callable[[types_union_types_dog_Dog], T_Result], diff --git a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/circle.py b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/shape.py b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/square.py b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/square.py +++ b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/exhaustive/union-utils/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/exhaustive/union-utils/tests/utils/test_query_encoding.py b/seed/python-sdk/exhaustive/union-utils/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/exhaustive/union-utils/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/exhaustive/union-utils/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/extra-properties/src/seed/core/__init__.py b/seed/python-sdk/extra-properties/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/extra-properties/src/seed/core/__init__.py +++ b/seed/python-sdk/extra-properties/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py b/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/extra-properties/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/extra-properties/src/seed/core/query_encoder.py b/seed/python-sdk/extra-properties/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/extra-properties/src/seed/core/query_encoder.py +++ b/seed/python-sdk/extra-properties/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/extra-properties/tests/utils/assets/models/circle.py b/seed/python-sdk/extra-properties/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/extra-properties/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/extra-properties/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/extra-properties/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/extra-properties/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/extra-properties/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/extra-properties/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/extra-properties/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/extra-properties/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/extra-properties/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/extra-properties/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/extra-properties/tests/utils/assets/models/shape.py b/seed/python-sdk/extra-properties/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/extra-properties/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/extra-properties/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/extra-properties/tests/utils/assets/models/square.py b/seed/python-sdk/extra-properties/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/extra-properties/tests/utils/assets/models/square.py +++ b/seed/python-sdk/extra-properties/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/extra-properties/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/extra-properties/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/extra-properties/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/extra-properties/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/extra-properties/tests/utils/test_query_encoding.py b/seed/python-sdk/extra-properties/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/extra-properties/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/extra-properties/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/folders/src/seed/core/__init__.py b/seed/python-sdk/folders/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/folders/src/seed/core/__init__.py +++ b/seed/python-sdk/folders/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py b/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/folders/src/seed/core/query_encoder.py b/seed/python-sdk/folders/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/folders/src/seed/core/query_encoder.py +++ b/seed/python-sdk/folders/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/folders/tests/utils/assets/models/circle.py b/seed/python-sdk/folders/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/folders/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/folders/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/folders/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/folders/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/folders/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/folders/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/folders/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/folders/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/folders/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/folders/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/folders/tests/utils/assets/models/shape.py b/seed/python-sdk/folders/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/folders/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/folders/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/folders/tests/utils/assets/models/square.py b/seed/python-sdk/folders/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/folders/tests/utils/assets/models/square.py +++ b/seed/python-sdk/folders/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/folders/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/folders/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/folders/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/folders/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/folders/tests/utils/test_query_encoding.py b/seed/python-sdk/folders/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/folders/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/folders/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/grpc-proto/src/seed/core/__init__.py b/seed/python-sdk/grpc-proto/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/grpc-proto/src/seed/core/__init__.py +++ b/seed/python-sdk/grpc-proto/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py b/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/grpc-proto/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/grpc-proto/src/seed/core/query_encoder.py b/seed/python-sdk/grpc-proto/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/grpc-proto/src/seed/core/query_encoder.py +++ b/seed/python-sdk/grpc-proto/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/grpc-proto/tests/utils/assets/models/circle.py b/seed/python-sdk/grpc-proto/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/grpc-proto/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/grpc-proto/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/grpc-proto/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/grpc-proto/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/grpc-proto/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/grpc-proto/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/grpc-proto/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/grpc-proto/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/grpc-proto/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/grpc-proto/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/grpc-proto/tests/utils/assets/models/shape.py b/seed/python-sdk/grpc-proto/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/grpc-proto/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/grpc-proto/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/grpc-proto/tests/utils/assets/models/square.py b/seed/python-sdk/grpc-proto/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/grpc-proto/tests/utils/assets/models/square.py +++ b/seed/python-sdk/grpc-proto/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/grpc-proto/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/grpc-proto/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/grpc-proto/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/grpc-proto/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/grpc-proto/tests/utils/test_query_encoding.py b/seed/python-sdk/grpc-proto/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/grpc-proto/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/grpc-proto/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/literal/no-custom-config/src/seed/core/__init__.py b/seed/python-sdk/literal/no-custom-config/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/literal/no-custom-config/src/seed/core/__init__.py +++ b/seed/python-sdk/literal/no-custom-config/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/literal/no-custom-config/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/literal/no-custom-config/src/seed/core/query_encoder.py b/seed/python-sdk/literal/no-custom-config/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/literal/no-custom-config/src/seed/core/query_encoder.py +++ b/seed/python-sdk/literal/no-custom-config/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/circle.py b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/shape.py b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/square.py b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/square.py +++ b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/literal/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/literal/no-custom-config/tests/utils/test_query_encoding.py b/seed/python-sdk/literal/no-custom-config/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/literal/no-custom-config/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/literal/no-custom-config/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/__init__.py b/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/__init__.py +++ b/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py b/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/query_encoder.py b/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/query_encoder.py +++ b/seed/python-sdk/literal/use_typeddict_requests/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/circle.py b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/shape.py b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/square.py b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/square.py +++ b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/test_query_encoding.py b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/literal/use_typeddict_requests/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/multi-line-docs/src/seed/core/__init__.py b/seed/python-sdk/multi-line-docs/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/multi-line-docs/src/seed/core/__init__.py +++ b/seed/python-sdk/multi-line-docs/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py b/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/multi-line-docs/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/multi-line-docs/src/seed/core/query_encoder.py b/seed/python-sdk/multi-line-docs/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/multi-line-docs/src/seed/core/query_encoder.py +++ b/seed/python-sdk/multi-line-docs/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/circle.py b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/shape.py b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/square.py b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/square.py +++ b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/multi-line-docs/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/multi-line-docs/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/multi-line-docs/tests/utils/test_query_encoding.py b/seed/python-sdk/multi-line-docs/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/multi-line-docs/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/multi-line-docs/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/multi-url-environment-no-default/src/seed/core/__init__.py b/seed/python-sdk/multi-url-environment-no-default/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/multi-url-environment-no-default/src/seed/core/__init__.py +++ b/seed/python-sdk/multi-url-environment-no-default/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/multi-url-environment-no-default/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/multi-url-environment-no-default/src/seed/core/query_encoder.py b/seed/python-sdk/multi-url-environment-no-default/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/multi-url-environment-no-default/src/seed/core/query_encoder.py +++ b/seed/python-sdk/multi-url-environment-no-default/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/circle.py b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/shape.py b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/square.py b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/square.py +++ b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/multi-url-environment-no-default/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/multi-url-environment-no-default/tests/utils/test_query_encoding.py b/seed/python-sdk/multi-url-environment-no-default/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/multi-url-environment-no-default/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/multi-url-environment-no-default/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/multi-url-environment/src/seed/core/__init__.py b/seed/python-sdk/multi-url-environment/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/multi-url-environment/src/seed/core/__init__.py +++ b/seed/python-sdk/multi-url-environment/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py b/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/multi-url-environment/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/multi-url-environment/src/seed/core/query_encoder.py b/seed/python-sdk/multi-url-environment/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/multi-url-environment/src/seed/core/query_encoder.py +++ b/seed/python-sdk/multi-url-environment/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/circle.py b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/shape.py b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/square.py b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/square.py +++ b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/multi-url-environment/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/multi-url-environment/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/multi-url-environment/tests/utils/test_query_encoding.py b/seed/python-sdk/multi-url-environment/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/multi-url-environment/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/multi-url-environment/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/__init__.py b/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/__init__.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py b/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/query_encoder.py b/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/query_encoder.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/circle.py b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/shape.py b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/square.py b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/square.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/test_query_encoding.py b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/oauth-client-credentials-nested-root/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/objects-with-imports/src/seed/core/__init__.py b/seed/python-sdk/objects-with-imports/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/objects-with-imports/src/seed/core/__init__.py +++ b/seed/python-sdk/objects-with-imports/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py b/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/objects-with-imports/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/objects-with-imports/src/seed/core/query_encoder.py b/seed/python-sdk/objects-with-imports/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/objects-with-imports/src/seed/core/query_encoder.py +++ b/seed/python-sdk/objects-with-imports/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/circle.py b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/shape.py b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/square.py b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/square.py +++ b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/objects-with-imports/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/objects-with-imports/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/objects-with-imports/tests/utils/test_query_encoding.py b/seed/python-sdk/objects-with-imports/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/objects-with-imports/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/objects-with-imports/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/package-yml/src/seed/core/__init__.py b/seed/python-sdk/package-yml/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/package-yml/src/seed/core/__init__.py +++ b/seed/python-sdk/package-yml/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py b/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/package-yml/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/package-yml/src/seed/core/query_encoder.py b/seed/python-sdk/package-yml/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/package-yml/src/seed/core/query_encoder.py +++ b/seed/python-sdk/package-yml/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/package-yml/tests/utils/assets/models/circle.py b/seed/python-sdk/package-yml/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/package-yml/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/package-yml/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/package-yml/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/package-yml/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/package-yml/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/package-yml/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/package-yml/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/package-yml/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/package-yml/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/package-yml/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/package-yml/tests/utils/assets/models/shape.py b/seed/python-sdk/package-yml/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/package-yml/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/package-yml/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/package-yml/tests/utils/assets/models/square.py b/seed/python-sdk/package-yml/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/package-yml/tests/utils/assets/models/square.py +++ b/seed/python-sdk/package-yml/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/package-yml/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/package-yml/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/package-yml/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/package-yml/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/package-yml/tests/utils/test_query_encoding.py b/seed/python-sdk/package-yml/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/package-yml/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/package-yml/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/pagination/src/seed/core/__init__.py b/seed/python-sdk/pagination/src/seed/core/__init__.py index 2fcdcefd748..15442d42733 100644 --- a/seed/python-sdk/pagination/src/seed/core/__init__.py +++ b/seed/python-sdk/pagination/src/seed/core/__init__.py @@ -11,6 +11,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -38,6 +39,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py b/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/pagination/src/seed/core/query_encoder.py b/seed/python-sdk/pagination/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/pagination/src/seed/core/query_encoder.py +++ b/seed/python-sdk/pagination/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/pagination/tests/utils/assets/models/circle.py b/seed/python-sdk/pagination/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/pagination/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/pagination/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/pagination/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/pagination/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/pagination/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/pagination/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/pagination/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/pagination/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/pagination/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/pagination/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/pagination/tests/utils/assets/models/shape.py b/seed/python-sdk/pagination/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/pagination/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/pagination/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/pagination/tests/utils/assets/models/square.py b/seed/python-sdk/pagination/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/pagination/tests/utils/assets/models/square.py +++ b/seed/python-sdk/pagination/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/pagination/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/pagination/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/pagination/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/pagination/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/pagination/tests/utils/test_query_encoding.py b/seed/python-sdk/pagination/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/pagination/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/pagination/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/plain-text/src/seed/core/__init__.py b/seed/python-sdk/plain-text/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/plain-text/src/seed/core/__init__.py +++ b/seed/python-sdk/plain-text/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py b/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/plain-text/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/plain-text/src/seed/core/query_encoder.py b/seed/python-sdk/plain-text/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/plain-text/src/seed/core/query_encoder.py +++ b/seed/python-sdk/plain-text/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/plain-text/tests/utils/assets/models/circle.py b/seed/python-sdk/plain-text/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/plain-text/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/plain-text/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/plain-text/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/plain-text/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/plain-text/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/plain-text/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/plain-text/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/plain-text/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/plain-text/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/plain-text/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/plain-text/tests/utils/assets/models/shape.py b/seed/python-sdk/plain-text/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/plain-text/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/plain-text/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/plain-text/tests/utils/assets/models/square.py b/seed/python-sdk/plain-text/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/plain-text/tests/utils/assets/models/square.py +++ b/seed/python-sdk/plain-text/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/plain-text/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/plain-text/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/plain-text/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/plain-text/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/plain-text/tests/utils/test_query_encoding.py b/seed/python-sdk/plain-text/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/plain-text/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/plain-text/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/query-parameters/src/seed/core/__init__.py b/seed/python-sdk/query-parameters/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/query-parameters/src/seed/core/__init__.py +++ b/seed/python-sdk/query-parameters/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py b/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/query-parameters/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/query-parameters/src/seed/core/query_encoder.py b/seed/python-sdk/query-parameters/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/query-parameters/src/seed/core/query_encoder.py +++ b/seed/python-sdk/query-parameters/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/query-parameters/tests/utils/assets/models/circle.py b/seed/python-sdk/query-parameters/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/query-parameters/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/query-parameters/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/query-parameters/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/query-parameters/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/query-parameters/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/query-parameters/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/query-parameters/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/query-parameters/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/query-parameters/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/query-parameters/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/query-parameters/tests/utils/assets/models/shape.py b/seed/python-sdk/query-parameters/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/query-parameters/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/query-parameters/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/query-parameters/tests/utils/assets/models/square.py b/seed/python-sdk/query-parameters/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/query-parameters/tests/utils/assets/models/square.py +++ b/seed/python-sdk/query-parameters/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/query-parameters/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/query-parameters/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/query-parameters/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/query-parameters/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/query-parameters/tests/utils/test_query_encoding.py b/seed/python-sdk/query-parameters/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/query-parameters/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/query-parameters/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/reserved-keywords/src/seed/core/__init__.py b/seed/python-sdk/reserved-keywords/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/reserved-keywords/src/seed/core/__init__.py +++ b/seed/python-sdk/reserved-keywords/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py b/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/reserved-keywords/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/reserved-keywords/src/seed/core/query_encoder.py b/seed/python-sdk/reserved-keywords/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/reserved-keywords/src/seed/core/query_encoder.py +++ b/seed/python-sdk/reserved-keywords/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/circle.py b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/shape.py b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/square.py b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/square.py +++ b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/reserved-keywords/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/reserved-keywords/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/reserved-keywords/tests/utils/test_query_encoding.py b/seed/python-sdk/reserved-keywords/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/reserved-keywords/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/reserved-keywords/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/response-property/src/seed/core/__init__.py b/seed/python-sdk/response-property/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/response-property/src/seed/core/__init__.py +++ b/seed/python-sdk/response-property/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py b/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/response-property/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/response-property/src/seed/core/query_encoder.py b/seed/python-sdk/response-property/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/response-property/src/seed/core/query_encoder.py +++ b/seed/python-sdk/response-property/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/response-property/tests/utils/assets/models/circle.py b/seed/python-sdk/response-property/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/response-property/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/response-property/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/response-property/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/response-property/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/response-property/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/response-property/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/response-property/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/response-property/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/response-property/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/response-property/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/response-property/tests/utils/assets/models/shape.py b/seed/python-sdk/response-property/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/response-property/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/response-property/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/response-property/tests/utils/assets/models/square.py b/seed/python-sdk/response-property/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/response-property/tests/utils/assets/models/square.py +++ b/seed/python-sdk/response-property/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/response-property/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/response-property/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/response-property/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/response-property/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/response-property/tests/utils/test_query_encoding.py b/seed/python-sdk/response-property/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/response-property/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/response-property/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/simple-fhir/src/seed/core/__init__.py b/seed/python-sdk/simple-fhir/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/simple-fhir/src/seed/core/__init__.py +++ b/seed/python-sdk/simple-fhir/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py b/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/simple-fhir/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/simple-fhir/src/seed/core/query_encoder.py b/seed/python-sdk/simple-fhir/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/simple-fhir/src/seed/core/query_encoder.py +++ b/seed/python-sdk/simple-fhir/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/simple-fhir/tests/utils/assets/models/circle.py b/seed/python-sdk/simple-fhir/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/simple-fhir/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/simple-fhir/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/simple-fhir/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/simple-fhir/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/simple-fhir/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/simple-fhir/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/simple-fhir/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/simple-fhir/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/simple-fhir/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/simple-fhir/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/simple-fhir/tests/utils/assets/models/shape.py b/seed/python-sdk/simple-fhir/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/simple-fhir/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/simple-fhir/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/simple-fhir/tests/utils/assets/models/square.py b/seed/python-sdk/simple-fhir/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/simple-fhir/tests/utils/assets/models/square.py +++ b/seed/python-sdk/simple-fhir/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/simple-fhir/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/simple-fhir/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/simple-fhir/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/simple-fhir/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/simple-fhir/tests/utils/test_query_encoding.py b/seed/python-sdk/simple-fhir/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/simple-fhir/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/simple-fhir/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/single-url-environment-default/src/seed/core/__init__.py b/seed/python-sdk/single-url-environment-default/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/single-url-environment-default/src/seed/core/__init__.py +++ b/seed/python-sdk/single-url-environment-default/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/single-url-environment-default/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/single-url-environment-default/src/seed/core/query_encoder.py b/seed/python-sdk/single-url-environment-default/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/single-url-environment-default/src/seed/core/query_encoder.py +++ b/seed/python-sdk/single-url-environment-default/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/circle.py b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/shape.py b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/square.py b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/square.py +++ b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/single-url-environment-default/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/single-url-environment-default/tests/utils/test_query_encoding.py b/seed/python-sdk/single-url-environment-default/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/single-url-environment-default/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/single-url-environment-default/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/single-url-environment-no-default/src/seed/core/__init__.py b/seed/python-sdk/single-url-environment-no-default/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/single-url-environment-no-default/src/seed/core/__init__.py +++ b/seed/python-sdk/single-url-environment-no-default/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py b/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/single-url-environment-no-default/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/single-url-environment-no-default/src/seed/core/query_encoder.py b/seed/python-sdk/single-url-environment-no-default/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/single-url-environment-no-default/src/seed/core/query_encoder.py +++ b/seed/python-sdk/single-url-environment-no-default/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/circle.py b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/shape.py b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/square.py b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/square.py +++ b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/single-url-environment-no-default/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/single-url-environment-no-default/tests/utils/test_query_encoding.py b/seed/python-sdk/single-url-environment-no-default/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/single-url-environment-no-default/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/single-url-environment-no-default/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/streaming-parameter/src/seed/core/__init__.py b/seed/python-sdk/streaming-parameter/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/streaming-parameter/src/seed/core/__init__.py +++ b/seed/python-sdk/streaming-parameter/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py b/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/streaming-parameter/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/streaming-parameter/src/seed/core/query_encoder.py b/seed/python-sdk/streaming-parameter/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/streaming-parameter/src/seed/core/query_encoder.py +++ b/seed/python-sdk/streaming-parameter/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/circle.py b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/shape.py b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/square.py b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/square.py +++ b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/streaming-parameter/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/streaming-parameter/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/streaming-parameter/tests/utils/test_query_encoding.py b/seed/python-sdk/streaming-parameter/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/streaming-parameter/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/streaming-parameter/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/streaming/no-custom-config/src/seed/core/__init__.py b/seed/python-sdk/streaming/no-custom-config/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/streaming/no-custom-config/src/seed/core/__init__.py +++ b/seed/python-sdk/streaming/no-custom-config/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/streaming/no-custom-config/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/streaming/no-custom-config/src/seed/core/query_encoder.py b/seed/python-sdk/streaming/no-custom-config/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/streaming/no-custom-config/src/seed/core/query_encoder.py +++ b/seed/python-sdk/streaming/no-custom-config/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/circle.py b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/shape.py b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/square.py b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/square.py +++ b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/streaming/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/streaming/no-custom-config/tests/utils/test_query_encoding.py b/seed/python-sdk/streaming/no-custom-config/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/streaming/no-custom-config/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/streaming/no-custom-config/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/__init__.py b/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/__init__.py index 226d7d5c439..e62bebe7ce4 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/__init__.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -39,6 +40,7 @@ "construct_type", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py b/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/query_encoder.py b/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/query_encoder.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/circle.py b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/shape.py b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/square.py b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/square.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/test_query_encoding.py b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/streaming/skip-pydantic-validation/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/trace/src/seed/core/__init__.py b/seed/python-sdk/trace/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/trace/src/seed/core/__init__.py +++ b/seed/python-sdk/trace/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py b/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/trace/src/seed/core/query_encoder.py b/seed/python-sdk/trace/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/trace/src/seed/core/query_encoder.py +++ b/seed/python-sdk/trace/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/trace/tests/utils/assets/models/circle.py b/seed/python-sdk/trace/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/trace/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/trace/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/trace/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/trace/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/trace/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/trace/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/trace/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/trace/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/trace/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/trace/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/trace/tests/utils/assets/models/shape.py b/seed/python-sdk/trace/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/trace/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/trace/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/trace/tests/utils/assets/models/square.py b/seed/python-sdk/trace/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/trace/tests/utils/assets/models/square.py +++ b/seed/python-sdk/trace/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/trace/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/trace/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/trace/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/trace/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/trace/tests/utils/test_query_encoding.py b/seed/python-sdk/trace/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/trace/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/trace/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/undiscriminated-unions/src/seed/core/__init__.py b/seed/python-sdk/undiscriminated-unions/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/undiscriminated-unions/src/seed/core/__init__.py +++ b/seed/python-sdk/undiscriminated-unions/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py b/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/undiscriminated-unions/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/undiscriminated-unions/src/seed/core/query_encoder.py b/seed/python-sdk/undiscriminated-unions/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/undiscriminated-unions/src/seed/core/query_encoder.py +++ b/seed/python-sdk/undiscriminated-unions/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/circle.py b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/shape.py b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/square.py b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/square.py +++ b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/undiscriminated-unions/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/undiscriminated-unions/tests/utils/test_query_encoding.py b/seed/python-sdk/undiscriminated-unions/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/undiscriminated-unions/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/undiscriminated-unions/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/unions/no-custom-config/src/seed/core/__init__.py b/seed/python-sdk/unions/no-custom-config/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/unions/no-custom-config/src/seed/core/__init__.py +++ b/seed/python-sdk/unions/no-custom-config/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unions/no-custom-config/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/unions/no-custom-config/src/seed/core/query_encoder.py b/seed/python-sdk/unions/no-custom-config/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/unions/no-custom-config/src/seed/core/query_encoder.py +++ b/seed/python-sdk/unions/no-custom-config/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/circle.py b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/shape.py b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/square.py b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/square.py +++ b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/unions/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/unions/no-custom-config/tests/utils/test_query_encoding.py b/seed/python-sdk/unions/no-custom-config/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/unions/no-custom-config/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/unions/no-custom-config/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/unions/union-naming-v1/src/seed/core/__init__.py b/seed/python-sdk/unions/union-naming-v1/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/unions/union-naming-v1/src/seed/core/__init__.py +++ b/seed/python-sdk/unions/union-naming-v1/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unions/union-naming-v1/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/unions/union-naming-v1/src/seed/core/query_encoder.py b/seed/python-sdk/unions/union-naming-v1/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/unions/union-naming-v1/src/seed/core/query_encoder.py +++ b/seed/python-sdk/unions/union-naming-v1/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/circle.py b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/shape.py b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/square.py b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/square.py +++ b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/unions/union-naming-v1/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/unions/union-naming-v1/tests/utils/test_query_encoding.py b/seed/python-sdk/unions/union-naming-v1/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/unions/union-naming-v1/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/unions/union-naming-v1/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/unions/union-utils/src/seed/core/__init__.py b/seed/python-sdk/unions/union-utils/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/core/__init__.py +++ b/seed/python-sdk/unions/union-utils/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unions/union-utils/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/unions/union-utils/src/seed/core/query_encoder.py b/seed/python-sdk/unions/union-utils/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/core/query_encoder.py +++ b/seed/python-sdk/unions/union-utils/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union.py index b6dfe9a1257..9d3f4887347 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union.py @@ -48,12 +48,6 @@ def get_as_union(self) -> typing.Union[_Union.Foo, _Union.Bar]: def get_as_union(self) -> typing.Union[_Union.Foo, _Union.Bar]: return self.__root__ - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - if IS_PYDANTIC_V2: - return self.root.dict(**kwargs) - else: - return self.__root__.dict(**kwargs) - def visit( self, foo: typing.Callable[[types_types_foo_Foo], T_Result], diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_base_properties.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_base_properties.py index f5ae247a9ae..528bbf11f80 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_base_properties.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_base_properties.py @@ -69,12 +69,6 @@ def get_as_union( ]: return self.__root__ - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - if IS_PYDANTIC_V2: - return self.root.dict(**kwargs) - else: - return self.__root__.dict(**kwargs) - def visit( self, integer: typing.Callable[[int], T_Result], diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_discriminant.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_discriminant.py index 7be98ba4bcd..de18727f449 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_discriminant.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_discriminant.py @@ -46,12 +46,6 @@ def get_as_union(self) -> typing.Union[_UnionWithDiscriminant.Foo, _UnionWithDis def get_as_union(self) -> typing.Union[_UnionWithDiscriminant.Foo, _UnionWithDiscriminant.Bar]: return self.__root__ - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - if IS_PYDANTIC_V2: - return self.root.dict(**kwargs) - else: - return self.__root__.dict(**kwargs) - def visit( self, foo: typing.Callable[[types_types_foo_Foo], T_Result], diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_literal.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_literal.py index d2af7baac3b..c0618c1ea12 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_literal.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_literal.py @@ -33,12 +33,6 @@ def get_as_union(self) -> typing.Union[_UnionWithLiteral.Fern]: def get_as_union(self) -> typing.Union[_UnionWithLiteral.Fern]: return self.__root__ - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - if IS_PYDANTIC_V2: - return self.root.dict(**kwargs) - else: - return self.__root__.dict(**kwargs) - def visit(self, fern: typing.Callable[[typing.Literal["fern"]], T_Result]) -> T_Result: unioned_value = self.get_as_union() if unioned_value.type == "fern": diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_optional_time.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_optional_time.py index bd80996b719..642934e1560 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_optional_time.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_optional_time.py @@ -47,12 +47,6 @@ def get_as_union(self) -> typing.Union[_UnionWithOptionalTime.Date, _UnionWithOp def get_as_union(self) -> typing.Union[_UnionWithOptionalTime.Date, _UnionWithOptionalTime.Dateimte]: return self.__root__ - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - if IS_PYDANTIC_V2: - return self.root.dict(**kwargs) - else: - return self.__root__.dict(**kwargs) - def visit( self, date: typing.Callable[[typing.Optional[dt.date]], T_Result], diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_primitive.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_primitive.py index fcdc1758e91..12fb115de9d 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_primitive.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_primitive.py @@ -44,12 +44,6 @@ def get_as_union(self) -> typing.Union[_UnionWithPrimitive.Integer, _UnionWithPr def get_as_union(self) -> typing.Union[_UnionWithPrimitive.Integer, _UnionWithPrimitive.String]: return self.__root__ - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - if IS_PYDANTIC_V2: - return self.root.dict(**kwargs) - else: - return self.__root__.dict(**kwargs) - def visit(self, integer: typing.Callable[[int], T_Result], string: typing.Callable[[str], T_Result]) -> T_Result: unioned_value = self.get_as_union() if unioned_value.type == "integer": diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_single_element.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_single_element.py index 6a7bc84e91f..b235d8263b6 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_single_element.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_single_element.py @@ -37,12 +37,6 @@ def get_as_union(self) -> typing.Union[_UnionWithSingleElement.Foo]: def get_as_union(self) -> typing.Union[_UnionWithSingleElement.Foo]: return self.__root__ - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - if IS_PYDANTIC_V2: - return self.root.dict(**kwargs) - else: - return self.__root__.dict(**kwargs) - def visit(self, foo: typing.Callable[[types_types_foo_Foo], T_Result]) -> T_Result: unioned_value = self.get_as_union() if unioned_value.type == "foo": diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_time.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_time.py index 785c8f39f4a..41a01b2ca36 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_time.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_time.py @@ -53,12 +53,6 @@ def get_as_union(self) -> typing.Union[_UnionWithTime.Value, _UnionWithTime.Date def get_as_union(self) -> typing.Union[_UnionWithTime.Value, _UnionWithTime.Date, _UnionWithTime.Datetime]: return self.__root__ - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - if IS_PYDANTIC_V2: - return self.root.dict(**kwargs) - else: - return self.__root__.dict(**kwargs) - def visit( self, value: typing.Callable[[int], T_Result], diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_unknown.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_unknown.py index a50b9b06a29..67bccf1bbec 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_unknown.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_with_unknown.py @@ -45,12 +45,6 @@ def get_as_union(self) -> typing.Union[_UnionWithUnknown.Foo, _UnionWithUnknown. def get_as_union(self) -> typing.Union[_UnionWithUnknown.Foo, _UnionWithUnknown.Unknown]: return self.__root__ - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - if IS_PYDANTIC_V2: - return self.root.dict(**kwargs) - else: - return self.__root__.dict(**kwargs) - def visit( self, foo: typing.Callable[[types_types_foo_Foo], T_Result], unknown: typing.Callable[[], T_Result] ) -> T_Result: diff --git a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_without_key.py b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_without_key.py index 3ecae1641de..5b45b23327f 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/types/types/union_without_key.py +++ b/seed/python-sdk/unions/union-utils/src/seed/types/types/union_without_key.py @@ -45,12 +45,6 @@ def get_as_union(self) -> typing.Union[_UnionWithoutKey.Foo, _UnionWithoutKey.Ba def get_as_union(self) -> typing.Union[_UnionWithoutKey.Foo, _UnionWithoutKey.Bar]: return self.__root__ - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - if IS_PYDANTIC_V2: - return self.root.dict(**kwargs) - else: - return self.__root__.dict(**kwargs) - def visit( self, foo: typing.Callable[[types_types_foo_Foo], T_Result], diff --git a/seed/python-sdk/unions/union-utils/src/seed/union/types/shape.py b/seed/python-sdk/unions/union-utils/src/seed/union/types/shape.py index dda7645f483..79999ae2835 100644 --- a/seed/python-sdk/unions/union-utils/src/seed/union/types/shape.py +++ b/seed/python-sdk/unions/union-utils/src/seed/union/types/shape.py @@ -45,12 +45,6 @@ def get_as_union(self) -> typing.Union[_Shape.Circle, _Shape.Square]: def get_as_union(self) -> typing.Union[_Shape.Circle, _Shape.Square]: return self.__root__ - def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - if IS_PYDANTIC_V2: - return self.root.dict(**kwargs) - else: - return self.__root__.dict(**kwargs) - def visit( self, circle: typing.Callable[[union_types_circle_Circle], T_Result], diff --git a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/circle.py b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/shape.py b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/square.py b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/square.py +++ b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/unions/union-utils/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/unions/union-utils/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/unions/union-utils/tests/utils/test_query_encoding.py b/seed/python-sdk/unions/union-utils/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/unions/union-utils/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/unions/union-utils/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/unknown/src/seed/core/__init__.py b/seed/python-sdk/unknown/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/unknown/src/seed/core/__init__.py +++ b/seed/python-sdk/unknown/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py b/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/unknown/src/seed/core/query_encoder.py b/seed/python-sdk/unknown/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/unknown/src/seed/core/query_encoder.py +++ b/seed/python-sdk/unknown/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/unknown/tests/utils/assets/models/circle.py b/seed/python-sdk/unknown/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/unknown/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/unknown/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unknown/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/unknown/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/unknown/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/unknown/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/unknown/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/unknown/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/unknown/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/unknown/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/unknown/tests/utils/assets/models/shape.py b/seed/python-sdk/unknown/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/unknown/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/unknown/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unknown/tests/utils/assets/models/square.py b/seed/python-sdk/unknown/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/unknown/tests/utils/assets/models/square.py +++ b/seed/python-sdk/unknown/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/unknown/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/unknown/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/unknown/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/unknown/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/unknown/tests/utils/test_query_encoding.py b/seed/python-sdk/unknown/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/unknown/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/unknown/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/validation/no-custom-config/src/seed/core/__init__.py b/seed/python-sdk/validation/no-custom-config/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/validation/no-custom-config/src/seed/core/__init__.py +++ b/seed/python-sdk/validation/no-custom-config/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py b/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/validation/no-custom-config/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/validation/no-custom-config/src/seed/core/query_encoder.py b/seed/python-sdk/validation/no-custom-config/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/validation/no-custom-config/src/seed/core/query_encoder.py +++ b/seed/python-sdk/validation/no-custom-config/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/circle.py b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/shape.py b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/square.py b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/square.py +++ b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/validation/no-custom-config/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/validation/no-custom-config/tests/utils/test_query_encoding.py b/seed/python-sdk/validation/no-custom-config/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/validation/no-custom-config/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/validation/no-custom-config/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/validation/with-defaults/src/seed/core/__init__.py b/seed/python-sdk/validation/with-defaults/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/validation/with-defaults/src/seed/core/__init__.py +++ b/seed/python-sdk/validation/with-defaults/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py b/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/validation/with-defaults/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/validation/with-defaults/src/seed/core/query_encoder.py b/seed/python-sdk/validation/with-defaults/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/validation/with-defaults/src/seed/core/query_encoder.py +++ b/seed/python-sdk/validation/with-defaults/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/circle.py b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/shape.py b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/square.py b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/square.py +++ b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/validation/with-defaults/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/validation/with-defaults/tests/utils/test_query_encoding.py b/seed/python-sdk/validation/with-defaults/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/validation/with-defaults/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/validation/with-defaults/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/variables/src/seed/core/__init__.py b/seed/python-sdk/variables/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/variables/src/seed/core/__init__.py +++ b/seed/python-sdk/variables/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py b/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/variables/src/seed/core/query_encoder.py b/seed/python-sdk/variables/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/variables/src/seed/core/query_encoder.py +++ b/seed/python-sdk/variables/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/variables/tests/utils/assets/models/circle.py b/seed/python-sdk/variables/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/variables/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/variables/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/variables/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/variables/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/variables/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/variables/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/variables/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/variables/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/variables/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/variables/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/variables/tests/utils/assets/models/shape.py b/seed/python-sdk/variables/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/variables/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/variables/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/variables/tests/utils/assets/models/square.py b/seed/python-sdk/variables/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/variables/tests/utils/assets/models/square.py +++ b/seed/python-sdk/variables/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/variables/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/variables/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/variables/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/variables/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/variables/tests/utils/test_query_encoding.py b/seed/python-sdk/variables/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/variables/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/variables/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: diff --git a/seed/python-sdk/websocket/src/seed/core/__init__.py b/seed/python-sdk/websocket/src/seed/core/__init__.py index 4213c349a1d..5a0bee343d0 100644 --- a/seed/python-sdk/websocket/src/seed/core/__init__.py +++ b/seed/python-sdk/websocket/src/seed/core/__init__.py @@ -10,6 +10,7 @@ IS_PYDANTIC_V2, UniversalBaseModel, UniversalRootModel, + deep_union_pydantic_dicts, parse_obj_as, universal_field_validator, universal_root_validator, @@ -35,6 +36,7 @@ "UniversalRootModel", "convert_and_respect_annotation_metadata", "convert_file_dict_to_httpx_tuples", + "deep_union_pydantic_dicts", "encode_query", "jsonable_encoder", "parse_obj_as", diff --git a/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py b/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py index eb429181594..06bc2b9e10c 100644 --- a/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py @@ -55,6 +55,19 @@ Model = typing.TypeVar("Model", bound=pydantic.BaseModel) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 @@ -93,34 +106,27 @@ def json(self, **kwargs: typing.Any) -> str: return super().json(**kwargs_with_defaults) def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: - """ - Override the default dict method to `exclude_unset` by default. This function patches - `exclude_unset` to work include fields within non-None default values. - """ - _fields_set = self.__fields_set__ - - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) - - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { "by_alias": True, "exclude_unset": True, - "include": _fields_set, + **kwargs, + } + kwargs_with_defaults_exclude_none: typing.Any = { + "by_alias": True, + "exclude_none": True, **kwargs, } if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + return deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), + super().dict(**kwargs_with_defaults_exclude_none), + ) if IS_PYDANTIC_V2: @@ -178,29 +184,3 @@ def decorator(func: AnyCallable) -> AnyCallable: return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1 return decorator - - -PydanticField = typing.Union[ModelField, pydantic.fields.FieldInfo] - - -def _get_model_fields( - model: typing.Type["Model"], -) -> typing.Mapping[str, PydanticField]: - if IS_PYDANTIC_V2: - return model.model_fields # type: ignore # Pydantic v2 - else: - return model.__fields__ # type: ignore # Pydantic v1 - - -def _get_field_default(field: PydanticField) -> typing.Any: - try: - value = field.get_default() # type: ignore # Pydantic < v1.10.15 - except: - value = field.default - if IS_PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None - return value - return value diff --git a/seed/python-sdk/websocket/src/seed/core/query_encoder.py b/seed/python-sdk/websocket/src/seed/core/query_encoder.py index 24076d72ee9..3183001d404 100644 --- a/seed/python-sdk/websocket/src/seed/core/query_encoder.py +++ b/seed/python-sdk/websocket/src/seed/core/query_encoder.py @@ -1,33 +1,58 @@ # This file was auto-generated by Fern from our API Definition. -from collections import ChainMap -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional, Tuple import pydantic # Flattens dicts to be of the form {"key[subkey][subkey2]": value} where value is not a dict -def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> Dict[str, Any]: - result = {} +def traverse_query_dict(dict_flat: Dict[str, Any], key_prefix: Optional[str] = None) -> List[Tuple[str, Any]]: + result = [] for k, v in dict_flat.items(): key = f"{key_prefix}[{k}]" if key_prefix is not None else k if isinstance(v, dict): - result.update(traverse_query_dict(v, key)) + result.extend(traverse_query_dict(v, key)) + elif isinstance(v, list): + for arr_v in v: + if isinstance(arr_v, dict): + result.extend(traverse_query_dict(arr_v, key)) + else: + result.append((key, arr_v)) else: - result[key] = v + result.append((key, v)) return result -def single_query_encoder(query_key: str, query_value: Any) -> Dict[str, Any]: +def single_query_encoder(query_key: str, query_value: Any) -> List[Tuple[str, Any]]: if isinstance(query_value, pydantic.BaseModel) or isinstance(query_value, dict): if isinstance(query_value, pydantic.BaseModel): obj_dict = query_value.dict(by_alias=True) else: obj_dict = query_value return traverse_query_dict(obj_dict, query_key) + elif isinstance(query_value, list): + encoded_values: List[Tuple[str, Any]] = [] + for value in query_value: + if isinstance(value, pydantic.BaseModel) or isinstance(value, dict): + if isinstance(value, pydantic.BaseModel): + obj_dict = value.dict(by_alias=True) + elif isinstance(value, dict): + obj_dict = value - return {query_key: query_value} + encoded_values.extend(single_query_encoder(query_key, obj_dict)) + else: + encoded_values.append((query_key, value)) + return encoded_values -def encode_query(query: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: - return dict(ChainMap(*[single_query_encoder(k, v) for k, v in query.items()])) if query is not None else None + return [(query_key, query_value)] + + +def encode_query(query: Optional[Dict[str, Any]]) -> Optional[List[Tuple[str, Any]]]: + if query is None: + return None + + encoded_query = [] + for k, v in query.items(): + encoded_query.extend(single_query_encoder(k, v)) + return encoded_query diff --git a/seed/python-sdk/websocket/tests/utils/assets/models/circle.py b/seed/python-sdk/websocket/tests/utils/assets/models/circle.py index 6522dc58c5a..74ecf38c308 100644 --- a/seed/python-sdk/websocket/tests/utils/assets/models/circle.py +++ b/seed/python-sdk/websocket/tests/utils/assets/models/circle.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/websocket/tests/utils/assets/models/object_with_defaults.py b/seed/python-sdk/websocket/tests/utils/assets/models/object_with_defaults.py index ef14f7b2c9d..a977b1d2aa1 100644 --- a/seed/python-sdk/websocket/tests/utils/assets/models/object_with_defaults.py +++ b/seed/python-sdk/websocket/tests/utils/assets/models/object_with_defaults.py @@ -3,7 +3,6 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions class ObjectWithDefaultsParams(typing_extensions.TypedDict): diff --git a/seed/python-sdk/websocket/tests/utils/assets/models/object_with_optional_field.py b/seed/python-sdk/websocket/tests/utils/assets/models/object_with_optional_field.py index fc5a379b967..4086c2356b1 100644 --- a/seed/python-sdk/websocket/tests/utils/assets/models/object_with_optional_field.py +++ b/seed/python-sdk/websocket/tests/utils/assets/models/object_with_optional_field.py @@ -2,12 +2,13 @@ # This file was auto-generated by Fern from our API Definition. -import typing_extensions +import datetime as dt import typing +import uuid + import typing_extensions + from seed.core.serialization import FieldMetadata -import datetime as dt -import uuid from .color import Color from .shape import ShapeParams from .undiscriminated_shape import UndiscriminatedShapeParams @@ -31,4 +32,4 @@ class ObjectWithOptionalFieldParams(typing_extensions.TypedDict): union: typing_extensions.NotRequired[ShapeParams] second_union: typing_extensions.NotRequired[ShapeParams] undiscriminated_union: typing_extensions.NotRequired[UndiscriminatedShapeParams] - any: typing.Optional[typing.Any] + any: typing.Any diff --git a/seed/python-sdk/websocket/tests/utils/assets/models/shape.py b/seed/python-sdk/websocket/tests/utils/assets/models/shape.py index ae113ae0609..7e70010a251 100644 --- a/seed/python-sdk/websocket/tests/utils/assets/models/shape.py +++ b/seed/python-sdk/websocket/tests/utils/assets/models/shape.py @@ -3,9 +3,11 @@ # This file was auto-generated by Fern from our API Definition. from __future__ import annotations -import typing_extensions -import typing_extensions + import typing + +import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/websocket/tests/utils/assets/models/square.py b/seed/python-sdk/websocket/tests/utils/assets/models/square.py index 7f6f79a3ddc..71c7d25fd4a 100644 --- a/seed/python-sdk/websocket/tests/utils/assets/models/square.py +++ b/seed/python-sdk/websocket/tests/utils/assets/models/square.py @@ -3,7 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing_extensions -import typing_extensions + from seed.core.serialization import FieldMetadata diff --git a/seed/python-sdk/websocket/tests/utils/assets/models/undiscriminated_shape.py b/seed/python-sdk/websocket/tests/utils/assets/models/undiscriminated_shape.py index 68876a23c38..99f12b300d1 100644 --- a/seed/python-sdk/websocket/tests/utils/assets/models/undiscriminated_shape.py +++ b/seed/python-sdk/websocket/tests/utils/assets/models/undiscriminated_shape.py @@ -3,6 +3,7 @@ # This file was auto-generated by Fern from our API Definition. import typing + from .circle import CircleParams from .square import SquareParams diff --git a/seed/python-sdk/websocket/tests/utils/test_query_encoding.py b/seed/python-sdk/websocket/tests/utils/test_query_encoding.py index 24a165a48ca..e075394a502 100644 --- a/seed/python-sdk/websocket/tests/utils/test_query_encoding.py +++ b/seed/python-sdk/websocket/tests/utils/test_query_encoding.py @@ -4,14 +4,32 @@ from seed.core.query_encoder import encode_query -def test_query_encoding() -> None: - assert encode_query({"hello world": "hello world"}) == {"hello world": "hello world"} - assert encode_query({"hello_world": {"hello": "world"}}) == {"hello_world[hello]": "world"} - assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == { - "hello_world[hello][world]": "today", - "hello_world[test]": "this", - "hi": "there", - } +def test_query_encoding_deep_objects() -> None: + assert encode_query({"hello world": "hello world"}) == [("hello world", "hello world")] + assert encode_query({"hello_world": {"hello": "world"}}) == [("hello_world[hello]", "world")] + assert encode_query({"hello_world": {"hello": {"world": "today"}, "test": "this"}, "hi": "there"}) == [ + ("hello_world[hello][world]", "today"), + ("hello_world[test]", "this"), + ("hi", "there"), + ] + + +def test_query_encoding_deep_object_arrays() -> None: + assert encode_query({"objects": [{"key": "hello", "value": "world"}, {"key": "foo", "value": "bar"}]}) == [ + ("objects[key]", "hello"), + ("objects[value]", "world"), + ("objects[key]", "foo"), + ("objects[value]", "bar"), + ] + assert encode_query( + {"users": [{"name": "string", "tags": ["string"]}, {"name": "string2", "tags": ["string2", "string3"]}]} + ) == [ + ("users[name]", "string"), + ("users[tags]", "string"), + ("users[name]", "string2"), + ("users[tags]", "string2"), + ("users[tags]", "string3"), + ] def test_encode_query_with_none() -> None: