From d2a3c2ab343d1e1f52c0ef10cb1d6c71525b77a0 Mon Sep 17 00:00:00 2001 From: armandobelardo Date: Thu, 5 Sep 2024 09:53:59 -0400 Subject: [PATCH 1/8] fix(python): pydantic V2 .dict calls once again use dict merging --- .../fastapi/pydantic_utilities.py | 71 +++-- .../pydantic/pydantic_utilities.py | 71 +++-- .../core_utilities/sdk/pydantic_utilities.py | 71 +++-- generators/python/sdk/versions.yml | 11 + .../alias-extends/core/pydantic_utilities.py | 73 +++-- seed/fastapi/alias/core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../audiences/core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../basic-auth/core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- seed/fastapi/code-samples/core/__init__.py | 3 + .../code-samples/core/pydantic_utilities.py | 104 ++++--- .../code-samples/core/serialization.py | 258 ++++++++++++++++++ .../core/pydantic_utilities.py | 73 +++-- .../custom-auth/core/pydantic_utilities.py | 73 +++-- .../error-property/core/pydantic_utilities.py | 73 +++-- .../examples/core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../pydantic-v1/core/pydantic_utilities.py | 73 +++-- .../pydantic-v2/core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../extends/core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../folders/core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../grpc-proto/core/pydantic_utilities.py | 73 +++-- seed/fastapi/grpc/core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../async-handlers/core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../mixed-case/core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../no-environment/core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../fastapi/object/core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../optional/core/pydantic_utilities.py | 73 +++-- .../package-yml/core/pydantic_utilities.py | 73 +++-- .../pagination/core/pydantic_utilities.py | 73 +++-- .../plain-text/core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../simple-fhir/core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- seed/fastapi/trace/core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../fastapi/unions/core/pydantic_utilities.py | 73 +++-- .../unknown/core/pydantic_utilities.py | 73 +++-- .../validation/core/pydantic_utilities.py | 73 +++-- .../variables/core/pydantic_utilities.py | 73 +++-- .../core/pydantic_utilities.py | 73 +++-- .../version/core/pydantic_utilities.py | 73 +++-- .../websocket/core/pydantic_utilities.py | 73 +++-- .../alias_extends/core/pydantic_utilities.py | 71 +++-- .../src/seed/alias/core/pydantic_utilities.py | 71 +++-- .../seed/any_auth/core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../seed/audiences/core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../basic_auth/core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../src/seed/bytes/core/pydantic_utilities.py | 71 +++-- .../src/seed/api/core/pydantic_utilities.py | 71 +++-- .../src/seed/api/core/pydantic_utilities.py | 71 +++-- .../code_samples/core/pydantic_utilities.py | 100 ++++--- .../seed/code_samples/core/serialization.py | 164 ++++++++--- .../core/pydantic_utilities.py | 71 +++-- .../custom_auth/core/pydantic_utilities.py | 71 +++-- .../src/seed/enum/core/pydantic_utilities.py | 71 +++-- .../error_property/core/pydantic_utilities.py | 71 +++-- .../seed/examples/core/pydantic_utilities.py | 71 +++-- .../exhaustive/core/pydantic_utilities.py | 71 +++-- .../exhaustive/core/pydantic_utilities.py | 71 +++-- .../seed/extends/core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../file_download/core/pydantic_utilities.py | 71 +++-- .../file_upload/core/pydantic_utilities.py | 71 +++-- .../src/seed/api/core/pydantic_utilities.py | 71 +++-- .../src/seed/api/core/pydantic_utilities.py | 71 +++-- .../src/seed/api/core/pydantic_utilities.py | 71 +++-- .../src/seed/api/core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../src/seed/api/core/pydantic_utilities.py | 71 +++-- .../seed/literal/core/pydantic_utilities.py | 71 +++-- .../mixed_case/core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../no_environment/core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../seed/object/core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../package_yml/core/pydantic_utilities.py | 71 +++-- .../pagination/core/pydantic_utilities.py | 71 +++-- .../plain_text/core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../nursery_api/core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../src/seed/api/core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../seed/streaming/core/pydantic_utilities.py | 71 +++-- .../seed/streaming/core/pydantic_utilities.py | 71 +++-- .../src/seed/trace/core/pydantic_utilities.py | 71 +++-- .../core/pydantic_utilities.py | 71 +++-- .../seed/unions/core/pydantic_utilities.py | 71 +++-- .../unknown_as_any/core/pydantic_utilities.py | 71 +++-- .../validation/core/pydantic_utilities.py | 71 +++-- .../seed/variables/core/pydantic_utilities.py | 71 +++-- .../seed/version/core/pydantic_utilities.py | 71 +++-- .../seed/version/core/pydantic_utilities.py | 71 +++-- .../seed/websocket/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../alias/src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../bytes/src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 100 ++++--- .../src/seed/core/serialization.py | 164 ++++++++--- .../tests/utils/test_serialization.py | 16 +- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../grpc/src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../imdb/src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../trace/src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../src/seed/core/pydantic_utilities.py | 71 +++-- .../fern/apis/literal/definition/inlined.yml | 9 + 216 files changed, 11311 insertions(+), 4358 deletions(-) create mode 100644 seed/fastapi/code-samples/core/serialization.py diff --git a/generators/python/core_utilities/fastapi/pydantic_utilities.py b/generators/python/core_utilities/fastapi/pydantic_utilities.py index a32a33cfc99..e42d554581e 100644 --- a/generators/python/core_utilities/fastapi/pydantic_utilities.py +++ b/generators/python/core_utilities/fastapi/pydantic_utilities.py @@ -102,33 +102,62 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination if IS_PYDANTIC_V2: diff --git a/generators/python/core_utilities/pydantic/pydantic_utilities.py b/generators/python/core_utilities/pydantic/pydantic_utilities.py index a32a33cfc99..e42d554581e 100644 --- a/generators/python/core_utilities/pydantic/pydantic_utilities.py +++ b/generators/python/core_utilities/pydantic/pydantic_utilities.py @@ -102,33 +102,62 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination if IS_PYDANTIC_V2: diff --git a/generators/python/core_utilities/sdk/pydantic_utilities.py b/generators/python/core_utilities/sdk/pydantic_utilities.py index a32a33cfc99..e42d554581e 100644 --- a/generators/python/core_utilities/sdk/pydantic_utilities.py +++ b/generators/python/core_utilities/sdk/pydantic_utilities.py @@ -102,33 +102,62 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination if IS_PYDANTIC_V2: diff --git a/generators/python/sdk/versions.yml b/generators/python/sdk/versions.yml index 1d6ad12a9da..0ea0d451007 100644 --- a/generators/python/sdk/versions.yml +++ b/generators/python/sdk/versions.yml @@ -1,4 +1,15 @@ # For unreleased changes, use unreleased.yml +- version: 3.11.1-rc0 + ir_version: 53 + changelog_entry: + - type: fix + summary: Update .dict calls in Pydantic V2 to be back to pre-3.10.4 logic. + fixed: + - >- + Pydantic V2 `.dict` calls are updated to be back to pre-3.10.4 logic. + This is fix a regression where nested literals were being omitted due to the Pydantic V2 serializers not respecting the recursive .dict logic, as + Pydantic V2 shells out `model_dump` calls to Rust library and serializers, as opposed to recursively calling `model_dump`. + - version: 3.11.0-rc0 ir_version: 53 changelog_entry: diff --git a/seed/fastapi/alias-extends/core/pydantic_utilities.py b/seed/fastapi/alias-extends/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/alias-extends/core/pydantic_utilities.py +++ b/seed/fastapi/alias-extends/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/alias/core/pydantic_utilities.py b/seed/fastapi/alias/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/alias/core/pydantic_utilities.py +++ b/seed/fastapi/alias/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 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 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py +++ b/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/audiences/core/pydantic_utilities.py b/seed/fastapi/audiences/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/audiences/core/pydantic_utilities.py +++ b/seed/fastapi/audiences/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py b/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 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 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/basic-auth/core/pydantic_utilities.py b/seed/fastapi/basic-auth/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/basic-auth/core/pydantic_utilities.py +++ b/seed/fastapi/basic-auth/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 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 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py +++ b/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py b/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py +++ b/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/circular-references/core/pydantic_utilities.py b/seed/fastapi/circular-references/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/circular-references/core/pydantic_utilities.py +++ b/seed/fastapi/circular-references/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/code-samples/core/__init__.py b/seed/fastapi/code-samples/core/__init__.py index b40f82b07df..f9c8e44aea0 100644 --- a/seed/fastapi/code-samples/core/__init__.py +++ b/seed/fastapi/code-samples/core/__init__.py @@ -19,14 +19,17 @@ ) from .route_args import route_args from .security import BearerToken +from .serialization import FieldMetadata, convert_and_respect_annotation_metadata __all__ = [ "BearerToken", "FernHTTPException", + "FieldMetadata", "IS_PYDANTIC_V2", "UnauthorizedException", "UniversalBaseModel", "UniversalRootModel", + "convert_and_respect_annotation_metadata", "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 32b162d03f8..e5ce0a87860 100644 --- a/seed/fastapi/code-samples/core/pydantic_utilities.py +++ b/seed/fastapi/code-samples/core/pydantic_utilities.py @@ -10,6 +10,7 @@ import pydantic from .datetime_utils import serialize_datetime +from .serialization import convert_and_respect_annotation_metadata IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.") @@ -56,11 +57,14 @@ def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: + dealiased_object = convert_and_respect_annotation_metadata( + object_=object_, annotation=type_, direction="read" + ) if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 - return adapter.validate_python(object_) + return adapter.validate_python(dealiased_object) else: - return pydantic.parse_obj_as(type_, object_) + return pydantic.parse_obj_as(type_, dealiased_object) def to_jsonable_with_fallback( @@ -75,13 +79,16 @@ def to_jsonable_with_fallback( class UniversalBaseModel(pydantic.BaseModel): - class Config: - populate_by_name = True - smart_union = True - allow_population_by_field_name = True - json_encoders = {dt.datetime: serialize_datetime} - # Allow fields begining with `model_` to be used in the model - protected_namespaces = () + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + protected_namespaces=(), + json_encoders={dt.datetime: serialize_datetime}, + ) # type: ignore # Pydantic v2 + else: + + class Config: + smart_union = True + json_encoders = {dt.datetime: serialize_datetime} def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = { @@ -99,30 +106,65 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + + return convert_and_respect_annotation_metadata( + object_=dict_dump, annotation=self.__class__, direction="write" + ) + + +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value + + return destination if IS_PYDANTIC_V2: diff --git a/seed/fastapi/code-samples/core/serialization.py b/seed/fastapi/code-samples/core/serialization.py new file mode 100644 index 00000000000..f9aa93a75a7 --- /dev/null +++ b/seed/fastapi/code-samples/core/serialization.py @@ -0,0 +1,258 @@ +# This file was auto-generated by Fern from our API Definition. + +import collections +import inspect +import typing + +import typing_extensions + +import pydantic + + +class FieldMetadata: + """ + Metadata class used to annotate fields to provide additional information. + + Example: + class MyDict(TypedDict): + field: typing.Annotated[str, FieldMetadata(alias="field_name")] + + Will serialize: `{"field": "value"}` + To: `{"field_name": "value"}` + """ + + alias: str + + def __init__(self, *, alias: str) -> None: + self.alias = alias + + +def convert_and_respect_annotation_metadata( + *, + object_: typing.Any, + annotation: typing.Any, + inner_type: typing.Optional[typing.Any] = None, + direction: typing.Literal["read", "write"], +) -> typing.Any: + """ + Respect the metadata annotations on a field, such as aliasing. This function effectively + manipulates the dict-form of an object to respect the metadata annotations. This is primarily used for + TypedDicts, which cannot support aliasing out of the box, and can be extended for additional + utilities, such as defaults. + + Parameters + ---------- + object_ : typing.Any + + annotation : type + The type we're looking to apply typing annotations from + + inner_type : typing.Optional[type] + + Returns + ------- + typing.Any + """ + + if object_ is None: + return None + if inner_type is None: + inner_type = annotation + + clean_type = _remove_annotations(inner_type) + # Pydantic models + if ( + inspect.isclass(clean_type) + and issubclass(clean_type, pydantic.BaseModel) + and isinstance(object_, typing.Mapping) + ): + return _convert_mapping(object_, clean_type, direction) + # TypedDicts + if typing_extensions.is_typeddict(clean_type) and isinstance( + object_, typing.Mapping + ): + return _convert_mapping(object_, clean_type, direction) + + # If you're iterating on a string, do not bother to coerce it to a sequence. + if not isinstance(object_, str): + if ( + typing_extensions.get_origin(clean_type) == typing.Set + or typing_extensions.get_origin(clean_type) == set + or clean_type == typing.Set + ) and isinstance(object_, typing.Set): + inner_type = typing_extensions.get_args(clean_type)[0] + return { + convert_and_respect_annotation_metadata( + object_=item, + annotation=annotation, + inner_type=inner_type, + direction=direction, + ) + for item in object_ + } + elif ( + ( + typing_extensions.get_origin(clean_type) == typing.List + or typing_extensions.get_origin(clean_type) == list + or clean_type == typing.List + ) + and isinstance(object_, typing.List) + ) or ( + ( + typing_extensions.get_origin(clean_type) == typing.Sequence + or typing_extensions.get_origin(clean_type) == collections.abc.Sequence + or clean_type == typing.Sequence + ) + and isinstance(object_, typing.Sequence) + ): + inner_type = typing_extensions.get_args(clean_type)[0] + return [ + convert_and_respect_annotation_metadata( + object_=item, + annotation=annotation, + inner_type=inner_type, + direction=direction, + ) + for item in object_ + ] + + if typing_extensions.get_origin(clean_type) == typing.Union: + # We should be able to ~relatively~ safely try to convert keys against all + # member types in the union, the edge case here is if one member aliases a field + # 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, + direction=direction, + ) + return object_ + + annotated_type = _get_annotation(annotation) + if annotated_type is None: + return object_ + + # If the object is not a TypedDict, a Union, or other container (list, set, sequence, etc.) + # Then we can safely call it on the recursive conversion. + return object_ + + +def _convert_mapping( + object_: typing.Mapping[str, object], + expected_type: typing.Any, + direction: typing.Literal["read", "write"], +) -> typing.Mapping[str, object]: + converted_object: typing.Dict[str, object] = {} + annotations = typing_extensions.get_type_hints(expected_type, include_extras=True) + aliases_to_field_names = _get_alias_to_field_name(annotations) + for key, value in object_.items(): + if direction == "read" and key in aliases_to_field_names: + dealiased_key = aliases_to_field_names.get(key) + if dealiased_key is not None: + type_ = annotations.get(dealiased_key) + else: + type_ = annotations.get(key) + # Note you can't get the annotation by the field name if you're in read mode, so you must check the aliases map + # + # So this is effectively saying if we're in write mode, and we don't have a type, or if we're in read mode and we don't have an alias + # then we can just pass the value through as is + if type_ is None: + converted_object[key] = value + elif direction == "read" and key not in aliases_to_field_names: + converted_object[key] = convert_and_respect_annotation_metadata( + object_=value, annotation=type_, direction=direction + ) + else: + converted_object[ + _alias_key(key, type_, direction, aliases_to_field_names) + ] = convert_and_respect_annotation_metadata( + object_=value, annotation=type_, direction=direction + ) + return converted_object + + +def _get_annotation(type_: typing.Any) -> typing.Optional[typing.Any]: + maybe_annotated_type = typing_extensions.get_origin(type_) + if maybe_annotated_type is None: + return None + + if maybe_annotated_type == typing_extensions.NotRequired: + type_ = typing_extensions.get_args(type_)[0] + maybe_annotated_type = typing_extensions.get_origin(type_) + + if maybe_annotated_type == typing_extensions.Annotated: + return type_ + + return None + + +def _remove_annotations(type_: typing.Any) -> typing.Any: + maybe_annotated_type = typing_extensions.get_origin(type_) + if maybe_annotated_type is None: + return type_ + + if maybe_annotated_type == typing_extensions.NotRequired: + return _remove_annotations(typing_extensions.get_args(type_)[0]) + + if maybe_annotated_type == typing_extensions.Annotated: + return _remove_annotations(typing_extensions.get_args(type_)[0]) + + return type_ + + +def get_alias_to_field_mapping(type_: typing.Any) -> typing.Dict[str, str]: + annotations = typing_extensions.get_type_hints(type_, include_extras=True) + return _get_alias_to_field_name(annotations) + + +def get_field_to_alias_mapping(type_: typing.Any) -> typing.Dict[str, str]: + annotations = typing_extensions.get_type_hints(type_, include_extras=True) + return _get_field_to_alias_name(annotations) + + +def _get_alias_to_field_name( + field_to_hint: typing.Dict[str, typing.Any], +) -> typing.Dict[str, str]: + aliases = {} + for field, hint in field_to_hint.items(): + maybe_alias = _get_alias_from_type(hint) + if maybe_alias is not None: + aliases[maybe_alias] = field + return aliases + + +def _get_field_to_alias_name( + field_to_hint: typing.Dict[str, typing.Any], +) -> typing.Dict[str, str]: + aliases = {} + for field, hint in field_to_hint.items(): + maybe_alias = _get_alias_from_type(hint) + if maybe_alias is not None: + aliases[field] = maybe_alias + return aliases + + +def _get_alias_from_type(type_: typing.Any) -> typing.Optional[str]: + maybe_annotated_type = _get_annotation(type_) + + if maybe_annotated_type is not None: + # The actual annotations are 1 onward, the first is the annotated type + annotations = typing_extensions.get_args(maybe_annotated_type)[1:] + + for annotation in annotations: + if isinstance(annotation, FieldMetadata) and annotation.alias is not None: + return annotation.alias + return None + + +def _alias_key( + key: str, + type_: typing.Any, + direction: typing.Literal["read", "write"], + aliases_to_field_names: typing.Dict[str, str], +) -> str: + if direction == "read": + return aliases_to_field_names.get(key, key) + return _get_alias_from_type(type_=type_) or key diff --git a/seed/fastapi/cross-package-type-names/core/pydantic_utilities.py b/seed/fastapi/cross-package-type-names/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/cross-package-type-names/core/pydantic_utilities.py +++ b/seed/fastapi/cross-package-type-names/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/custom-auth/core/pydantic_utilities.py b/seed/fastapi/custom-auth/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/custom-auth/core/pydantic_utilities.py +++ b/seed/fastapi/custom-auth/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/error-property/core/pydantic_utilities.py b/seed/fastapi/error-property/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/error-property/core/pydantic_utilities.py +++ b/seed/fastapi/error-property/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/examples/core/pydantic_utilities.py b/seed/fastapi/examples/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/examples/core/pydantic_utilities.py +++ b/seed/fastapi/examples/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py b/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 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 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py b/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py b/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py b/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/extends/core/pydantic_utilities.py b/seed/fastapi/extends/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/extends/core/pydantic_utilities.py +++ b/seed/fastapi/extends/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/extra-properties/core/pydantic_utilities.py b/seed/fastapi/extra-properties/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/extra-properties/core/pydantic_utilities.py +++ b/seed/fastapi/extra-properties/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/folders/core/pydantic_utilities.py b/seed/fastapi/folders/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/folders/core/pydantic_utilities.py +++ b/seed/fastapi/folders/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/grpc-proto-exhaustive/core/pydantic_utilities.py b/seed/fastapi/grpc-proto-exhaustive/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/grpc-proto-exhaustive/core/pydantic_utilities.py +++ b/seed/fastapi/grpc-proto-exhaustive/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/grpc-proto/core/pydantic_utilities.py b/seed/fastapi/grpc-proto/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/grpc-proto/core/pydantic_utilities.py +++ b/seed/fastapi/grpc-proto/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/grpc/core/pydantic_utilities.py b/seed/fastapi/grpc/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/grpc/core/pydantic_utilities.py +++ b/seed/fastapi/grpc/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/idempotency-headers/core/pydantic_utilities.py b/seed/fastapi/idempotency-headers/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/idempotency-headers/core/pydantic_utilities.py +++ b/seed/fastapi/idempotency-headers/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py b/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 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 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 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 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/mixed-case/core/pydantic_utilities.py b/seed/fastapi/mixed-case/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/mixed-case/core/pydantic_utilities.py +++ b/seed/fastapi/mixed-case/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/multi-line-docs/core/pydantic_utilities.py b/seed/fastapi/multi-line-docs/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/multi-line-docs/core/pydantic_utilities.py +++ b/seed/fastapi/multi-line-docs/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 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 5a85b5acabc..e5ce0a87860 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 @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/multi-url-environment/core/pydantic_utilities.py b/seed/fastapi/multi-url-environment/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/multi-url-environment/core/pydantic_utilities.py +++ b/seed/fastapi/multi-url-environment/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/no-environment/core/pydantic_utilities.py b/seed/fastapi/no-environment/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/no-environment/core/pydantic_utilities.py +++ b/seed/fastapi/no-environment/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 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 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 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 5a85b5acabc..e5ce0a87860 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 @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 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 5a85b5acabc..e5ce0a87860 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 @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/object/core/pydantic_utilities.py b/seed/fastapi/object/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/object/core/pydantic_utilities.py +++ b/seed/fastapi/object/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/objects-with-imports/core/pydantic_utilities.py b/seed/fastapi/objects-with-imports/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/objects-with-imports/core/pydantic_utilities.py +++ b/seed/fastapi/objects-with-imports/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/optional/core/pydantic_utilities.py b/seed/fastapi/optional/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/optional/core/pydantic_utilities.py +++ b/seed/fastapi/optional/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/package-yml/core/pydantic_utilities.py b/seed/fastapi/package-yml/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/package-yml/core/pydantic_utilities.py +++ b/seed/fastapi/package-yml/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/pagination/core/pydantic_utilities.py b/seed/fastapi/pagination/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/pagination/core/pydantic_utilities.py +++ b/seed/fastapi/pagination/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/plain-text/core/pydantic_utilities.py b/seed/fastapi/plain-text/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/plain-text/core/pydantic_utilities.py +++ b/seed/fastapi/plain-text/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/reserved-keywords/core/pydantic_utilities.py b/seed/fastapi/reserved-keywords/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/reserved-keywords/core/pydantic_utilities.py +++ b/seed/fastapi/reserved-keywords/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/simple-fhir/core/pydantic_utilities.py b/seed/fastapi/simple-fhir/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/simple-fhir/core/pydantic_utilities.py +++ b/seed/fastapi/simple-fhir/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 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 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py +++ b/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 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 5a85b5acabc..e5ce0a87860 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 @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/trace/core/pydantic_utilities.py b/seed/fastapi/trace/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/trace/core/pydantic_utilities.py +++ b/seed/fastapi/trace/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py b/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py +++ b/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/unions/core/pydantic_utilities.py b/seed/fastapi/unions/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/unions/core/pydantic_utilities.py +++ b/seed/fastapi/unions/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/unknown/core/pydantic_utilities.py b/seed/fastapi/unknown/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/unknown/core/pydantic_utilities.py +++ b/seed/fastapi/unknown/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/validation/core/pydantic_utilities.py b/seed/fastapi/validation/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/validation/core/pydantic_utilities.py +++ b/seed/fastapi/validation/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/variables/core/pydantic_utilities.py b/seed/fastapi/variables/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/variables/core/pydantic_utilities.py +++ b/seed/fastapi/variables/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/version-no-default/core/pydantic_utilities.py b/seed/fastapi/version-no-default/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/version-no-default/core/pydantic_utilities.py +++ b/seed/fastapi/version-no-default/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/version/core/pydantic_utilities.py b/seed/fastapi/version/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/version/core/pydantic_utilities.py +++ b/seed/fastapi/version/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/websocket/core/pydantic_utilities.py b/seed/fastapi/websocket/core/pydantic_utilities.py index 5a85b5acabc..e5ce0a87860 100644 --- a/seed/fastapi/websocket/core/pydantic_utilities.py +++ b/seed/fastapi/websocket/core/pydantic_utilities.py @@ -106,29 +106,47 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) return convert_and_respect_annotation_metadata( @@ -136,6 +154,19 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py +++ b/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: diff --git a/seed/pydantic/any-auth/src/seed/any_auth/core/pydantic_utilities.py b/seed/pydantic/any-auth/src/seed/any_auth/core/pydantic_utilities.py index 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/any-auth/src/seed/any_auth/core/pydantic_utilities.py +++ b/seed/pydantic/any-auth/src/seed/any_auth/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py +++ b/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py +++ b/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 e2ef134b429..41cc0b621dd 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 @@ -10,6 +10,7 @@ import pydantic from .datetime_utils import serialize_datetime +from .serialization import convert_and_respect_annotation_metadata IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.") @@ -56,11 +57,12 @@ def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: + dealiased_object = convert_and_respect_annotation_metadata(object_=object_, annotation=type_, direction="read") if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 - return adapter.validate_python(object_) + return adapter.validate_python(dealiased_object) else: - return pydantic.parse_obj_as(type_, object_) + return pydantic.parse_obj_as(type_, dealiased_object) def to_jsonable_with_fallback( @@ -75,13 +77,16 @@ def to_jsonable_with_fallback( class UniversalBaseModel(pydantic.BaseModel): - class Config: - populate_by_name = True - smart_union = True - allow_population_by_field_name = True - json_encoders = {dt.datetime: serialize_datetime} - # Allow fields begining with `model_` to be used in the model - protected_namespaces = () + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + protected_namespaces=(), + json_encoders={dt.datetime: serialize_datetime}, + ) # type: ignore # Pydantic v2 + else: + + class Config: + smart_union = True + json_encoders = {dt.datetime: serialize_datetime} def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = { @@ -99,30 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + + +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value + + return destination if IS_PYDANTIC_V2: diff --git a/seed/pydantic/code-samples/src/seed/code_samples/core/serialization.py b/seed/pydantic/code-samples/src/seed/code_samples/core/serialization.py index 36180ac858f..5605f1b6f65 100644 --- a/seed/pydantic/code-samples/src/seed/code_samples/core/serialization.py +++ b/seed/pydantic/code-samples/src/seed/code_samples/core/serialization.py @@ -1,10 +1,13 @@ # This file was auto-generated by Fern from our API Definition. import collections +import inspect import typing import typing_extensions +import pydantic + class FieldMetadata: """ @@ -29,6 +32,7 @@ def convert_and_respect_annotation_metadata( object_: typing.Any, annotation: typing.Any, inner_type: typing.Optional[typing.Any] = None, + direction: typing.Literal["read", "write"], ) -> typing.Any: """ Respect the metadata annotations on a field, such as aliasing. This function effectively @@ -56,44 +60,59 @@ 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): - return _convert_typeddict(object_, clean_type) - + # Pydantic models if ( - # If you're iterating on a string, do not bother to coerce it to a sequence. - (not isinstance(object_, str)) - and ( - ( - ( - typing_extensions.get_origin(clean_type) == typing.List - or typing_extensions.get_origin(clean_type) == list - or clean_type == typing.List + inspect.isclass(clean_type) + and issubclass(clean_type, pydantic.BaseModel) + and isinstance(object_, typing.Mapping) + ): + return _convert_mapping(object_, clean_type, direction) + # TypedDicts + if typing_extensions.is_typeddict(clean_type) and isinstance(object_, typing.Mapping): + return _convert_mapping(object_, clean_type, direction) + + # If you're iterating on a string, do not bother to coerce it to a sequence. + if not isinstance(object_, str): + if ( + typing_extensions.get_origin(clean_type) == typing.Set + or typing_extensions.get_origin(clean_type) == set + or clean_type == typing.Set + ) and isinstance(object_, typing.Set): + inner_type = typing_extensions.get_args(clean_type)[0] + return { + convert_and_respect_annotation_metadata( + object_=item, + annotation=annotation, + inner_type=inner_type, + direction=direction, ) - and isinstance(object_, typing.List) + for item in object_ + } + elif ( + ( + typing_extensions.get_origin(clean_type) == typing.List + or typing_extensions.get_origin(clean_type) == list + or clean_type == typing.List ) - or ( - ( - typing_extensions.get_origin(clean_type) == typing.Set - or typing_extensions.get_origin(clean_type) == set - or clean_type == typing.Set - ) - and isinstance(object_, typing.Set) + and isinstance(object_, typing.List) + ) or ( + ( + typing_extensions.get_origin(clean_type) == typing.Sequence + or typing_extensions.get_origin(clean_type) == collections.abc.Sequence + or clean_type == typing.Sequence ) - or ( - ( - typing_extensions.get_origin(clean_type) == typing.Sequence - or typing_extensions.get_origin(clean_type) == collections.abc.Sequence - or clean_type == typing.Sequence + and isinstance(object_, typing.Sequence) + ): + inner_type = typing_extensions.get_args(clean_type)[0] + return [ + convert_and_respect_annotation_metadata( + object_=item, + annotation=annotation, + inner_type=inner_type, + direction=direction, ) - and isinstance(object_, typing.Sequence) - ) - ) - ): - inner_type = typing_extensions.get_args(clean_type)[0] - return [ - convert_and_respect_annotation_metadata(object_=item, annotation=annotation, inner_type=inner_type) - for item in object_ - ] + for item in object_ + ] if typing_extensions.get_origin(clean_type) == typing.Union: # We should be able to ~relatively~ safely try to convert keys against all @@ -101,7 +120,12 @@ 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, + direction=direction, + ) return object_ annotated_type = _get_annotation(annotation) @@ -113,16 +137,34 @@ 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_mapping( + object_: typing.Mapping[str, object], + expected_type: typing.Any, + direction: typing.Literal["read", "write"], +) -> typing.Mapping[str, object]: converted_object: typing.Dict[str, object] = {} annotations = typing_extensions.get_type_hints(expected_type, include_extras=True) + aliases_to_field_names = _get_alias_to_field_name(annotations) for key, value in object_.items(): - type_ = annotations.get(key) + if direction == "read" and key in aliases_to_field_names: + dealiased_key = aliases_to_field_names.get(key) + if dealiased_key is not None: + type_ = annotations.get(dealiased_key) + else: + type_ = annotations.get(key) + # Note you can't get the annotation by the field name if you're in read mode, so you must check the aliases map + # + # So this is effectively saying if we're in write mode, and we don't have a type, or if we're in read mode and we don't have an alias + # then we can just pass the value through as is if type_ is None: converted_object[key] = value + elif direction == "read" and key not in aliases_to_field_names: + converted_object[key] = convert_and_respect_annotation_metadata( + object_=value, annotation=type_, direction=direction + ) else: - converted_object[_alias_key(key, type_)] = convert_and_respect_annotation_metadata( - object_=value, annotation=type_ + converted_object[_alias_key(key, type_, direction, aliases_to_field_names)] = ( + convert_and_respect_annotation_metadata(object_=value, annotation=type_, direction=direction) ) return converted_object @@ -156,7 +198,39 @@ def _remove_annotations(type_: typing.Any) -> typing.Any: return type_ -def _alias_key(key: str, type_: typing.Any) -> str: +def get_alias_to_field_mapping(type_: typing.Any) -> typing.Dict[str, str]: + annotations = typing_extensions.get_type_hints(type_, include_extras=True) + return _get_alias_to_field_name(annotations) + + +def get_field_to_alias_mapping(type_: typing.Any) -> typing.Dict[str, str]: + annotations = typing_extensions.get_type_hints(type_, include_extras=True) + return _get_field_to_alias_name(annotations) + + +def _get_alias_to_field_name( + field_to_hint: typing.Dict[str, typing.Any], +) -> typing.Dict[str, str]: + aliases = {} + for field, hint in field_to_hint.items(): + maybe_alias = _get_alias_from_type(hint) + if maybe_alias is not None: + aliases[maybe_alias] = field + return aliases + + +def _get_field_to_alias_name( + field_to_hint: typing.Dict[str, typing.Any], +) -> typing.Dict[str, str]: + aliases = {} + for field, hint in field_to_hint.items(): + maybe_alias = _get_alias_from_type(hint) + if maybe_alias is not None: + aliases[field] = maybe_alias + return aliases + + +def _get_alias_from_type(type_: typing.Any) -> typing.Optional[str]: maybe_annotated_type = _get_annotation(type_) if maybe_annotated_type is not None: @@ -166,5 +240,15 @@ def _alias_key(key: str, type_: typing.Any) -> str: for annotation in annotations: if isinstance(annotation, FieldMetadata) and annotation.alias is not None: return annotation.alias + return None + - return key +def _alias_key( + key: str, + type_: typing.Any, + direction: typing.Literal["read", "write"], + aliases_to_field_names: typing.Dict[str, str], +) -> str: + if direction == "read": + return aliases_to_field_names.get(key, key) + return _get_alias_from_type(type_=type_) or key diff --git a/seed/pydantic/cross-package-type-names/src/seed/cross_package_type_names/core/pydantic_utilities.py b/seed/pydantic/cross-package-type-names/src/seed/cross_package_type_names/core/pydantic_utilities.py index 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/cross-package-type-names/src/seed/cross_package_type_names/core/pydantic_utilities.py +++ b/seed/pydantic/cross-package-type-names/src/seed/cross_package_type_names/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py +++ b/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py +++ b/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py +++ b/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: diff --git a/seed/pydantic/grpc-proto-exhaustive/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/grpc-proto-exhaustive/src/seed/api/core/pydantic_utilities.py index 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/grpc-proto-exhaustive/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/grpc-proto-exhaustive/src/seed/api/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py +++ b/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py +++ b/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py +++ b/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py +++ b/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py +++ b/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py +++ b/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py +++ b/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py +++ b/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py +++ b/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py +++ b/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: diff --git a/seed/python-sdk/any-auth/src/seed/core/pydantic_utilities.py b/seed/python-sdk/any-auth/src/seed/core/pydantic_utilities.py index 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/any-auth/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/any-auth/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 e2ef134b429..41cc0b621dd 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 @@ -10,6 +10,7 @@ import pydantic from .datetime_utils import serialize_datetime +from .serialization import convert_and_respect_annotation_metadata IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.") @@ -56,11 +57,12 @@ def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: + dealiased_object = convert_and_respect_annotation_metadata(object_=object_, annotation=type_, direction="read") if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 - return adapter.validate_python(object_) + return adapter.validate_python(dealiased_object) else: - return pydantic.parse_obj_as(type_, object_) + return pydantic.parse_obj_as(type_, dealiased_object) def to_jsonable_with_fallback( @@ -75,13 +77,16 @@ def to_jsonable_with_fallback( class UniversalBaseModel(pydantic.BaseModel): - class Config: - populate_by_name = True - smart_union = True - allow_population_by_field_name = True - json_encoders = {dt.datetime: serialize_datetime} - # Allow fields begining with `model_` to be used in the model - protected_namespaces = () + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict( + protected_namespaces=(), + json_encoders={dt.datetime: serialize_datetime}, + ) # type: ignore # Pydantic v2 + else: + + class Config: + smart_union = True + json_encoders = {dt.datetime: serialize_datetime} def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = { @@ -99,30 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - return super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } + + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + + +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - return super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value + + return destination if IS_PYDANTIC_V2: diff --git a/seed/python-sdk/code-samples/src/seed/core/serialization.py b/seed/python-sdk/code-samples/src/seed/core/serialization.py index 36180ac858f..5605f1b6f65 100644 --- a/seed/python-sdk/code-samples/src/seed/core/serialization.py +++ b/seed/python-sdk/code-samples/src/seed/core/serialization.py @@ -1,10 +1,13 @@ # This file was auto-generated by Fern from our API Definition. import collections +import inspect import typing import typing_extensions +import pydantic + class FieldMetadata: """ @@ -29,6 +32,7 @@ def convert_and_respect_annotation_metadata( object_: typing.Any, annotation: typing.Any, inner_type: typing.Optional[typing.Any] = None, + direction: typing.Literal["read", "write"], ) -> typing.Any: """ Respect the metadata annotations on a field, such as aliasing. This function effectively @@ -56,44 +60,59 @@ 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): - return _convert_typeddict(object_, clean_type) - + # Pydantic models if ( - # If you're iterating on a string, do not bother to coerce it to a sequence. - (not isinstance(object_, str)) - and ( - ( - ( - typing_extensions.get_origin(clean_type) == typing.List - or typing_extensions.get_origin(clean_type) == list - or clean_type == typing.List + inspect.isclass(clean_type) + and issubclass(clean_type, pydantic.BaseModel) + and isinstance(object_, typing.Mapping) + ): + return _convert_mapping(object_, clean_type, direction) + # TypedDicts + if typing_extensions.is_typeddict(clean_type) and isinstance(object_, typing.Mapping): + return _convert_mapping(object_, clean_type, direction) + + # If you're iterating on a string, do not bother to coerce it to a sequence. + if not isinstance(object_, str): + if ( + typing_extensions.get_origin(clean_type) == typing.Set + or typing_extensions.get_origin(clean_type) == set + or clean_type == typing.Set + ) and isinstance(object_, typing.Set): + inner_type = typing_extensions.get_args(clean_type)[0] + return { + convert_and_respect_annotation_metadata( + object_=item, + annotation=annotation, + inner_type=inner_type, + direction=direction, ) - and isinstance(object_, typing.List) + for item in object_ + } + elif ( + ( + typing_extensions.get_origin(clean_type) == typing.List + or typing_extensions.get_origin(clean_type) == list + or clean_type == typing.List ) - or ( - ( - typing_extensions.get_origin(clean_type) == typing.Set - or typing_extensions.get_origin(clean_type) == set - or clean_type == typing.Set - ) - and isinstance(object_, typing.Set) + and isinstance(object_, typing.List) + ) or ( + ( + typing_extensions.get_origin(clean_type) == typing.Sequence + or typing_extensions.get_origin(clean_type) == collections.abc.Sequence + or clean_type == typing.Sequence ) - or ( - ( - typing_extensions.get_origin(clean_type) == typing.Sequence - or typing_extensions.get_origin(clean_type) == collections.abc.Sequence - or clean_type == typing.Sequence + and isinstance(object_, typing.Sequence) + ): + inner_type = typing_extensions.get_args(clean_type)[0] + return [ + convert_and_respect_annotation_metadata( + object_=item, + annotation=annotation, + inner_type=inner_type, + direction=direction, ) - and isinstance(object_, typing.Sequence) - ) - ) - ): - inner_type = typing_extensions.get_args(clean_type)[0] - return [ - convert_and_respect_annotation_metadata(object_=item, annotation=annotation, inner_type=inner_type) - for item in object_ - ] + for item in object_ + ] if typing_extensions.get_origin(clean_type) == typing.Union: # We should be able to ~relatively~ safely try to convert keys against all @@ -101,7 +120,12 @@ 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, + direction=direction, + ) return object_ annotated_type = _get_annotation(annotation) @@ -113,16 +137,34 @@ 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_mapping( + object_: typing.Mapping[str, object], + expected_type: typing.Any, + direction: typing.Literal["read", "write"], +) -> typing.Mapping[str, object]: converted_object: typing.Dict[str, object] = {} annotations = typing_extensions.get_type_hints(expected_type, include_extras=True) + aliases_to_field_names = _get_alias_to_field_name(annotations) for key, value in object_.items(): - type_ = annotations.get(key) + if direction == "read" and key in aliases_to_field_names: + dealiased_key = aliases_to_field_names.get(key) + if dealiased_key is not None: + type_ = annotations.get(dealiased_key) + else: + type_ = annotations.get(key) + # Note you can't get the annotation by the field name if you're in read mode, so you must check the aliases map + # + # So this is effectively saying if we're in write mode, and we don't have a type, or if we're in read mode and we don't have an alias + # then we can just pass the value through as is if type_ is None: converted_object[key] = value + elif direction == "read" and key not in aliases_to_field_names: + converted_object[key] = convert_and_respect_annotation_metadata( + object_=value, annotation=type_, direction=direction + ) else: - converted_object[_alias_key(key, type_)] = convert_and_respect_annotation_metadata( - object_=value, annotation=type_ + converted_object[_alias_key(key, type_, direction, aliases_to_field_names)] = ( + convert_and_respect_annotation_metadata(object_=value, annotation=type_, direction=direction) ) return converted_object @@ -156,7 +198,39 @@ def _remove_annotations(type_: typing.Any) -> typing.Any: return type_ -def _alias_key(key: str, type_: typing.Any) -> str: +def get_alias_to_field_mapping(type_: typing.Any) -> typing.Dict[str, str]: + annotations = typing_extensions.get_type_hints(type_, include_extras=True) + return _get_alias_to_field_name(annotations) + + +def get_field_to_alias_mapping(type_: typing.Any) -> typing.Dict[str, str]: + annotations = typing_extensions.get_type_hints(type_, include_extras=True) + return _get_field_to_alias_name(annotations) + + +def _get_alias_to_field_name( + field_to_hint: typing.Dict[str, typing.Any], +) -> typing.Dict[str, str]: + aliases = {} + for field, hint in field_to_hint.items(): + maybe_alias = _get_alias_from_type(hint) + if maybe_alias is not None: + aliases[maybe_alias] = field + return aliases + + +def _get_field_to_alias_name( + field_to_hint: typing.Dict[str, typing.Any], +) -> typing.Dict[str, str]: + aliases = {} + for field, hint in field_to_hint.items(): + maybe_alias = _get_alias_from_type(hint) + if maybe_alias is not None: + aliases[field] = maybe_alias + return aliases + + +def _get_alias_from_type(type_: typing.Any) -> typing.Optional[str]: maybe_annotated_type = _get_annotation(type_) if maybe_annotated_type is not None: @@ -166,5 +240,15 @@ def _alias_key(key: str, type_: typing.Any) -> str: for annotation in annotations: if isinstance(annotation, FieldMetadata) and annotation.alias is not None: return annotation.alias + return None + - return key +def _alias_key( + key: str, + type_: typing.Any, + direction: typing.Literal["read", "write"], + aliases_to_field_names: typing.Dict[str, str], +) -> str: + if direction == "read": + return aliases_to_field_names.get(key, key) + return _get_alias_from_type(type_=type_) or key diff --git a/seed/python-sdk/code-samples/tests/utils/test_serialization.py b/seed/python-sdk/code-samples/tests/utils/test_serialization.py index ca93a724b58..dd74836366c 100644 --- a/seed/python-sdk/code-samples/tests/utils/test_serialization.py +++ b/seed/python-sdk/code-samples/tests/utils/test_serialization.py @@ -18,7 +18,9 @@ def test_convert_and_respect_annotation_metadata() -> None: "literal": "lit_one", "any": "any", } - converted = convert_and_respect_annotation_metadata(object_=data, annotation=ObjectWithOptionalFieldParams) + converted = convert_and_respect_annotation_metadata( + object_=data, annotation=ObjectWithOptionalFieldParams, direction="write" + ) assert converted == {"string": "string", "long": 12345, "bool": True, "literal": "lit_one", "any": "any"} @@ -27,7 +29,9 @@ def test_convert_and_respect_annotation_metadata_in_list() -> None: {"string": "string", "long_": 12345, "bool_": True, "literal": "lit_one", "any": "any"}, {"string": "another string", "long_": 67890, "list_": [], "literal": "lit_one", "any": "any"}, ] - converted = convert_and_respect_annotation_metadata(object_=data, annotation=List[ObjectWithOptionalFieldParams]) + converted = convert_and_respect_annotation_metadata( + object_=data, annotation=List[ObjectWithOptionalFieldParams], direction="write" + ) assert converted == [ {"string": "string", "long": 12345, "bool": True, "literal": "lit_one", "any": "any"}, @@ -43,7 +47,9 @@ def test_convert_and_respect_annotation_metadata_in_nested_object() -> None: "literal": "lit_one", "any": "any", } - converted = convert_and_respect_annotation_metadata(object_=data, annotation=ObjectWithOptionalFieldParams) + converted = convert_and_respect_annotation_metadata( + object_=data, annotation=ObjectWithOptionalFieldParams, direction="write" + ) assert converted == { "string": "string", @@ -55,12 +61,12 @@ def test_convert_and_respect_annotation_metadata_in_nested_object() -> None: def test_convert_and_respect_annotation_metadata_in_union() -> None: - converted = convert_and_respect_annotation_metadata(object_=UNION_TEST, annotation=ShapeParams) + converted = convert_and_respect_annotation_metadata(object_=UNION_TEST, annotation=ShapeParams, direction="write") assert converted == UNION_TEST_CONVERTED def test_convert_and_respect_annotation_metadata_with_empty_object() -> None: data: Any = {} - converted = convert_and_respect_annotation_metadata(object_=data, annotation=ShapeParams) + converted = convert_and_respect_annotation_metadata(object_=data, annotation=ShapeParams, direction="write") assert converted == data diff --git a/seed/python-sdk/cross-package-type-names/src/seed/core/pydantic_utilities.py b/seed/python-sdk/cross-package-type-names/src/seed/core/pydantic_utilities.py index 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/cross-package-type-names/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/cross-package-type-names/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: diff --git a/seed/python-sdk/grpc-proto-exhaustive/src/seed/core/pydantic_utilities.py b/seed/python-sdk/grpc-proto-exhaustive/src/seed/core/pydantic_utilities.py index 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/grpc-proto-exhaustive/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/grpc-proto-exhaustive/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/object/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/object/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 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 @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/version/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/version/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: 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 0bc76873e0a..41cc0b621dd 100644 --- a/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py @@ -104,32 +104,63 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default values. """ - _fields_set = self.__fields_set__ + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. + if IS_PYDANTIC_V2: + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: + _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, + } - fields = _get_model_fields(self.__class__) - for name, field in fields.items(): - if name not in _fields_set: - default = _get_field_default(field) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) - # If the default values are non-null act like they've been set - # This effectively allows exclude_unset to work like exclude_none where - # the latter passes through intentionally set none values. - if default != None: - _fields_set.add(name) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") - kwargs_with_defaults_exclude_unset: typing.Any = { - "by_alias": True, - "exclude_unset": True, - "include": _fields_set, - **kwargs, - } - if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + destination[key] = value - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return destination if IS_PYDANTIC_V2: diff --git a/test-definitions/fern/apis/literal/definition/inlined.yml b/test-definitions/fern/apis/literal/definition/inlined.yml index 33fda38a6d8..4bf030a9259 100644 --- a/test-definitions/fern/apis/literal/definition/inlined.yml +++ b/test-definitions/fern/apis/literal/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + nestedLiteral: ATopLevelLiteral response: root.SendResponse examples: From 937695e9fb0e0fe15185b1412f7f5a91582081f1 Mon Sep 17 00:00:00 2001 From: armandobelardo Date: Thu, 5 Sep 2024 09:55:02 -0400 Subject: [PATCH 2/8] update version --- generators/python/sdk/versions.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/generators/python/sdk/versions.yml b/generators/python/sdk/versions.yml index 0ea0d451007..4e4dba971ea 100644 --- a/generators/python/sdk/versions.yml +++ b/generators/python/sdk/versions.yml @@ -10,6 +10,8 @@ This is fix a regression where nested literals were being omitted due to the Pydantic V2 serializers not respecting the recursive .dict logic, as Pydantic V2 shells out `model_dump` calls to Rust library and serializers, as opposed to recursively calling `model_dump`. + It is expected that performance will not be degraded given the Rust-based serializers have optimized performance, compared to the Pydantic V1 .dict approach. + - version: 3.11.0-rc0 ir_version: 53 changelog_entry: From 034a0783d9f719eee47ab8dabfd0399526c49cfd Mon Sep 17 00:00:00 2001 From: armandobelardo Date: Thu, 5 Sep 2024 11:33:42 -0400 Subject: [PATCH 3/8] update seed --- .../fastapi/pydantic_utilities.py | 4 +- .../pydantic/pydantic_utilities.py | 4 +- .../core_utilities/sdk/pydantic_utilities.py | 4 +- pnpm-lock.yaml | 4 + .../literal/.mock/definition/inlined.yml | 12 ++ .../src/SeedLiteral/Inlined/ANestedLiteral.cs | 17 ++ .../SeedLiteral/Inlined/ATopLevelLiteral.cs | 17 ++ .../literal/.mock/definition/inlined.yml | 12 ++ seed/csharp-sdk/literal/reference.md | 4 + seed/csharp-sdk/literal/snippet.json | 2 +- .../src/SeedLiteral/Inlined/InlinedClient.cs | 4 + .../Requests/SendLiteralsInlinedRequest.cs | 3 + .../Inlined/Types/ANestedLiteral.cs | 17 ++ .../Inlined/Types/ATopLevelLiteral.cs | 17 ++ .../alias-extends/core/pydantic_utilities.py | 6 +- seed/fastapi/alias/core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../audiences/core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../basic-auth/core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../code-samples/core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../custom-auth/core/pydantic_utilities.py | 6 +- .../error-property/core/pydantic_utilities.py | 6 +- .../examples/core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../pydantic-v1/core/pydantic_utilities.py | 6 +- .../pydantic-v2/core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../extends/core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../folders/core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../grpc-proto/core/pydantic_utilities.py | 6 +- seed/fastapi/grpc/core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../async-handlers/core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../mixed-case/core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../no-environment/core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../fastapi/object/core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../optional/core/pydantic_utilities.py | 6 +- .../package-yml/core/pydantic_utilities.py | 6 +- .../pagination/core/pydantic_utilities.py | 6 +- .../plain-text/core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../simple-fhir/core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- seed/fastapi/trace/core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../fastapi/unions/core/pydantic_utilities.py | 6 +- .../unknown/core/pydantic_utilities.py | 6 +- .../validation/core/pydantic_utilities.py | 6 +- .../variables/core/pydantic_utilities.py | 6 +- .../core/pydantic_utilities.py | 6 +- .../version/core/pydantic_utilities.py | 6 +- .../websocket/core/pydantic_utilities.py | 6 +- .../literal/.mock/definition/inlined.yml | 12 ++ seed/go-fiber/literal/inlined.go | 51 +++++- seed/go-fiber/literal/types.go | 59 +++++++ .../literal/.mock/definition/inlined.yml | 12 ++ seed/go-model/literal/inlined.go | 40 +++++ seed/go-model/literal/types.go | 59 +++++++ .../literal/.mock/definition/inlined.yml | 12 ++ seed/go-sdk/literal/inlined.go | 58 ++++++- seed/go-sdk/literal/types.go | 66 ++++++++ .../literal/.mock/definition/inlined.yml | 12 ++ .../literal/model/inlined/ANestedLiteral.java | 49 ++++++ .../model/inlined/ATopLevelLiteral.java | 86 ++++++++++ .../literal/.mock/definition/inlined.yml | 12 ++ .../requests/SendLiteralsInlinedRequest.java | 43 ++++- .../inlined/types/ANestedLiteral.java | 65 +++++++ .../inlined/types/ATopLevelLiteral.java | 101 +++++++++++ .../literal/.mock/definition/inlined.yml | 12 ++ .../requests/SendLiteralsInlinedRequest.java | 37 +++- .../inlined/types/ANestedLiteral.java | 58 +++++++ .../inlined/types/ATopLevelLiteral.java | 94 +++++++++++ .../literal/.mock/definition/inlined.yml | 12 ++ seed/openapi/literal/openapi.yml | 24 +++ .../literal/.mock/definition/inlined.yml | 12 ++ seed/postman/literal/collection.json | 6 +- .../alias_extends/core/pydantic_utilities.py | 4 +- .../src/seed/alias/core/pydantic_utilities.py | 4 +- .../seed/any_auth/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 +- .../code_samples/core/pydantic_utilities.py | 4 +- .../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 +- .../src/seed/api/core/pydantic_utilities.py | 4 +- .../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 +- .../literal/.mock/definition/inlined.yml | 12 ++ .../literal/src/seed/literal/__init__.py | 21 ++- .../seed/literal/core/pydantic_utilities.py | 4 +- .../src/seed/literal/resources/__init__.py | 12 +- .../literal/resources/inlined/__init__.py | 4 +- .../resources/inlined/a_nested_literal.py | 21 +++ .../resources/inlined/a_top_level_literal.py | 20 +++ .../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 +- .../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 +- .../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/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 +- .../grpc/src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../imdb/src/seed/core/pydantic_utilities.py | 4 +- .../.mock/definition/inlined.yml | 12 ++ .../literal/no-custom-config/reference.md | 12 ++ .../no-custom-config/snippet-templates.json | 54 ++++++ .../literal/no-custom-config/snippet.json | 4 +- .../no-custom-config/src/seed/__init__.py | 4 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/inlined/__init__.py | 4 +- .../src/seed/inlined/client.py | 22 +++ .../src/seed/inlined/types/__init__.py | 4 +- .../seed/inlined/types/a_nested_literal.py | 23 +++ .../seed/inlined/types/a_top_level_literal.py | 22 +++ .../no-custom-config/tests/test_inlined.py | 4 + .../.mock/definition/inlined.yml | 12 ++ .../use_typeddict_requests/reference.md | 9 + .../snippet-templates.json | 46 +++++ .../use_typeddict_requests/snippet.json | 4 +- .../src/seed/__init__.py | 6 +- .../src/seed/core/pydantic_utilities.py | 4 +- .../src/seed/inlined/__init__.py | 5 +- .../src/seed/inlined/client.py | 18 ++ .../src/seed/inlined/requests/__init__.py | 6 + .../seed/inlined/requests/a_nested_literal.py | 10 ++ .../inlined/requests/a_top_level_literal.py | 10 ++ .../src/seed/inlined/types/__init__.py | 4 +- .../seed/inlined/types/a_nested_literal.py | 23 +++ .../seed/inlined/types/a_top_level_literal.py | 22 +++ .../tests/test_inlined.py | 2 + .../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 +- .../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 +- .../literal/.mock/definition/inlined.yml | 12 ++ .../literal/lib/seed_literal_client.rb | 2 + .../inlined/types/a_nested_literal.rb | 57 +++++++ .../inlined/types/a_top_level_literal.rb | 63 +++++++ .../literal/.mock/definition/inlined.yml | 12 ++ seed/ruby-sdk/literal/fern_literal.gemspec | 4 - seed/ruby-sdk/literal/lib/fern_literal.rb | 83 +-------- .../lib/fern_literal/headers/client.rb | 99 ----------- .../lib/fern_literal/inlined/client.rb | 130 -------------- .../inlined/types/a_nested_literal.rb | 57 +++++++ .../inlined/types/a_top_level_literal.rb | 63 +++++++ .../literal/lib/fern_literal/path/client.rb | 97 ----------- .../literal/lib/fern_literal/query/client.rb | 105 ------------ .../lib/fern_literal/reference/client.rb | 106 ------------ seed/ruby-sdk/literal/lib/requests.rb | 158 ------------------ seed/ruby-sdk/literal/lib/types_export.rb | 6 - seed/ruby-sdk/literal/snippet.json | 115 ------------- .../literal/.mock/definition/inlined.yml | 12 ++ .../requests/SendLiteralsInlinedRequest.ts | 1 + .../resources/inlined/types/ANestedLiteral.ts | 7 + .../inlined/types/ATopLevelLiteral.ts | 9 + .../api/resources/inlined/types/index.ts | 2 + .../requests/SendLiteralsInlinedRequest.ts | 2 + .../resources/inlined/types/ANestedLiteral.ts | 20 +++ .../inlined/types/ATopLevelLiteral.ts | 20 +++ .../resources/inlined/types/index.ts | 2 + .../literal/.mock/definition/inlined.yml | 12 ++ seed/ts-sdk/literal/reference.md | 5 + seed/ts-sdk/literal/snippet-templates.json | 23 +++ seed/ts-sdk/literal/snippet.json | 2 +- .../api/resources/inlined/client/Client.ts | 5 + .../requests/SendLiteralsInlinedRequest.ts | 6 + .../resources/inlined/types/ANestedLiteral.ts | 7 + .../inlined/types/ATopLevelLiteral.ts | 9 + .../src/api/resources/inlined/types/index.ts | 2 + .../requests/SendLiteralsInlinedRequest.ts | 3 + .../resources/inlined/types/ANestedLiteral.ts | 20 +++ .../inlined/types/ATopLevelLiteral.ts | 21 +++ .../resources/inlined/types/index.ts | 2 + .../fern/apis/literal/definition/inlined.yml | 5 +- 315 files changed, 2486 insertions(+), 1365 deletions(-) create mode 100644 seed/csharp-model/literal/src/SeedLiteral/Inlined/ANestedLiteral.cs create mode 100644 seed/csharp-model/literal/src/SeedLiteral/Inlined/ATopLevelLiteral.cs create mode 100644 seed/csharp-sdk/literal/src/SeedLiteral/Inlined/Types/ANestedLiteral.cs create mode 100644 seed/csharp-sdk/literal/src/SeedLiteral/Inlined/Types/ATopLevelLiteral.cs create mode 100644 seed/java-model/literal/src/main/java/com/seed/literal/model/inlined/ANestedLiteral.java create mode 100644 seed/java-model/literal/src/main/java/com/seed/literal/model/inlined/ATopLevelLiteral.java create mode 100644 seed/java-sdk/literal/src/main/java/com/seed/literal/resources/inlined/types/ANestedLiteral.java create mode 100644 seed/java-sdk/literal/src/main/java/com/seed/literal/resources/inlined/types/ATopLevelLiteral.java create mode 100644 seed/java-spring/literal/resources/inlined/types/ANestedLiteral.java create mode 100644 seed/java-spring/literal/resources/inlined/types/ATopLevelLiteral.java create mode 100644 seed/pydantic/literal/src/seed/literal/resources/inlined/a_nested_literal.py create mode 100644 seed/pydantic/literal/src/seed/literal/resources/inlined/a_top_level_literal.py create mode 100644 seed/python-sdk/literal/no-custom-config/src/seed/inlined/types/a_nested_literal.py create mode 100644 seed/python-sdk/literal/no-custom-config/src/seed/inlined/types/a_top_level_literal.py create mode 100644 seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/requests/__init__.py create mode 100644 seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/requests/a_nested_literal.py create mode 100644 seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/requests/a_top_level_literal.py create mode 100644 seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/types/a_nested_literal.py create mode 100644 seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/types/a_top_level_literal.py create mode 100644 seed/ruby-model/literal/lib/seed_literal_client/inlined/types/a_nested_literal.rb create mode 100644 seed/ruby-model/literal/lib/seed_literal_client/inlined/types/a_top_level_literal.rb delete mode 100644 seed/ruby-sdk/literal/lib/fern_literal/headers/client.rb delete mode 100644 seed/ruby-sdk/literal/lib/fern_literal/inlined/client.rb create mode 100644 seed/ruby-sdk/literal/lib/fern_literal/inlined/types/a_nested_literal.rb create mode 100644 seed/ruby-sdk/literal/lib/fern_literal/inlined/types/a_top_level_literal.rb delete mode 100644 seed/ruby-sdk/literal/lib/fern_literal/path/client.rb delete mode 100644 seed/ruby-sdk/literal/lib/fern_literal/query/client.rb delete mode 100644 seed/ruby-sdk/literal/lib/fern_literal/reference/client.rb delete mode 100644 seed/ruby-sdk/literal/lib/requests.rb delete mode 100644 seed/ruby-sdk/literal/lib/types_export.rb create mode 100644 seed/ts-express/literal/api/resources/inlined/types/ANestedLiteral.ts create mode 100644 seed/ts-express/literal/api/resources/inlined/types/ATopLevelLiteral.ts create mode 100644 seed/ts-express/literal/serialization/resources/inlined/types/ANestedLiteral.ts create mode 100644 seed/ts-express/literal/serialization/resources/inlined/types/ATopLevelLiteral.ts create mode 100644 seed/ts-sdk/literal/src/api/resources/inlined/types/ANestedLiteral.ts create mode 100644 seed/ts-sdk/literal/src/api/resources/inlined/types/ATopLevelLiteral.ts create mode 100644 seed/ts-sdk/literal/src/serialization/resources/inlined/types/ANestedLiteral.ts create mode 100644 seed/ts-sdk/literal/src/serialization/resources/inlined/types/ATopLevelLiteral.ts diff --git a/generators/python/core_utilities/fastapi/pydantic_utilities.py b/generators/python/core_utilities/fastapi/pydantic_utilities.py index e42d554581e..4bdabe86ba8 100644 --- a/generators/python/core_utilities/fastapi/pydantic_utilities.py +++ b/generators/python/core_utilities/fastapi/pydantic_utilities.py @@ -136,14 +136,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") diff --git a/generators/python/core_utilities/pydantic/pydantic_utilities.py b/generators/python/core_utilities/pydantic/pydantic_utilities.py index e42d554581e..4bdabe86ba8 100644 --- a/generators/python/core_utilities/pydantic/pydantic_utilities.py +++ b/generators/python/core_utilities/pydantic/pydantic_utilities.py @@ -136,14 +136,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") diff --git a/generators/python/core_utilities/sdk/pydantic_utilities.py b/generators/python/core_utilities/sdk/pydantic_utilities.py index e42d554581e..4bdabe86ba8 100644 --- a/generators/python/core_utilities/sdk/pydantic_utilities.py +++ b/generators/python/core_utilities/sdk/pydantic_utilities.py @@ -136,14 +136,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 79fce47f59b..c49be95013e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3102,6 +3102,10 @@ importers: 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/dev: {} + + packages/cli/cli/dist/prod: {} + packages/cli/configuration: dependencies: '@fern-api/core-utils': diff --git a/seed/csharp-model/literal/.mock/definition/inlined.yml b/seed/csharp-model/literal/.mock/definition/inlined.yml index 33fda38a6d8..c2834c5c50c 100644 --- a/seed/csharp-model/literal/.mock/definition/inlined.yml +++ b/seed/csharp-model/literal/.mock/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -32,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: diff --git a/seed/csharp-model/literal/src/SeedLiteral/Inlined/ANestedLiteral.cs b/seed/csharp-model/literal/src/SeedLiteral/Inlined/ANestedLiteral.cs new file mode 100644 index 00000000000..c57cc4daa06 --- /dev/null +++ b/seed/csharp-model/literal/src/SeedLiteral/Inlined/ANestedLiteral.cs @@ -0,0 +1,17 @@ +using System.Text.Json.Serialization; +using SeedLiteral.Core; + +#nullable enable + +namespace SeedLiteral; + +public record ANestedLiteral +{ + [JsonPropertyName("myLiteral")] + public required string MyLiteral { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/seed/csharp-model/literal/src/SeedLiteral/Inlined/ATopLevelLiteral.cs b/seed/csharp-model/literal/src/SeedLiteral/Inlined/ATopLevelLiteral.cs new file mode 100644 index 00000000000..8076cba7c70 --- /dev/null +++ b/seed/csharp-model/literal/src/SeedLiteral/Inlined/ATopLevelLiteral.cs @@ -0,0 +1,17 @@ +using System.Text.Json.Serialization; +using SeedLiteral.Core; + +#nullable enable + +namespace SeedLiteral; + +public record ATopLevelLiteral +{ + [JsonPropertyName("nestedLiteral")] + public required ANestedLiteral NestedLiteral { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/seed/csharp-sdk/literal/.mock/definition/inlined.yml b/seed/csharp-sdk/literal/.mock/definition/inlined.yml index 33fda38a6d8..c2834c5c50c 100644 --- a/seed/csharp-sdk/literal/.mock/definition/inlined.yml +++ b/seed/csharp-sdk/literal/.mock/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -32,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: diff --git a/seed/csharp-sdk/literal/reference.md b/seed/csharp-sdk/literal/reference.md index 48259f4fa21..930aa99a6c6 100644 --- a/seed/csharp-sdk/literal/reference.md +++ b/seed/csharp-sdk/literal/reference.md @@ -69,6 +69,10 @@ await client.Inlined.SendAsync( Context = "You're super wise", AliasedContext = "You're super wise", MaybeContext = "You're super wise", + ObjectWithLiteral = new ATopLevelLiteral + { + NestedLiteral = new ANestedLiteral { MyLiteral = "How super cool" }, + }, Stream = false, Query = "What is the weather today", } diff --git a/seed/csharp-sdk/literal/snippet.json b/seed/csharp-sdk/literal/snippet.json index 0b92e22a3c8..4828cf0e04b 100644 --- a/seed/csharp-sdk/literal/snippet.json +++ b/seed/csharp-sdk/literal/snippet.json @@ -22,7 +22,7 @@ }, "snippet": { "type": "typescript", - "client": "using SeedLiteral;\n\nvar client = new SeedLiteralClient();\nawait client.Inlined.SendAsync(\n new SendLiteralsInlinedRequest\n {\n Temperature = 10.1,\n Prompt = \"You are a helpful assistant\",\n Context = \"You're super wise\",\n AliasedContext = \"You're super wise\",\n MaybeContext = \"You're super wise\",\n Stream = false,\n Query = \"What is the weather today\",\n }\n);\n" + "client": "using SeedLiteral;\n\nvar client = new SeedLiteralClient();\nawait client.Inlined.SendAsync(\n new SendLiteralsInlinedRequest\n {\n Temperature = 10.1,\n Prompt = \"You are a helpful assistant\",\n Context = \"You're super wise\",\n AliasedContext = \"You're super wise\",\n MaybeContext = \"You're super wise\",\n ObjectWithLiteral = new ATopLevelLiteral\n {\n NestedLiteral = new ANestedLiteral { MyLiteral = \"How super cool\" },\n },\n Stream = false,\n Query = \"What is the weather today\",\n }\n);\n" } }, { diff --git a/seed/csharp-sdk/literal/src/SeedLiteral/Inlined/InlinedClient.cs b/seed/csharp-sdk/literal/src/SeedLiteral/Inlined/InlinedClient.cs index 5d9730d2252..76cd3e30498 100644 --- a/seed/csharp-sdk/literal/src/SeedLiteral/Inlined/InlinedClient.cs +++ b/seed/csharp-sdk/literal/src/SeedLiteral/Inlined/InlinedClient.cs @@ -26,6 +26,10 @@ internal InlinedClient(RawClient client) /// Context = "You're super wise", /// AliasedContext = "You're super wise", /// MaybeContext = "You're super wise", + /// ObjectWithLiteral = new ATopLevelLiteral + /// { + /// NestedLiteral = new ANestedLiteral { MyLiteral = "How super cool" }, + /// }, /// Stream = false, /// Query = "What is the weather today", /// } diff --git a/seed/csharp-sdk/literal/src/SeedLiteral/Inlined/Requests/SendLiteralsInlinedRequest.cs b/seed/csharp-sdk/literal/src/SeedLiteral/Inlined/Requests/SendLiteralsInlinedRequest.cs index 897458198f4..2067000d071 100644 --- a/seed/csharp-sdk/literal/src/SeedLiteral/Inlined/Requests/SendLiteralsInlinedRequest.cs +++ b/seed/csharp-sdk/literal/src/SeedLiteral/Inlined/Requests/SendLiteralsInlinedRequest.cs @@ -28,6 +28,9 @@ public record SendLiteralsInlinedRequest [JsonPropertyName("maybeContext")] public string? MaybeContext { get; set; } + [JsonPropertyName("objectWithLiteral")] + public required ATopLevelLiteral ObjectWithLiteral { get; set; } + public override string ToString() { return JsonUtils.Serialize(this); diff --git a/seed/csharp-sdk/literal/src/SeedLiteral/Inlined/Types/ANestedLiteral.cs b/seed/csharp-sdk/literal/src/SeedLiteral/Inlined/Types/ANestedLiteral.cs new file mode 100644 index 00000000000..c57cc4daa06 --- /dev/null +++ b/seed/csharp-sdk/literal/src/SeedLiteral/Inlined/Types/ANestedLiteral.cs @@ -0,0 +1,17 @@ +using System.Text.Json.Serialization; +using SeedLiteral.Core; + +#nullable enable + +namespace SeedLiteral; + +public record ANestedLiteral +{ + [JsonPropertyName("myLiteral")] + public required string MyLiteral { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/seed/csharp-sdk/literal/src/SeedLiteral/Inlined/Types/ATopLevelLiteral.cs b/seed/csharp-sdk/literal/src/SeedLiteral/Inlined/Types/ATopLevelLiteral.cs new file mode 100644 index 00000000000..8076cba7c70 --- /dev/null +++ b/seed/csharp-sdk/literal/src/SeedLiteral/Inlined/Types/ATopLevelLiteral.cs @@ -0,0 +1,17 @@ +using System.Text.Json.Serialization; +using SeedLiteral.Core; + +#nullable enable + +namespace SeedLiteral; + +public record ATopLevelLiteral +{ + [JsonPropertyName("nestedLiteral")] + public required ANestedLiteral NestedLiteral { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/seed/fastapi/alias-extends/core/pydantic_utilities.py b/seed/fastapi/alias-extends/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/alias-extends/core/pydantic_utilities.py +++ b/seed/fastapi/alias-extends/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/alias/core/pydantic_utilities.py b/seed/fastapi/alias/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/alias/core/pydantic_utilities.py +++ b/seed/fastapi/alias/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" 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 e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py +++ b/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/audiences/core/pydantic_utilities.py b/seed/fastapi/audiences/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/audiences/core/pydantic_utilities.py +++ b/seed/fastapi/audiences/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py b/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" 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 e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/basic-auth/core/pydantic_utilities.py b/seed/fastapi/basic-auth/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/basic-auth/core/pydantic_utilities.py +++ b/seed/fastapi/basic-auth/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" 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 e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py +++ b/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py b/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py +++ b/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/circular-references/core/pydantic_utilities.py b/seed/fastapi/circular-references/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/circular-references/core/pydantic_utilities.py +++ b/seed/fastapi/circular-references/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/code-samples/core/pydantic_utilities.py b/seed/fastapi/code-samples/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/code-samples/core/pydantic_utilities.py +++ b/seed/fastapi/code-samples/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/cross-package-type-names/core/pydantic_utilities.py b/seed/fastapi/cross-package-type-names/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/cross-package-type-names/core/pydantic_utilities.py +++ b/seed/fastapi/cross-package-type-names/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/custom-auth/core/pydantic_utilities.py b/seed/fastapi/custom-auth/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/custom-auth/core/pydantic_utilities.py +++ b/seed/fastapi/custom-auth/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/error-property/core/pydantic_utilities.py b/seed/fastapi/error-property/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/error-property/core/pydantic_utilities.py +++ b/seed/fastapi/error-property/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/examples/core/pydantic_utilities.py b/seed/fastapi/examples/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/examples/core/pydantic_utilities.py +++ b/seed/fastapi/examples/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py b/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" 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 e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py b/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py b/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py b/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/extends/core/pydantic_utilities.py b/seed/fastapi/extends/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/extends/core/pydantic_utilities.py +++ b/seed/fastapi/extends/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/extra-properties/core/pydantic_utilities.py b/seed/fastapi/extra-properties/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/extra-properties/core/pydantic_utilities.py +++ b/seed/fastapi/extra-properties/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/folders/core/pydantic_utilities.py b/seed/fastapi/folders/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/folders/core/pydantic_utilities.py +++ b/seed/fastapi/folders/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/grpc-proto-exhaustive/core/pydantic_utilities.py b/seed/fastapi/grpc-proto-exhaustive/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/grpc-proto-exhaustive/core/pydantic_utilities.py +++ b/seed/fastapi/grpc-proto-exhaustive/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/grpc-proto/core/pydantic_utilities.py b/seed/fastapi/grpc-proto/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/grpc-proto/core/pydantic_utilities.py +++ b/seed/fastapi/grpc-proto/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/grpc/core/pydantic_utilities.py b/seed/fastapi/grpc/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/grpc/core/pydantic_utilities.py +++ b/seed/fastapi/grpc/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/idempotency-headers/core/pydantic_utilities.py b/seed/fastapi/idempotency-headers/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/idempotency-headers/core/pydantic_utilities.py +++ b/seed/fastapi/idempotency-headers/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py b/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" 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 e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" 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 e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/mixed-case/core/pydantic_utilities.py b/seed/fastapi/mixed-case/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/mixed-case/core/pydantic_utilities.py +++ b/seed/fastapi/mixed-case/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/multi-line-docs/core/pydantic_utilities.py b/seed/fastapi/multi-line-docs/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/multi-line-docs/core/pydantic_utilities.py +++ b/seed/fastapi/multi-line-docs/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" 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 e5ce0a87860..a445878af5b 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 @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/multi-url-environment/core/pydantic_utilities.py b/seed/fastapi/multi-url-environment/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/multi-url-environment/core/pydantic_utilities.py +++ b/seed/fastapi/multi-url-environment/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/no-environment/core/pydantic_utilities.py b/seed/fastapi/no-environment/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/no-environment/core/pydantic_utilities.py +++ b/seed/fastapi/no-environment/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" 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 e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" 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 e5ce0a87860..a445878af5b 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 @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" 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 e5ce0a87860..a445878af5b 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 @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py b/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/object/core/pydantic_utilities.py b/seed/fastapi/object/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/object/core/pydantic_utilities.py +++ b/seed/fastapi/object/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/objects-with-imports/core/pydantic_utilities.py b/seed/fastapi/objects-with-imports/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/objects-with-imports/core/pydantic_utilities.py +++ b/seed/fastapi/objects-with-imports/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/optional/core/pydantic_utilities.py b/seed/fastapi/optional/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/optional/core/pydantic_utilities.py +++ b/seed/fastapi/optional/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/package-yml/core/pydantic_utilities.py b/seed/fastapi/package-yml/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/package-yml/core/pydantic_utilities.py +++ b/seed/fastapi/package-yml/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/pagination/core/pydantic_utilities.py b/seed/fastapi/pagination/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/pagination/core/pydantic_utilities.py +++ b/seed/fastapi/pagination/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/plain-text/core/pydantic_utilities.py b/seed/fastapi/plain-text/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/plain-text/core/pydantic_utilities.py +++ b/seed/fastapi/plain-text/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/reserved-keywords/core/pydantic_utilities.py b/seed/fastapi/reserved-keywords/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/reserved-keywords/core/pydantic_utilities.py +++ b/seed/fastapi/reserved-keywords/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/simple-fhir/core/pydantic_utilities.py b/seed/fastapi/simple-fhir/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/simple-fhir/core/pydantic_utilities.py +++ b/seed/fastapi/simple-fhir/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" 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 e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py +++ b/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" 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 e5ce0a87860..a445878af5b 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 @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/trace/core/pydantic_utilities.py b/seed/fastapi/trace/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/trace/core/pydantic_utilities.py +++ b/seed/fastapi/trace/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py b/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py +++ b/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/unions/core/pydantic_utilities.py b/seed/fastapi/unions/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/unions/core/pydantic_utilities.py +++ b/seed/fastapi/unions/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/unknown/core/pydantic_utilities.py b/seed/fastapi/unknown/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/unknown/core/pydantic_utilities.py +++ b/seed/fastapi/unknown/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/validation/core/pydantic_utilities.py b/seed/fastapi/validation/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/validation/core/pydantic_utilities.py +++ b/seed/fastapi/validation/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/variables/core/pydantic_utilities.py b/seed/fastapi/variables/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/variables/core/pydantic_utilities.py +++ b/seed/fastapi/variables/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/version-no-default/core/pydantic_utilities.py b/seed/fastapi/version-no-default/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/version-no-default/core/pydantic_utilities.py +++ b/seed/fastapi/version-no-default/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/version/core/pydantic_utilities.py b/seed/fastapi/version/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/version/core/pydantic_utilities.py +++ b/seed/fastapi/version/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/fastapi/websocket/core/pydantic_utilities.py b/seed/fastapi/websocket/core/pydantic_utilities.py index e5ce0a87860..a445878af5b 100644 --- a/seed/fastapi/websocket/core/pydantic_utilities.py +++ b/seed/fastapi/websocket/core/pydantic_utilities.py @@ -140,14 +140,16 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" diff --git a/seed/go-fiber/literal/.mock/definition/inlined.yml b/seed/go-fiber/literal/.mock/definition/inlined.yml index 33fda38a6d8..c2834c5c50c 100644 --- a/seed/go-fiber/literal/.mock/definition/inlined.yml +++ b/seed/go-fiber/literal/.mock/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -32,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: diff --git a/seed/go-fiber/literal/inlined.go b/seed/go-fiber/literal/inlined.go index d293c884ebc..0cd03793022 100644 --- a/seed/go-fiber/literal/inlined.go +++ b/seed/go-fiber/literal/inlined.go @@ -4,16 +4,19 @@ package literal import ( json "encoding/json" + fmt "fmt" + core "github.com/literal/fern/core" ) type SendLiteralsInlinedRequest struct { - Context *string `json:"context,omitempty" url:"-"` - Query string `json:"query" url:"-"` - Temperature *float64 `json:"temperature,omitempty" url:"-"` - AliasedContext SomeAliasedLiteral `json:"aliasedContext,omitempty" url:"-"` - MaybeContext *SomeAliasedLiteral `json:"maybeContext,omitempty" url:"-"` - prompt string - stream bool + Context *string `json:"context,omitempty" url:"-"` + Query string `json:"query" url:"-"` + Temperature *float64 `json:"temperature,omitempty" url:"-"` + AliasedContext SomeAliasedLiteral `json:"aliasedContext,omitempty" url:"-"` + MaybeContext *SomeAliasedLiteral `json:"maybeContext,omitempty" url:"-"` + ObjectWithLiteral *ATopLevelLiteral `json:"objectWithLiteral,omitempty" url:"-"` + prompt string + stream bool } func (s *SendLiteralsInlinedRequest) Prompt() string { @@ -50,4 +53,38 @@ func (s *SendLiteralsInlinedRequest) MarshalJSON() ([]byte, error) { return json.Marshal(marshaler) } +type ATopLevelLiteral struct { + NestedLiteral *ANestedLiteral `json:"nestedLiteral,omitempty" url:"nestedLiteral,omitempty"` + + extraProperties map[string]interface{} +} + +func (a *ATopLevelLiteral) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *ATopLevelLiteral) UnmarshalJSON(data []byte) error { + type unmarshaler ATopLevelLiteral + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *a = ATopLevelLiteral(value) + + extraProperties, err := core.ExtractExtraProperties(data, *a) + if err != nil { + return err + } + a.extraProperties = extraProperties + + return nil +} + +func (a *ATopLevelLiteral) String() string { + if value, err := core.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} + type SomeAliasedLiteral = string diff --git a/seed/go-fiber/literal/types.go b/seed/go-fiber/literal/types.go index ea5fa6c5827..187be354f5b 100644 --- a/seed/go-fiber/literal/types.go +++ b/seed/go-fiber/literal/types.go @@ -69,4 +69,63 @@ func (s *SendResponse) String() string { return fmt.Sprintf("%#v", s) } +type ANestedLiteral struct { + myLiteral string + + extraProperties map[string]interface{} +} + +func (a *ANestedLiteral) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *ANestedLiteral) MyLiteral() string { + return a.myLiteral +} + +func (a *ANestedLiteral) UnmarshalJSON(data []byte) error { + type embed ANestedLiteral + var unmarshaler = struct { + embed + MyLiteral string `json:"myLiteral"` + }{ + embed: embed(*a), + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + *a = ANestedLiteral(unmarshaler.embed) + if unmarshaler.MyLiteral != "How super cool" { + return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", a, "How super cool", unmarshaler.MyLiteral) + } + a.myLiteral = unmarshaler.MyLiteral + + extraProperties, err := core.ExtractExtraProperties(data, *a, "myLiteral") + if err != nil { + return err + } + a.extraProperties = extraProperties + + return nil +} + +func (a *ANestedLiteral) MarshalJSON() ([]byte, error) { + type embed ANestedLiteral + var marshaler = struct { + embed + MyLiteral string `json:"myLiteral"` + }{ + embed: embed(*a), + MyLiteral: "How super cool", + } + return json.Marshal(marshaler) +} + +func (a *ANestedLiteral) String() string { + if value, err := core.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} + type SomeLiteral = string diff --git a/seed/go-model/literal/.mock/definition/inlined.yml b/seed/go-model/literal/.mock/definition/inlined.yml index 33fda38a6d8..c2834c5c50c 100644 --- a/seed/go-model/literal/.mock/definition/inlined.yml +++ b/seed/go-model/literal/.mock/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -32,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: diff --git a/seed/go-model/literal/inlined.go b/seed/go-model/literal/inlined.go index 15baa10b1cc..1515aa523d6 100644 --- a/seed/go-model/literal/inlined.go +++ b/seed/go-model/literal/inlined.go @@ -2,4 +2,44 @@ package literal +import ( + json "encoding/json" + fmt "fmt" + core "github.com/literal/fern/core" +) + +type ATopLevelLiteral struct { + NestedLiteral *ANestedLiteral `json:"nestedLiteral,omitempty" url:"nestedLiteral,omitempty"` + + extraProperties map[string]interface{} +} + +func (a *ATopLevelLiteral) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *ATopLevelLiteral) UnmarshalJSON(data []byte) error { + type unmarshaler ATopLevelLiteral + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *a = ATopLevelLiteral(value) + + extraProperties, err := core.ExtractExtraProperties(data, *a) + if err != nil { + return err + } + a.extraProperties = extraProperties + + return nil +} + +func (a *ATopLevelLiteral) String() string { + if value, err := core.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} + type SomeAliasedLiteral = string diff --git a/seed/go-model/literal/types.go b/seed/go-model/literal/types.go index ea5fa6c5827..187be354f5b 100644 --- a/seed/go-model/literal/types.go +++ b/seed/go-model/literal/types.go @@ -69,4 +69,63 @@ func (s *SendResponse) String() string { return fmt.Sprintf("%#v", s) } +type ANestedLiteral struct { + myLiteral string + + extraProperties map[string]interface{} +} + +func (a *ANestedLiteral) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *ANestedLiteral) MyLiteral() string { + return a.myLiteral +} + +func (a *ANestedLiteral) UnmarshalJSON(data []byte) error { + type embed ANestedLiteral + var unmarshaler = struct { + embed + MyLiteral string `json:"myLiteral"` + }{ + embed: embed(*a), + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + *a = ANestedLiteral(unmarshaler.embed) + if unmarshaler.MyLiteral != "How super cool" { + return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", a, "How super cool", unmarshaler.MyLiteral) + } + a.myLiteral = unmarshaler.MyLiteral + + extraProperties, err := core.ExtractExtraProperties(data, *a, "myLiteral") + if err != nil { + return err + } + a.extraProperties = extraProperties + + return nil +} + +func (a *ANestedLiteral) MarshalJSON() ([]byte, error) { + type embed ANestedLiteral + var marshaler = struct { + embed + MyLiteral string `json:"myLiteral"` + }{ + embed: embed(*a), + MyLiteral: "How super cool", + } + return json.Marshal(marshaler) +} + +func (a *ANestedLiteral) String() string { + if value, err := core.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} + type SomeLiteral = string diff --git a/seed/go-sdk/literal/.mock/definition/inlined.yml b/seed/go-sdk/literal/.mock/definition/inlined.yml index 33fda38a6d8..c2834c5c50c 100644 --- a/seed/go-sdk/literal/.mock/definition/inlined.yml +++ b/seed/go-sdk/literal/.mock/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -32,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: diff --git a/seed/go-sdk/literal/inlined.go b/seed/go-sdk/literal/inlined.go index d293c884ebc..a47ff6da3a1 100644 --- a/seed/go-sdk/literal/inlined.go +++ b/seed/go-sdk/literal/inlined.go @@ -4,16 +4,19 @@ package literal import ( json "encoding/json" + fmt "fmt" + core "github.com/literal/fern/core" ) type SendLiteralsInlinedRequest struct { - Context *string `json:"context,omitempty" url:"-"` - Query string `json:"query" url:"-"` - Temperature *float64 `json:"temperature,omitempty" url:"-"` - AliasedContext SomeAliasedLiteral `json:"aliasedContext,omitempty" url:"-"` - MaybeContext *SomeAliasedLiteral `json:"maybeContext,omitempty" url:"-"` - prompt string - stream bool + Context *string `json:"context,omitempty" url:"-"` + Query string `json:"query" url:"-"` + Temperature *float64 `json:"temperature,omitempty" url:"-"` + AliasedContext SomeAliasedLiteral `json:"aliasedContext,omitempty" url:"-"` + MaybeContext *SomeAliasedLiteral `json:"maybeContext,omitempty" url:"-"` + ObjectWithLiteral *ATopLevelLiteral `json:"objectWithLiteral,omitempty" url:"-"` + prompt string + stream bool } func (s *SendLiteralsInlinedRequest) Prompt() string { @@ -50,4 +53,45 @@ func (s *SendLiteralsInlinedRequest) MarshalJSON() ([]byte, error) { return json.Marshal(marshaler) } +type ATopLevelLiteral struct { + NestedLiteral *ANestedLiteral `json:"nestedLiteral,omitempty" url:"nestedLiteral,omitempty"` + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (a *ATopLevelLiteral) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *ATopLevelLiteral) UnmarshalJSON(data []byte) error { + type unmarshaler ATopLevelLiteral + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *a = ATopLevelLiteral(value) + + extraProperties, err := core.ExtractExtraProperties(data, *a) + if err != nil { + return err + } + a.extraProperties = extraProperties + + a._rawJSON = json.RawMessage(data) + return nil +} + +func (a *ATopLevelLiteral) String() string { + if len(a._rawJSON) > 0 { + if value, err := core.StringifyJSON(a._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} + type SomeAliasedLiteral = string diff --git a/seed/go-sdk/literal/types.go b/seed/go-sdk/literal/types.go index 73361e9c014..f37ed21d745 100644 --- a/seed/go-sdk/literal/types.go +++ b/seed/go-sdk/literal/types.go @@ -76,4 +76,70 @@ func (s *SendResponse) String() string { return fmt.Sprintf("%#v", s) } +type ANestedLiteral struct { + myLiteral string + + extraProperties map[string]interface{} + _rawJSON json.RawMessage +} + +func (a *ANestedLiteral) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *ANestedLiteral) MyLiteral() string { + return a.myLiteral +} + +func (a *ANestedLiteral) UnmarshalJSON(data []byte) error { + type embed ANestedLiteral + var unmarshaler = struct { + embed + MyLiteral string `json:"myLiteral"` + }{ + embed: embed(*a), + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + *a = ANestedLiteral(unmarshaler.embed) + if unmarshaler.MyLiteral != "How super cool" { + return fmt.Errorf("unexpected value for literal on type %T; expected %v got %v", a, "How super cool", unmarshaler.MyLiteral) + } + a.myLiteral = unmarshaler.MyLiteral + + extraProperties, err := core.ExtractExtraProperties(data, *a, "myLiteral") + if err != nil { + return err + } + a.extraProperties = extraProperties + + a._rawJSON = json.RawMessage(data) + return nil +} + +func (a *ANestedLiteral) MarshalJSON() ([]byte, error) { + type embed ANestedLiteral + var marshaler = struct { + embed + MyLiteral string `json:"myLiteral"` + }{ + embed: embed(*a), + MyLiteral: "How super cool", + } + return json.Marshal(marshaler) +} + +func (a *ANestedLiteral) String() string { + if len(a._rawJSON) > 0 { + if value, err := core.StringifyJSON(a._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} + type SomeLiteral = string diff --git a/seed/java-model/literal/.mock/definition/inlined.yml b/seed/java-model/literal/.mock/definition/inlined.yml index 33fda38a6d8..c2834c5c50c 100644 --- a/seed/java-model/literal/.mock/definition/inlined.yml +++ b/seed/java-model/literal/.mock/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -32,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: diff --git a/seed/java-model/literal/src/main/java/com/seed/literal/model/inlined/ANestedLiteral.java b/seed/java-model/literal/src/main/java/com/seed/literal/model/inlined/ANestedLiteral.java new file mode 100644 index 00000000000..3561750966f --- /dev/null +++ b/seed/java-model/literal/src/main/java/com/seed/literal/model/inlined/ANestedLiteral.java @@ -0,0 +1,49 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.literal.model.inlined; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.literal.core.ObjectMappers; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ANestedLiteral.Builder.class) +public final class ANestedLiteral { + private ANestedLiteral() {} + + @JsonProperty("myLiteral") + public String getMyLiteral() { + return "How super cool"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ANestedLiteral; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + private Builder() {} + + public Builder from(ANestedLiteral other) { + return this; + } + + public ANestedLiteral build() { + return new ANestedLiteral(); + } + } +} diff --git a/seed/java-model/literal/src/main/java/com/seed/literal/model/inlined/ATopLevelLiteral.java b/seed/java-model/literal/src/main/java/com/seed/literal/model/inlined/ATopLevelLiteral.java new file mode 100644 index 00000000000..b4838aad557 --- /dev/null +++ b/seed/java-model/literal/src/main/java/com/seed/literal/model/inlined/ATopLevelLiteral.java @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.literal.model.inlined; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.literal.core.ObjectMappers; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ATopLevelLiteral.Builder.class) +public final class ATopLevelLiteral { + private final ANestedLiteral nestedLiteral; + + private ATopLevelLiteral(ANestedLiteral nestedLiteral) { + this.nestedLiteral = nestedLiteral; + } + + @JsonProperty("nestedLiteral") + public ANestedLiteral getNestedLiteral() { + return nestedLiteral; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ATopLevelLiteral && equalTo((ATopLevelLiteral) other); + } + + private boolean equalTo(ATopLevelLiteral other) { + return nestedLiteral.equals(other.nestedLiteral); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.nestedLiteral); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NestedLiteralStage builder() { + return new Builder(); + } + + public interface NestedLiteralStage { + _FinalStage nestedLiteral(ANestedLiteral nestedLiteral); + + Builder from(ATopLevelLiteral other); + } + + public interface _FinalStage { + ATopLevelLiteral build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NestedLiteralStage, _FinalStage { + private ANestedLiteral nestedLiteral; + + private Builder() {} + + @java.lang.Override + public Builder from(ATopLevelLiteral other) { + nestedLiteral(other.getNestedLiteral()); + return this; + } + + @java.lang.Override + @JsonSetter("nestedLiteral") + public _FinalStage nestedLiteral(ANestedLiteral nestedLiteral) { + this.nestedLiteral = nestedLiteral; + return this; + } + + @java.lang.Override + public ATopLevelLiteral build() { + return new ATopLevelLiteral(nestedLiteral); + } + } +} diff --git a/seed/java-sdk/literal/.mock/definition/inlined.yml b/seed/java-sdk/literal/.mock/definition/inlined.yml index 33fda38a6d8..c2834c5c50c 100644 --- a/seed/java-sdk/literal/.mock/definition/inlined.yml +++ b/seed/java-sdk/literal/.mock/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -32,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: diff --git a/seed/java-sdk/literal/src/main/java/com/seed/literal/resources/inlined/requests/SendLiteralsInlinedRequest.java b/seed/java-sdk/literal/src/main/java/com/seed/literal/resources/inlined/requests/SendLiteralsInlinedRequest.java index 6cacb3db5a0..879a0aa46b8 100644 --- a/seed/java-sdk/literal/src/main/java/com/seed/literal/resources/inlined/requests/SendLiteralsInlinedRequest.java +++ b/seed/java-sdk/literal/src/main/java/com/seed/literal/resources/inlined/requests/SendLiteralsInlinedRequest.java @@ -12,6 +12,7 @@ import com.fasterxml.jackson.annotation.Nulls; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.seed.literal.core.ObjectMappers; +import com.seed.literal.resources.inlined.types.ATopLevelLiteral; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -30,6 +31,8 @@ public final class SendLiteralsInlinedRequest { private final Optional maybeContext; + private final ATopLevelLiteral objectWithLiteral; + private final Map additionalProperties; private SendLiteralsInlinedRequest( @@ -38,12 +41,14 @@ private SendLiteralsInlinedRequest( Optional temperature, String aliasedContext, Optional maybeContext, + ATopLevelLiteral objectWithLiteral, Map additionalProperties) { this.context = context; this.query = query; this.temperature = temperature; this.aliasedContext = aliasedContext; this.maybeContext = maybeContext; + this.objectWithLiteral = objectWithLiteral; this.additionalProperties = additionalProperties; } @@ -82,6 +87,11 @@ public Optional getMaybeContext() { return maybeContext; } + @JsonProperty("objectWithLiteral") + public ATopLevelLiteral getObjectWithLiteral() { + return objectWithLiteral; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -98,12 +108,19 @@ private boolean equalTo(SendLiteralsInlinedRequest other) { && query.equals(other.query) && temperature.equals(other.temperature) && aliasedContext.equals(other.aliasedContext) - && maybeContext.equals(other.maybeContext); + && maybeContext.equals(other.maybeContext) + && objectWithLiteral.equals(other.objectWithLiteral); } @java.lang.Override public int hashCode() { - return Objects.hash(this.context, this.query, this.temperature, this.aliasedContext, this.maybeContext); + return Objects.hash( + this.context, + this.query, + this.temperature, + this.aliasedContext, + this.maybeContext, + this.objectWithLiteral); } @java.lang.Override @@ -122,7 +139,11 @@ public interface QueryStage { } public interface AliasedContextStage { - _FinalStage aliasedContext(String aliasedContext); + ObjectWithLiteralStage aliasedContext(String aliasedContext); + } + + public interface ObjectWithLiteralStage { + _FinalStage objectWithLiteral(ATopLevelLiteral objectWithLiteral); } public interface _FinalStage { @@ -142,11 +163,13 @@ public interface _FinalStage { } @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements QueryStage, AliasedContextStage, _FinalStage { + public static final class Builder implements QueryStage, AliasedContextStage, ObjectWithLiteralStage, _FinalStage { private String query; private String aliasedContext; + private ATopLevelLiteral objectWithLiteral; + private Optional maybeContext = Optional.empty(); private Optional temperature = Optional.empty(); @@ -165,6 +188,7 @@ public Builder from(SendLiteralsInlinedRequest other) { temperature(other.getTemperature()); aliasedContext(other.getAliasedContext()); maybeContext(other.getMaybeContext()); + objectWithLiteral(other.getObjectWithLiteral()); return this; } @@ -177,11 +201,18 @@ public AliasedContextStage query(String query) { @java.lang.Override @JsonSetter("aliasedContext") - public _FinalStage aliasedContext(String aliasedContext) { + public ObjectWithLiteralStage aliasedContext(String aliasedContext) { this.aliasedContext = aliasedContext; return this; } + @java.lang.Override + @JsonSetter("objectWithLiteral") + public _FinalStage objectWithLiteral(ATopLevelLiteral objectWithLiteral) { + this.objectWithLiteral = objectWithLiteral; + return this; + } + @java.lang.Override public _FinalStage maybeContext(String maybeContext) { this.maybeContext = Optional.ofNullable(maybeContext); @@ -224,7 +255,7 @@ public _FinalStage context(Optional context) { @java.lang.Override public SendLiteralsInlinedRequest build() { return new SendLiteralsInlinedRequest( - context, query, temperature, aliasedContext, maybeContext, additionalProperties); + context, query, temperature, aliasedContext, maybeContext, objectWithLiteral, additionalProperties); } } } diff --git a/seed/java-sdk/literal/src/main/java/com/seed/literal/resources/inlined/types/ANestedLiteral.java b/seed/java-sdk/literal/src/main/java/com/seed/literal/resources/inlined/types/ANestedLiteral.java new file mode 100644 index 00000000000..64d6eb5f759 --- /dev/null +++ b/seed/java-sdk/literal/src/main/java/com/seed/literal/resources/inlined/types/ANestedLiteral.java @@ -0,0 +1,65 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.literal.resources.inlined.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.literal.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ANestedLiteral.Builder.class) +public final class ANestedLiteral { + private final Map additionalProperties; + + private ANestedLiteral(Map additionalProperties) { + this.additionalProperties = additionalProperties; + } + + @JsonProperty("myLiteral") + public String getMyLiteral() { + return "How super cool"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ANestedLiteral; + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder { + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + public Builder from(ANestedLiteral other) { + return this; + } + + public ANestedLiteral build() { + return new ANestedLiteral(additionalProperties); + } + } +} diff --git a/seed/java-sdk/literal/src/main/java/com/seed/literal/resources/inlined/types/ATopLevelLiteral.java b/seed/java-sdk/literal/src/main/java/com/seed/literal/resources/inlined/types/ATopLevelLiteral.java new file mode 100644 index 00000000000..ada74cb8ca1 --- /dev/null +++ b/seed/java-sdk/literal/src/main/java/com/seed/literal/resources/inlined/types/ATopLevelLiteral.java @@ -0,0 +1,101 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.seed.literal.resources.inlined.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.seed.literal.core.ObjectMappers; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = ATopLevelLiteral.Builder.class) +public final class ATopLevelLiteral { + private final ANestedLiteral nestedLiteral; + + private final Map additionalProperties; + + private ATopLevelLiteral(ANestedLiteral nestedLiteral, Map additionalProperties) { + this.nestedLiteral = nestedLiteral; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("nestedLiteral") + public ANestedLiteral getNestedLiteral() { + return nestedLiteral; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ATopLevelLiteral && equalTo((ATopLevelLiteral) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(ATopLevelLiteral other) { + return nestedLiteral.equals(other.nestedLiteral); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.nestedLiteral); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NestedLiteralStage builder() { + return new Builder(); + } + + public interface NestedLiteralStage { + _FinalStage nestedLiteral(ANestedLiteral nestedLiteral); + + Builder from(ATopLevelLiteral other); + } + + public interface _FinalStage { + ATopLevelLiteral build(); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements NestedLiteralStage, _FinalStage { + private ANestedLiteral nestedLiteral; + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(ATopLevelLiteral other) { + nestedLiteral(other.getNestedLiteral()); + return this; + } + + @java.lang.Override + @JsonSetter("nestedLiteral") + public _FinalStage nestedLiteral(ANestedLiteral nestedLiteral) { + this.nestedLiteral = nestedLiteral; + return this; + } + + @java.lang.Override + public ATopLevelLiteral build() { + return new ATopLevelLiteral(nestedLiteral, additionalProperties); + } + } +} diff --git a/seed/java-spring/literal/.mock/definition/inlined.yml b/seed/java-spring/literal/.mock/definition/inlined.yml index 33fda38a6d8..c2834c5c50c 100644 --- a/seed/java-spring/literal/.mock/definition/inlined.yml +++ b/seed/java-spring/literal/.mock/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -32,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: diff --git a/seed/java-spring/literal/resources/inlined/requests/SendLiteralsInlinedRequest.java b/seed/java-spring/literal/resources/inlined/requests/SendLiteralsInlinedRequest.java index c69fd37e9cc..08602fc32ed 100644 --- a/seed/java-spring/literal/resources/inlined/requests/SendLiteralsInlinedRequest.java +++ b/seed/java-spring/literal/resources/inlined/requests/SendLiteralsInlinedRequest.java @@ -17,6 +17,7 @@ import java.lang.String; import java.util.Objects; import java.util.Optional; +import resources.inlined.types.ATopLevelLiteral; import resources.inlined.types.SomeAliasedLiteral; @JsonInclude(JsonInclude.Include.NON_ABSENT) @@ -34,14 +35,17 @@ public final class SendLiteralsInlinedRequest { private final Optional maybeContext; + private final ATopLevelLiteral objectWithLiteral; + private SendLiteralsInlinedRequest(Optional context, String query, Optional temperature, SomeAliasedLiteral aliasedContext, - Optional maybeContext) { + Optional maybeContext, ATopLevelLiteral objectWithLiteral) { this.context = context; this.query = query; this.temperature = temperature; this.aliasedContext = aliasedContext; this.maybeContext = maybeContext; + this.objectWithLiteral = objectWithLiteral; } @JsonProperty("prompt") @@ -79,6 +83,11 @@ public Optional getMaybeContext() { return maybeContext; } + @JsonProperty("objectWithLiteral") + public ATopLevelLiteral getObjectWithLiteral() { + return objectWithLiteral; + } + @java.lang.Override public boolean equals(Object other) { if (this == other) return true; @@ -86,12 +95,12 @@ public boolean equals(Object other) { } private boolean equalTo(SendLiteralsInlinedRequest other) { - return context.equals(other.context) && query.equals(other.query) && temperature.equals(other.temperature) && aliasedContext.equals(other.aliasedContext) && maybeContext.equals(other.maybeContext); + return context.equals(other.context) && query.equals(other.query) && temperature.equals(other.temperature) && aliasedContext.equals(other.aliasedContext) && maybeContext.equals(other.maybeContext) && objectWithLiteral.equals(other.objectWithLiteral); } @java.lang.Override public int hashCode() { - return Objects.hash(this.context, this.query, this.temperature, this.aliasedContext, this.maybeContext); + return Objects.hash(this.context, this.query, this.temperature, this.aliasedContext, this.maybeContext, this.objectWithLiteral); } @java.lang.Override @@ -110,7 +119,11 @@ public interface QueryStage { } public interface AliasedContextStage { - _FinalStage aliasedContext(SomeAliasedLiteral aliasedContext); + ObjectWithLiteralStage aliasedContext(SomeAliasedLiteral aliasedContext); + } + + public interface ObjectWithLiteralStage { + _FinalStage objectWithLiteral(ATopLevelLiteral objectWithLiteral); } public interface _FinalStage { @@ -132,11 +145,13 @@ public interface _FinalStage { @JsonIgnoreProperties( ignoreUnknown = true ) - public static final class Builder implements QueryStage, AliasedContextStage, _FinalStage { + public static final class Builder implements QueryStage, AliasedContextStage, ObjectWithLiteralStage, _FinalStage { private String query; private SomeAliasedLiteral aliasedContext; + private ATopLevelLiteral objectWithLiteral; + private Optional maybeContext = Optional.empty(); private Optional temperature = Optional.empty(); @@ -153,6 +168,7 @@ public Builder from(SendLiteralsInlinedRequest other) { temperature(other.getTemperature()); aliasedContext(other.getAliasedContext()); maybeContext(other.getMaybeContext()); + objectWithLiteral(other.getObjectWithLiteral()); return this; } @@ -165,11 +181,18 @@ public AliasedContextStage query(String query) { @java.lang.Override @JsonSetter("aliasedContext") - public _FinalStage aliasedContext(SomeAliasedLiteral aliasedContext) { + public ObjectWithLiteralStage aliasedContext(SomeAliasedLiteral aliasedContext) { this.aliasedContext = aliasedContext; return this; } + @java.lang.Override + @JsonSetter("objectWithLiteral") + public _FinalStage objectWithLiteral(ATopLevelLiteral objectWithLiteral) { + this.objectWithLiteral = objectWithLiteral; + return this; + } + @java.lang.Override public _FinalStage maybeContext(SomeAliasedLiteral maybeContext) { this.maybeContext = Optional.ofNullable(maybeContext); @@ -220,7 +243,7 @@ public _FinalStage context(Optional context) { @java.lang.Override public SendLiteralsInlinedRequest build() { - return new SendLiteralsInlinedRequest(context, query, temperature, aliasedContext, maybeContext); + return new SendLiteralsInlinedRequest(context, query, temperature, aliasedContext, maybeContext, objectWithLiteral); } } } diff --git a/seed/java-spring/literal/resources/inlined/types/ANestedLiteral.java b/seed/java-spring/literal/resources/inlined/types/ANestedLiteral.java new file mode 100644 index 00000000000..5140cf35c39 --- /dev/null +++ b/seed/java-spring/literal/resources/inlined/types/ANestedLiteral.java @@ -0,0 +1,58 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package resources.inlined.types; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import core.ObjectMappers; +import java.lang.Object; +import java.lang.String; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = ANestedLiteral.Builder.class +) +public final class ANestedLiteral { + private ANestedLiteral() { + } + + @JsonProperty("myLiteral") + public String getMyLiteral() { + return "How super cool"; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ANestedLiteral; + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static Builder builder() { + return new Builder(); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder { + private Builder() { + } + + public Builder from(ANestedLiteral other) { + return this; + } + + public ANestedLiteral build() { + return new ANestedLiteral(); + } + } +} diff --git a/seed/java-spring/literal/resources/inlined/types/ATopLevelLiteral.java b/seed/java-spring/literal/resources/inlined/types/ATopLevelLiteral.java new file mode 100644 index 00000000000..f62eb77c40b --- /dev/null +++ b/seed/java-spring/literal/resources/inlined/types/ATopLevelLiteral.java @@ -0,0 +1,94 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +package resources.inlined.types; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import core.ObjectMappers; +import java.lang.Object; +import java.lang.String; +import java.util.Objects; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize( + builder = ATopLevelLiteral.Builder.class +) +public final class ATopLevelLiteral { + private final ANestedLiteral nestedLiteral; + + private ATopLevelLiteral(ANestedLiteral nestedLiteral) { + this.nestedLiteral = nestedLiteral; + } + + @JsonProperty("nestedLiteral") + public ANestedLiteral getNestedLiteral() { + return nestedLiteral; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof ATopLevelLiteral && equalTo((ATopLevelLiteral) other); + } + + private boolean equalTo(ATopLevelLiteral other) { + return nestedLiteral.equals(other.nestedLiteral); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.nestedLiteral); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static NestedLiteralStage builder() { + return new Builder(); + } + + public interface NestedLiteralStage { + _FinalStage nestedLiteral(ANestedLiteral nestedLiteral); + + Builder from(ATopLevelLiteral other); + } + + public interface _FinalStage { + ATopLevelLiteral build(); + } + + @JsonIgnoreProperties( + ignoreUnknown = true + ) + public static final class Builder implements NestedLiteralStage, _FinalStage { + private ANestedLiteral nestedLiteral; + + private Builder() { + } + + @java.lang.Override + public Builder from(ATopLevelLiteral other) { + nestedLiteral(other.getNestedLiteral()); + return this; + } + + @java.lang.Override + @JsonSetter("nestedLiteral") + public _FinalStage nestedLiteral(ANestedLiteral nestedLiteral) { + this.nestedLiteral = nestedLiteral; + return this; + } + + @java.lang.Override + public ATopLevelLiteral build() { + return new ATopLevelLiteral(nestedLiteral); + } + } +} diff --git a/seed/openapi/literal/.mock/definition/inlined.yml b/seed/openapi/literal/.mock/definition/inlined.yml index 33fda38a6d8..c2834c5c50c 100644 --- a/seed/openapi/literal/.mock/definition/inlined.yml +++ b/seed/openapi/literal/.mock/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -32,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: diff --git a/seed/openapi/literal/openapi.yml b/seed/openapi/literal/openapi.yml index a8435fb9c8e..7885a9725b9 100644 --- a/seed/openapi/literal/openapi.yml +++ b/seed/openapi/literal/openapi.yml @@ -107,11 +107,14 @@ paths: maybeContext: $ref: '#/components/schemas/SomeAliasedLiteral' nullable: true + objectWithLiteral: + $ref: '#/components/schemas/ATopLevelLiteral' required: - prompt - query - stream - aliasedContext + - objectWithLiteral examples: Example1: value: @@ -120,6 +123,9 @@ paths: context: You're super wise aliasedContext: You're super wise maybeContext: You're super wise + objectWithLiteral: + nestedLiteral: + myLiteral: How super cool stream: false query: What is the weather today /path/{id}: @@ -252,6 +258,24 @@ components: type: string enum: - You're super wise + ATopLevelLiteral: + title: ATopLevelLiteral + type: object + properties: + nestedLiteral: + $ref: '#/components/schemas/ANestedLiteral' + required: + - nestedLiteral + ANestedLiteral: + title: ANestedLiteral + type: object + properties: + myLiteral: + type: string + enum: + - How super cool + required: + - myLiteral SendRequest: title: SendRequest type: object diff --git a/seed/postman/literal/.mock/definition/inlined.yml b/seed/postman/literal/.mock/definition/inlined.yml index 33fda38a6d8..c2834c5c50c 100644 --- a/seed/postman/literal/.mock/definition/inlined.yml +++ b/seed/postman/literal/.mock/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -32,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: diff --git a/seed/postman/literal/collection.json b/seed/postman/literal/collection.json index 9f087239519..510b27c524d 100644 --- a/seed/postman/literal/collection.json +++ b/seed/postman/literal/collection.json @@ -206,7 +206,7 @@ "auth": null, "body": { "mode": "raw", - "raw": "{\n \"temperature\": 10.1,\n \"prompt\": \"You are a helpful assistant\",\n \"context\": \"You're super wise\",\n \"aliasedContext\": \"You're super wise\",\n \"maybeContext\": \"You're super wise\",\n \"stream\": false,\n \"query\": \"What is the weather today\"\n}", + "raw": "{\n \"temperature\": 10.1,\n \"prompt\": \"You are a helpful assistant\",\n \"context\": \"You're super wise\",\n \"aliasedContext\": \"You're super wise\",\n \"maybeContext\": \"You're super wise\",\n \"objectWithLiteral\": {\n \"nestedLiteral\": {\n \"myLiteral\": \"How super cool\"\n }\n },\n \"stream\": false,\n \"query\": \"What is the weather today\"\n}", "options": { "raw": { "language": "json" @@ -243,7 +243,7 @@ "auth": null, "body": { "mode": "raw", - "raw": "{\n \"temperature\": 10.1,\n \"prompt\": \"You are a helpful assistant\",\n \"context\": \"You're super wise\",\n \"aliasedContext\": \"You're super wise\",\n \"maybeContext\": \"You're super wise\",\n \"stream\": false,\n \"query\": \"What is the weather today\"\n}", + "raw": "{\n \"temperature\": 10.1,\n \"prompt\": \"You are a helpful assistant\",\n \"context\": \"You're super wise\",\n \"aliasedContext\": \"You're super wise\",\n \"maybeContext\": \"You're super wise\",\n \"objectWithLiteral\": {\n \"nestedLiteral\": {\n \"myLiteral\": \"How super cool\"\n }\n },\n \"stream\": false,\n \"query\": \"What is the weather today\"\n}", "options": { "raw": { "language": "json" @@ -283,7 +283,7 @@ "auth": null, "body": { "mode": "raw", - "raw": "{\n \"temperature\": 10.1,\n \"prompt\": \"You are a helpful assistant\",\n \"context\": \"You're super wise\",\n \"aliasedContext\": \"You're super wise\",\n \"maybeContext\": \"You're super wise\",\n \"stream\": false,\n \"query\": \"What is the weather today\"\n}", + "raw": "{\n \"temperature\": 10.1,\n \"prompt\": \"You are a helpful assistant\",\n \"context\": \"You're super wise\",\n \"aliasedContext\": \"You're super wise\",\n \"maybeContext\": \"You're super wise\",\n \"objectWithLiteral\": {\n \"nestedLiteral\": {\n \"myLiteral\": \"How super cool\"\n }\n },\n \"stream\": false,\n \"query\": \"What is the weather today\"\n}", "options": { "raw": { "language": "json" 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py +++ b/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") diff --git a/seed/pydantic/any-auth/src/seed/any_auth/core/pydantic_utilities.py b/seed/pydantic/any-auth/src/seed/any_auth/core/pydantic_utilities.py index 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/any-auth/src/seed/any_auth/core/pydantic_utilities.py +++ b/seed/pydantic/any-auth/src/seed/any_auth/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py +++ b/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py +++ b/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") diff --git a/seed/pydantic/cross-package-type-names/src/seed/cross_package_type_names/core/pydantic_utilities.py b/seed/pydantic/cross-package-type-names/src/seed/cross_package_type_names/core/pydantic_utilities.py index 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/cross-package-type-names/src/seed/cross_package_type_names/core/pydantic_utilities.py +++ b/seed/pydantic/cross-package-type-names/src/seed/cross_package_type_names/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py +++ b/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py +++ b/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py +++ b/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") diff --git a/seed/pydantic/grpc-proto-exhaustive/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/grpc-proto-exhaustive/src/seed/api/core/pydantic_utilities.py index 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/grpc-proto-exhaustive/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/grpc-proto-exhaustive/src/seed/api/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") diff --git a/seed/pydantic/literal/.mock/definition/inlined.yml b/seed/pydantic/literal/.mock/definition/inlined.yml index 33fda38a6d8..c2834c5c50c 100644 --- a/seed/pydantic/literal/.mock/definition/inlined.yml +++ b/seed/pydantic/literal/.mock/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -32,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: diff --git a/seed/pydantic/literal/src/seed/literal/__init__.py b/seed/pydantic/literal/src/seed/literal/__init__.py index 7066e1cfe53..e4542bd9a8e 100644 --- a/seed/pydantic/literal/src/seed/literal/__init__.py +++ b/seed/pydantic/literal/src/seed/literal/__init__.py @@ -1,6 +1,23 @@ # This file was auto-generated by Fern from our API Definition. -from .resources import SendRequest, SomeAliasedLiteral, SomeLiteral, inlined, reference +from .resources import ( + ANestedLiteral, + ATopLevelLiteral, + SendRequest, + SomeAliasedLiteral, + SomeLiteral, + inlined, + reference, +) from .send_response import SendResponse -__all__ = ["SendRequest", "SendResponse", "SomeAliasedLiteral", "SomeLiteral", "inlined", "reference"] +__all__ = [ + "ANestedLiteral", + "ATopLevelLiteral", + "SendRequest", + "SendResponse", + "SomeAliasedLiteral", + "SomeLiteral", + "inlined", + "reference", +] 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py +++ b/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") diff --git a/seed/pydantic/literal/src/seed/literal/resources/__init__.py b/seed/pydantic/literal/src/seed/literal/resources/__init__.py index 6c1e9347879..0f6855b21e9 100644 --- a/seed/pydantic/literal/src/seed/literal/resources/__init__.py +++ b/seed/pydantic/literal/src/seed/literal/resources/__init__.py @@ -1,7 +1,15 @@ # This file was auto-generated by Fern from our API Definition. from . import inlined, reference -from .inlined import SomeAliasedLiteral +from .inlined import ANestedLiteral, ATopLevelLiteral, SomeAliasedLiteral from .reference import SendRequest, SomeLiteral -__all__ = ["SendRequest", "SomeAliasedLiteral", "SomeLiteral", "inlined", "reference"] +__all__ = [ + "ANestedLiteral", + "ATopLevelLiteral", + "SendRequest", + "SomeAliasedLiteral", + "SomeLiteral", + "inlined", + "reference", +] diff --git a/seed/pydantic/literal/src/seed/literal/resources/inlined/__init__.py b/seed/pydantic/literal/src/seed/literal/resources/inlined/__init__.py index 4df5ab556ac..2fae519363a 100644 --- a/seed/pydantic/literal/src/seed/literal/resources/inlined/__init__.py +++ b/seed/pydantic/literal/src/seed/literal/resources/inlined/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +from .a_nested_literal import ANestedLiteral +from .a_top_level_literal import ATopLevelLiteral from .some_aliased_literal import SomeAliasedLiteral -__all__ = ["SomeAliasedLiteral"] +__all__ = ["ANestedLiteral", "ATopLevelLiteral", "SomeAliasedLiteral"] diff --git a/seed/pydantic/literal/src/seed/literal/resources/inlined/a_nested_literal.py b/seed/pydantic/literal/src/seed/literal/resources/inlined/a_nested_literal.py new file mode 100644 index 00000000000..edebf535d28 --- /dev/null +++ b/seed/pydantic/literal/src/seed/literal/resources/inlined/a_nested_literal.py @@ -0,0 +1,21 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +import typing_extensions +import typing +from ...core.serialization import FieldMetadata +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic + + +class ANestedLiteral(UniversalBaseModel): + my_literal: typing_extensions.Annotated[typing.Literal["How super cool"], FieldMetadata(alias="myLiteral")] = ( + "How super cool" + ) + + 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/pydantic/literal/src/seed/literal/resources/inlined/a_top_level_literal.py b/seed/pydantic/literal/src/seed/literal/resources/inlined/a_top_level_literal.py new file mode 100644 index 00000000000..d64966ef1bf --- /dev/null +++ b/seed/pydantic/literal/src/seed/literal/resources/inlined/a_top_level_literal.py @@ -0,0 +1,20 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +import typing_extensions +from .a_nested_literal import ANestedLiteral +from ...core.serialization import FieldMetadata +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing +import pydantic + + +class ATopLevelLiteral(UniversalBaseModel): + nested_literal: typing_extensions.Annotated[ANestedLiteral, FieldMetadata(alias="nestedLiteral")] + + 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/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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py +++ b/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py +++ b/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py +++ b/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py +++ b/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py +++ b/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py +++ b/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py +++ b/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py +++ b/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py +++ b/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") diff --git a/seed/python-sdk/any-auth/src/seed/core/pydantic_utilities.py b/seed/python-sdk/any-auth/src/seed/core/pydantic_utilities.py index 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/any-auth/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/any-auth/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") diff --git a/seed/python-sdk/cross-package-type-names/src/seed/core/pydantic_utilities.py b/seed/python-sdk/cross-package-type-names/src/seed/core/pydantic_utilities.py index 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/cross-package-type-names/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/cross-package-type-names/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") diff --git a/seed/python-sdk/grpc-proto-exhaustive/src/seed/core/pydantic_utilities.py b/seed/python-sdk/grpc-proto-exhaustive/src/seed/core/pydantic_utilities.py index 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/grpc-proto-exhaustive/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/grpc-proto-exhaustive/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") diff --git a/seed/python-sdk/literal/no-custom-config/.mock/definition/inlined.yml b/seed/python-sdk/literal/no-custom-config/.mock/definition/inlined.yml index 33fda38a6d8..c2834c5c50c 100644 --- a/seed/python-sdk/literal/no-custom-config/.mock/definition/inlined.yml +++ b/seed/python-sdk/literal/no-custom-config/.mock/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -32,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: diff --git a/seed/python-sdk/literal/no-custom-config/reference.md b/seed/python-sdk/literal/no-custom-config/reference.md index 7a5389faa93..5bcff3fe4b3 100644 --- a/seed/python-sdk/literal/no-custom-config/reference.md +++ b/seed/python-sdk/literal/no-custom-config/reference.md @@ -71,6 +71,7 @@ client.headers.send( ```python from seed import SeedLiteral +from seed.inlined import ANestedLiteral, ATopLevelLiteral client = SeedLiteral( base_url="https://yourhost.com/path/to/api", @@ -79,6 +80,9 @@ client.inlined.send( temperature=10.1, context="You're super wise", maybe_context="You're super wise", + object_with_literal=ATopLevelLiteral( + nested_literal=ANestedLiteral(), + ), query="What is the weather today", ) @@ -104,6 +108,14 @@ client.inlined.send(
+**object_with_literal:** `ATopLevelLiteral` + +
+
+ +
+
+ **context:** `typing.Optional[typing.Literal["You're super wise"]]`
diff --git a/seed/python-sdk/literal/no-custom-config/snippet-templates.json b/seed/python-sdk/literal/no-custom-config/snippet-templates.json index b8a0dca0d82..2792b393be1 100644 --- a/seed/python-sdk/literal/no-custom-config/snippet-templates.json +++ b/seed/python-sdk/literal/no-custom-config/snippet-templates.json @@ -147,6 +147,33 @@ ], "type": "generic" } + }, + { + "type": "template", + "value": { + "imports": [ + "from seed.inlined import ATopLevelLiteral" + ], + "isOptional": true, + "templateString": "object_with_literal=ATopLevelLiteral(\n\t\t$FERN_INPUT\n\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [ + "from seed.inlined import ANestedLiteral" + ], + "isOptional": true, + "templateString": "nested_literal=ANestedLiteral(\n\t\t\t$FERN_INPUT\n\t\t)", + "templateInputs": [], + "inputDelimiter": ",\n\t\t\t", + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t", + "type": "generic" + } } ], "inputDelimiter": ",\n\t", @@ -202,6 +229,33 @@ ], "type": "generic" } + }, + { + "type": "template", + "value": { + "imports": [ + "from seed.inlined import ATopLevelLiteral" + ], + "isOptional": true, + "templateString": "object_with_literal=ATopLevelLiteral(\n\t\t$FERN_INPUT\n\t)", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [ + "from seed.inlined import ANestedLiteral" + ], + "isOptional": true, + "templateString": "nested_literal=ANestedLiteral(\n\t\t\t$FERN_INPUT\n\t\t)", + "templateInputs": [], + "inputDelimiter": ",\n\t\t\t", + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t", + "type": "generic" + } } ], "inputDelimiter": ",\n\t", diff --git a/seed/python-sdk/literal/no-custom-config/snippet.json b/seed/python-sdk/literal/no-custom-config/snippet.json index 967430dbd5f..b2e25074a0e 100644 --- a/seed/python-sdk/literal/no-custom-config/snippet.json +++ b/seed/python-sdk/literal/no-custom-config/snippet.json @@ -22,8 +22,8 @@ "identifier_override": "endpoint_inlined.send" }, "snippet": { - "sync_client": "from seed import SeedLiteral\n\nclient = SeedLiteral(\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.inlined.send(\n temperature=10.1,\n context=\"You're super wise\",\n maybe_context=\"You're super wise\",\n query=\"What is the weather today\",\n)\n", - "async_client": "import asyncio\n\nfrom seed import AsyncSeedLiteral\n\nclient = AsyncSeedLiteral(\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.inlined.send(\n temperature=10.1,\n context=\"You're super wise\",\n maybe_context=\"You're super wise\",\n query=\"What is the weather today\",\n )\n\n\nasyncio.run(main())\n", + "sync_client": "from seed import SeedLiteral\nfrom seed.inlined import ANestedLiteral, ATopLevelLiteral\n\nclient = SeedLiteral(\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.inlined.send(\n temperature=10.1,\n context=\"You're super wise\",\n maybe_context=\"You're super wise\",\n object_with_literal=ATopLevelLiteral(\n nested_literal=ANestedLiteral(),\n ),\n query=\"What is the weather today\",\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedLiteral\nfrom seed.inlined import ANestedLiteral, ATopLevelLiteral\n\nclient = AsyncSeedLiteral(\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.inlined.send(\n temperature=10.1,\n context=\"You're super wise\",\n maybe_context=\"You're super wise\",\n object_with_literal=ATopLevelLiteral(\n nested_literal=ANestedLiteral(),\n ),\n query=\"What is the weather today\",\n )\n\n\nasyncio.run(main())\n", "type": "python" } }, diff --git a/seed/python-sdk/literal/no-custom-config/src/seed/__init__.py b/seed/python-sdk/literal/no-custom-config/src/seed/__init__.py index 3a7b4ef225b..f7cd691a2df 100644 --- a/seed/python-sdk/literal/no-custom-config/src/seed/__init__.py +++ b/seed/python-sdk/literal/no-custom-config/src/seed/__init__.py @@ -3,11 +3,13 @@ from .types import SendResponse from . import headers, inlined, path, query, reference from .client import AsyncSeedLiteral, SeedLiteral -from .inlined import SomeAliasedLiteral +from .inlined import ANestedLiteral, ATopLevelLiteral, SomeAliasedLiteral from .reference import SendRequest, SomeLiteral from .version import __version__ __all__ = [ + "ANestedLiteral", + "ATopLevelLiteral", "AsyncSeedLiteral", "SeedLiteral", "SendRequest", 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") diff --git a/seed/python-sdk/literal/no-custom-config/src/seed/inlined/__init__.py b/seed/python-sdk/literal/no-custom-config/src/seed/inlined/__init__.py index d8507b68c37..0bdbce63972 100644 --- a/seed/python-sdk/literal/no-custom-config/src/seed/inlined/__init__.py +++ b/seed/python-sdk/literal/no-custom-config/src/seed/inlined/__init__.py @@ -1,5 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -from .types import SomeAliasedLiteral +from .types import ANestedLiteral, ATopLevelLiteral, SomeAliasedLiteral -__all__ = ["SomeAliasedLiteral"] +__all__ = ["ANestedLiteral", "ATopLevelLiteral", "SomeAliasedLiteral"] diff --git a/seed/python-sdk/literal/no-custom-config/src/seed/inlined/client.py b/seed/python-sdk/literal/no-custom-config/src/seed/inlined/client.py index 62a0c87c7f3..3ec303a1596 100644 --- a/seed/python-sdk/literal/no-custom-config/src/seed/inlined/client.py +++ b/seed/python-sdk/literal/no-custom-config/src/seed/inlined/client.py @@ -2,9 +2,11 @@ import typing from ..core.client_wrapper import SyncClientWrapper +from .types.a_top_level_literal import ATopLevelLiteral from .types.some_aliased_literal import SomeAliasedLiteral from ..core.request_options import RequestOptions from ..types.send_response import SendResponse +from ..core.serialization import convert_and_respect_annotation_metadata from ..core.pydantic_utilities import parse_obj_as from json.decoder import JSONDecodeError from ..core.api_error import ApiError @@ -22,6 +24,7 @@ def send( self, *, query: str, + object_with_literal: ATopLevelLiteral, context: typing.Optional[typing.Literal["You're super wise"]] = OMIT, temperature: typing.Optional[float] = OMIT, maybe_context: typing.Optional[SomeAliasedLiteral] = OMIT, @@ -32,6 +35,8 @@ def send( ---------- query : str + object_with_literal : ATopLevelLiteral + context : typing.Optional[typing.Literal["You're super wise"]] temperature : typing.Optional[float] @@ -48,6 +53,7 @@ def send( Examples -------- from seed import SeedLiteral + from seed.inlined import ANestedLiteral, ATopLevelLiteral client = SeedLiteral( base_url="https://yourhost.com/path/to/api", @@ -56,6 +62,9 @@ def send( temperature=10.1, context="You're super wise", maybe_context="You're super wise", + object_with_literal=ATopLevelLiteral( + nested_literal=ANestedLiteral(), + ), query="What is the weather today", ) """ @@ -67,6 +76,9 @@ def send( "query": query, "temperature": temperature, "maybeContext": maybe_context, + "objectWithLiteral": convert_and_respect_annotation_metadata( + object_=object_with_literal, annotation=ATopLevelLiteral, direction="write" + ), "prompt": "You are a helpful assistant", "stream": False, "aliasedContext": "You're super wise", @@ -97,6 +109,7 @@ async def send( self, *, query: str, + object_with_literal: ATopLevelLiteral, context: typing.Optional[typing.Literal["You're super wise"]] = OMIT, temperature: typing.Optional[float] = OMIT, maybe_context: typing.Optional[SomeAliasedLiteral] = OMIT, @@ -107,6 +120,8 @@ async def send( ---------- query : str + object_with_literal : ATopLevelLiteral + context : typing.Optional[typing.Literal["You're super wise"]] temperature : typing.Optional[float] @@ -125,6 +140,7 @@ async def send( import asyncio from seed import AsyncSeedLiteral + from seed.inlined import ANestedLiteral, ATopLevelLiteral client = AsyncSeedLiteral( base_url="https://yourhost.com/path/to/api", @@ -136,6 +152,9 @@ async def main() -> None: temperature=10.1, context="You're super wise", maybe_context="You're super wise", + object_with_literal=ATopLevelLiteral( + nested_literal=ANestedLiteral(), + ), query="What is the weather today", ) @@ -150,6 +169,9 @@ async def main() -> None: "query": query, "temperature": temperature, "maybeContext": maybe_context, + "objectWithLiteral": convert_and_respect_annotation_metadata( + object_=object_with_literal, annotation=ATopLevelLiteral, direction="write" + ), "prompt": "You are a helpful assistant", "stream": False, "aliasedContext": "You're super wise", diff --git a/seed/python-sdk/literal/no-custom-config/src/seed/inlined/types/__init__.py b/seed/python-sdk/literal/no-custom-config/src/seed/inlined/types/__init__.py index 4df5ab556ac..2fae519363a 100644 --- a/seed/python-sdk/literal/no-custom-config/src/seed/inlined/types/__init__.py +++ b/seed/python-sdk/literal/no-custom-config/src/seed/inlined/types/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +from .a_nested_literal import ANestedLiteral +from .a_top_level_literal import ATopLevelLiteral from .some_aliased_literal import SomeAliasedLiteral -__all__ = ["SomeAliasedLiteral"] +__all__ = ["ANestedLiteral", "ATopLevelLiteral", "SomeAliasedLiteral"] diff --git a/seed/python-sdk/literal/no-custom-config/src/seed/inlined/types/a_nested_literal.py b/seed/python-sdk/literal/no-custom-config/src/seed/inlined/types/a_nested_literal.py new file mode 100644 index 00000000000..60f33114a25 --- /dev/null +++ b/seed/python-sdk/literal/no-custom-config/src/seed/inlined/types/a_nested_literal.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +import typing_extensions +import typing +from ...core.serialization import FieldMetadata +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic + + +class ANestedLiteral(UniversalBaseModel): + my_literal: typing_extensions.Annotated[typing.Literal["How super cool"], FieldMetadata(alias="myLiteral")] = ( + "How super cool" + ) + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/seed/python-sdk/literal/no-custom-config/src/seed/inlined/types/a_top_level_literal.py b/seed/python-sdk/literal/no-custom-config/src/seed/inlined/types/a_top_level_literal.py new file mode 100644 index 00000000000..dfed37d0a15 --- /dev/null +++ b/seed/python-sdk/literal/no-custom-config/src/seed/inlined/types/a_top_level_literal.py @@ -0,0 +1,22 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +import typing_extensions +from .a_nested_literal import ANestedLiteral +from ...core.serialization import FieldMetadata +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing +import pydantic + + +class ATopLevelLiteral(UniversalBaseModel): + nested_literal: typing_extensions.Annotated[ANestedLiteral, FieldMetadata(alias="nestedLiteral")] + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/seed/python-sdk/literal/no-custom-config/tests/test_inlined.py b/seed/python-sdk/literal/no-custom-config/tests/test_inlined.py index 3c57f030e2b..f9fb9491f53 100644 --- a/seed/python-sdk/literal/no-custom-config/tests/test_inlined.py +++ b/seed/python-sdk/literal/no-custom-config/tests/test_inlined.py @@ -3,6 +3,8 @@ from seed import SeedLiteral from seed import AsyncSeedLiteral import typing +from seed.inlined import ATopLevelLiteral +from seed.inlined import ANestedLiteral from .utilities import validate_response @@ -13,6 +15,7 @@ async def test_send(client: SeedLiteral, async_client: AsyncSeedLiteral) -> None temperature=10.1, context="You're super wise", maybe_context="You're super wise", + object_with_literal=ATopLevelLiteral(nested_literal=ANestedLiteral()), query="What is the weather today", ) validate_response(response, expected_response, expected_types) @@ -21,6 +24,7 @@ async def test_send(client: SeedLiteral, async_client: AsyncSeedLiteral) -> None temperature=10.1, context="You're super wise", maybe_context="You're super wise", + object_with_literal=ATopLevelLiteral(nested_literal=ANestedLiteral()), query="What is the weather today", ) validate_response(async_response, expected_response, expected_types) diff --git a/seed/python-sdk/literal/use_typeddict_requests/.mock/definition/inlined.yml b/seed/python-sdk/literal/use_typeddict_requests/.mock/definition/inlined.yml index 33fda38a6d8..c2834c5c50c 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/.mock/definition/inlined.yml +++ b/seed/python-sdk/literal/use_typeddict_requests/.mock/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -32,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: diff --git a/seed/python-sdk/literal/use_typeddict_requests/reference.md b/seed/python-sdk/literal/use_typeddict_requests/reference.md index 7a5389faa93..9bfbb743182 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/reference.md +++ b/seed/python-sdk/literal/use_typeddict_requests/reference.md @@ -79,6 +79,7 @@ client.inlined.send( temperature=10.1, context="You're super wise", maybe_context="You're super wise", + object_with_literal={"nested_literal": {"my_literal": "How super cool"}}, query="What is the weather today", ) @@ -104,6 +105,14 @@ client.inlined.send(
+**object_with_literal:** `ATopLevelLiteralParams` + +
+
+ +
+
+ **context:** `typing.Optional[typing.Literal["You're super wise"]]`
diff --git a/seed/python-sdk/literal/use_typeddict_requests/snippet-templates.json b/seed/python-sdk/literal/use_typeddict_requests/snippet-templates.json index b8a0dca0d82..99c5725ea76 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/snippet-templates.json +++ b/seed/python-sdk/literal/use_typeddict_requests/snippet-templates.json @@ -147,6 +147,29 @@ ], "type": "generic" } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "object_with_literal={\n\t\t$FERN_INPUT\n\t}", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "\"nested_literal\": {\n\t\t\t$FERN_INPUT\n\t\t}", + "templateInputs": [], + "inputDelimiter": ",\n\t\t\t", + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t", + "type": "generic" + } } ], "inputDelimiter": ",\n\t", @@ -202,6 +225,29 @@ ], "type": "generic" } + }, + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "object_with_literal={\n\t\t$FERN_INPUT\n\t}", + "templateInputs": [ + { + "type": "template", + "value": { + "imports": [], + "isOptional": true, + "templateString": "\"nested_literal\": {\n\t\t\t$FERN_INPUT\n\t\t}", + "templateInputs": [], + "inputDelimiter": ",\n\t\t\t", + "type": "generic" + } + } + ], + "inputDelimiter": ",\n\t\t", + "type": "generic" + } } ], "inputDelimiter": ",\n\t", diff --git a/seed/python-sdk/literal/use_typeddict_requests/snippet.json b/seed/python-sdk/literal/use_typeddict_requests/snippet.json index 967430dbd5f..fd8489d20d9 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/snippet.json +++ b/seed/python-sdk/literal/use_typeddict_requests/snippet.json @@ -22,8 +22,8 @@ "identifier_override": "endpoint_inlined.send" }, "snippet": { - "sync_client": "from seed import SeedLiteral\n\nclient = SeedLiteral(\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.inlined.send(\n temperature=10.1,\n context=\"You're super wise\",\n maybe_context=\"You're super wise\",\n query=\"What is the weather today\",\n)\n", - "async_client": "import asyncio\n\nfrom seed import AsyncSeedLiteral\n\nclient = AsyncSeedLiteral(\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.inlined.send(\n temperature=10.1,\n context=\"You're super wise\",\n maybe_context=\"You're super wise\",\n query=\"What is the weather today\",\n )\n\n\nasyncio.run(main())\n", + "sync_client": "from seed import SeedLiteral\n\nclient = SeedLiteral(\n base_url=\"https://yourhost.com/path/to/api\",\n)\nclient.inlined.send(\n temperature=10.1,\n context=\"You're super wise\",\n maybe_context=\"You're super wise\",\n object_with_literal={\"nested_literal\": {\"my_literal\": \"How super cool\"}},\n query=\"What is the weather today\",\n)\n", + "async_client": "import asyncio\n\nfrom seed import AsyncSeedLiteral\n\nclient = AsyncSeedLiteral(\n base_url=\"https://yourhost.com/path/to/api\",\n)\n\n\nasync def main() -> None:\n await client.inlined.send(\n temperature=10.1,\n context=\"You're super wise\",\n maybe_context=\"You're super wise\",\n object_with_literal={\n \"nested_literal\": {\"my_literal\": \"How super cool\"}\n },\n query=\"What is the weather today\",\n )\n\n\nasyncio.run(main())\n", "type": "python" } }, diff --git a/seed/python-sdk/literal/use_typeddict_requests/src/seed/__init__.py b/seed/python-sdk/literal/use_typeddict_requests/src/seed/__init__.py index ce19db8fa34..9cc02be7f8b 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/src/seed/__init__.py +++ b/seed/python-sdk/literal/use_typeddict_requests/src/seed/__init__.py @@ -3,12 +3,16 @@ from .types import SendResponse from . import headers, inlined, path, query, reference from .client import AsyncSeedLiteral, SeedLiteral -from .inlined import SomeAliasedLiteral +from .inlined import ANestedLiteral, ANestedLiteralParams, ATopLevelLiteral, ATopLevelLiteralParams, SomeAliasedLiteral from .reference import SendRequest, SendRequestParams, SomeLiteral from .requests import SendResponseParams from .version import __version__ __all__ = [ + "ANestedLiteral", + "ANestedLiteralParams", + "ATopLevelLiteral", + "ATopLevelLiteralParams", "AsyncSeedLiteral", "SeedLiteral", "SendRequest", 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") diff --git a/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/__init__.py b/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/__init__.py index d8507b68c37..2dfa51fa23a 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/__init__.py +++ b/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/__init__.py @@ -1,5 +1,6 @@ # This file was auto-generated by Fern from our API Definition. -from .types import SomeAliasedLiteral +from .types import ANestedLiteral, ATopLevelLiteral, SomeAliasedLiteral +from .requests import ANestedLiteralParams, ATopLevelLiteralParams -__all__ = ["SomeAliasedLiteral"] +__all__ = ["ANestedLiteral", "ANestedLiteralParams", "ATopLevelLiteral", "ATopLevelLiteralParams", "SomeAliasedLiteral"] diff --git a/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/client.py b/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/client.py index 62a0c87c7f3..47675717522 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/client.py +++ b/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/client.py @@ -2,9 +2,11 @@ import typing from ..core.client_wrapper import SyncClientWrapper +from .requests.a_top_level_literal import ATopLevelLiteralParams from .types.some_aliased_literal import SomeAliasedLiteral from ..core.request_options import RequestOptions from ..types.send_response import SendResponse +from ..core.serialization import convert_and_respect_annotation_metadata from ..core.pydantic_utilities import parse_obj_as from json.decoder import JSONDecodeError from ..core.api_error import ApiError @@ -22,6 +24,7 @@ def send( self, *, query: str, + object_with_literal: ATopLevelLiteralParams, context: typing.Optional[typing.Literal["You're super wise"]] = OMIT, temperature: typing.Optional[float] = OMIT, maybe_context: typing.Optional[SomeAliasedLiteral] = OMIT, @@ -32,6 +35,8 @@ def send( ---------- query : str + object_with_literal : ATopLevelLiteralParams + context : typing.Optional[typing.Literal["You're super wise"]] temperature : typing.Optional[float] @@ -56,6 +61,7 @@ def send( temperature=10.1, context="You're super wise", maybe_context="You're super wise", + object_with_literal={"nested_literal": {"my_literal": "How super cool"}}, query="What is the weather today", ) """ @@ -67,6 +73,9 @@ def send( "query": query, "temperature": temperature, "maybeContext": maybe_context, + "objectWithLiteral": convert_and_respect_annotation_metadata( + object_=object_with_literal, annotation=ATopLevelLiteralParams, direction="write" + ), "prompt": "You are a helpful assistant", "stream": False, "aliasedContext": "You're super wise", @@ -97,6 +106,7 @@ async def send( self, *, query: str, + object_with_literal: ATopLevelLiteralParams, context: typing.Optional[typing.Literal["You're super wise"]] = OMIT, temperature: typing.Optional[float] = OMIT, maybe_context: typing.Optional[SomeAliasedLiteral] = OMIT, @@ -107,6 +117,8 @@ async def send( ---------- query : str + object_with_literal : ATopLevelLiteralParams + context : typing.Optional[typing.Literal["You're super wise"]] temperature : typing.Optional[float] @@ -136,6 +148,9 @@ async def main() -> None: temperature=10.1, context="You're super wise", maybe_context="You're super wise", + object_with_literal={ + "nested_literal": {"my_literal": "How super cool"} + }, query="What is the weather today", ) @@ -150,6 +165,9 @@ async def main() -> None: "query": query, "temperature": temperature, "maybeContext": maybe_context, + "objectWithLiteral": convert_and_respect_annotation_metadata( + object_=object_with_literal, annotation=ATopLevelLiteralParams, direction="write" + ), "prompt": "You are a helpful assistant", "stream": False, "aliasedContext": "You're super wise", diff --git a/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/requests/__init__.py b/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/requests/__init__.py new file mode 100644 index 00000000000..a92f0ccd811 --- /dev/null +++ b/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/requests/__init__.py @@ -0,0 +1,6 @@ +# This file was auto-generated by Fern from our API Definition. + +from .a_nested_literal import ANestedLiteralParams +from .a_top_level_literal import ATopLevelLiteralParams + +__all__ = ["ANestedLiteralParams", "ATopLevelLiteralParams"] diff --git a/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/requests/a_nested_literal.py b/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/requests/a_nested_literal.py new file mode 100644 index 00000000000..848dcbea43e --- /dev/null +++ b/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/requests/a_nested_literal.py @@ -0,0 +1,10 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing_extensions +import typing_extensions +import typing +from ...core.serialization import FieldMetadata + + +class ANestedLiteralParams(typing_extensions.TypedDict): + my_literal: typing_extensions.Annotated[typing.Literal["How super cool"], FieldMetadata(alias="myLiteral")] diff --git a/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/requests/a_top_level_literal.py b/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/requests/a_top_level_literal.py new file mode 100644 index 00000000000..105019c0a55 --- /dev/null +++ b/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/requests/a_top_level_literal.py @@ -0,0 +1,10 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing_extensions +import typing_extensions +from .a_nested_literal import ANestedLiteralParams +from ...core.serialization import FieldMetadata + + +class ATopLevelLiteralParams(typing_extensions.TypedDict): + nested_literal: typing_extensions.Annotated[ANestedLiteralParams, FieldMetadata(alias="nestedLiteral")] diff --git a/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/types/__init__.py b/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/types/__init__.py index 4df5ab556ac..2fae519363a 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/types/__init__.py +++ b/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/types/__init__.py @@ -1,5 +1,7 @@ # This file was auto-generated by Fern from our API Definition. +from .a_nested_literal import ANestedLiteral +from .a_top_level_literal import ATopLevelLiteral from .some_aliased_literal import SomeAliasedLiteral -__all__ = ["SomeAliasedLiteral"] +__all__ = ["ANestedLiteral", "ATopLevelLiteral", "SomeAliasedLiteral"] diff --git a/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/types/a_nested_literal.py b/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/types/a_nested_literal.py new file mode 100644 index 00000000000..60f33114a25 --- /dev/null +++ b/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/types/a_nested_literal.py @@ -0,0 +1,23 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +import typing_extensions +import typing +from ...core.serialization import FieldMetadata +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import pydantic + + +class ANestedLiteral(UniversalBaseModel): + my_literal: typing_extensions.Annotated[typing.Literal["How super cool"], FieldMetadata(alias="myLiteral")] = ( + "How super cool" + ) + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/types/a_top_level_literal.py b/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/types/a_top_level_literal.py new file mode 100644 index 00000000000..dfed37d0a15 --- /dev/null +++ b/seed/python-sdk/literal/use_typeddict_requests/src/seed/inlined/types/a_top_level_literal.py @@ -0,0 +1,22 @@ +# This file was auto-generated by Fern from our API Definition. + +from ...core.pydantic_utilities import UniversalBaseModel +import typing_extensions +from .a_nested_literal import ANestedLiteral +from ...core.serialization import FieldMetadata +from ...core.pydantic_utilities import IS_PYDANTIC_V2 +import typing +import pydantic + + +class ATopLevelLiteral(UniversalBaseModel): + nested_literal: typing_extensions.Annotated[ANestedLiteral, FieldMetadata(alias="nestedLiteral")] + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/seed/python-sdk/literal/use_typeddict_requests/tests/test_inlined.py b/seed/python-sdk/literal/use_typeddict_requests/tests/test_inlined.py index 3c57f030e2b..cb96de208ef 100644 --- a/seed/python-sdk/literal/use_typeddict_requests/tests/test_inlined.py +++ b/seed/python-sdk/literal/use_typeddict_requests/tests/test_inlined.py @@ -13,6 +13,7 @@ async def test_send(client: SeedLiteral, async_client: AsyncSeedLiteral) -> None temperature=10.1, context="You're super wise", maybe_context="You're super wise", + object_with_literal={"nested_literal": {"my_literal": "How super cool"}}, query="What is the weather today", ) validate_response(response, expected_response, expected_types) @@ -21,6 +22,7 @@ async def test_send(client: SeedLiteral, async_client: AsyncSeedLiteral) -> None temperature=10.1, context="You're super wise", maybe_context="You're super wise", + object_with_literal={"nested_literal": {"my_literal": "How super cool"}}, query="What is the weather today", ) validate_response(async_response, expected_response, expected_types) 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/object/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/object/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 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 @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/version/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/version/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") 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 41cc0b621dd..eb2eaf707fd 100644 --- a/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py @@ -138,14 +138,14 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: if default != None: _fields_set.add(name) - kwargs_with_defaults_exclude_unset: typing.Any = { + kwargs_with_defaults_exclude_unset_include_fields: typing.Any = { "by_alias": True, "exclude_unset": True, "include": _fields_set, **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") diff --git a/seed/ruby-model/literal/.mock/definition/inlined.yml b/seed/ruby-model/literal/.mock/definition/inlined.yml index 33fda38a6d8..c2834c5c50c 100644 --- a/seed/ruby-model/literal/.mock/definition/inlined.yml +++ b/seed/ruby-model/literal/.mock/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -32,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: diff --git a/seed/ruby-model/literal/lib/seed_literal_client.rb b/seed/ruby-model/literal/lib/seed_literal_client.rb index 0cb11241f3f..0d197194aa4 100644 --- a/seed/ruby-model/literal/lib/seed_literal_client.rb +++ b/seed/ruby-model/literal/lib/seed_literal_client.rb @@ -2,5 +2,7 @@ require_relative "seed_literal_client/types/send_response" require_relative "seed_literal_client/inlined/types/some_aliased_literal" +require_relative "seed_literal_client/inlined/types/a_top_level_literal" +require_relative "seed_literal_client/inlined/types/a_nested_literal" require_relative "seed_literal_client/reference/types/send_request" require_relative "seed_literal_client/reference/types/some_literal" diff --git a/seed/ruby-model/literal/lib/seed_literal_client/inlined/types/a_nested_literal.rb b/seed/ruby-model/literal/lib/seed_literal_client/inlined/types/a_nested_literal.rb new file mode 100644 index 00000000000..4ad6b907c81 --- /dev/null +++ b/seed/ruby-model/literal/lib/seed_literal_client/inlined/types/a_nested_literal.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +require "ostruct" +require "json" + +module SeedLiteralClient + class Inlined + class ANestedLiteral + # @return [String] + attr_reader :my_literal + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param my_literal [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [SeedLiteralClient::Inlined::ANestedLiteral] + def initialize(my_literal:, additional_properties: nil) + @my_literal = my_literal + @additional_properties = additional_properties + @_field_set = { "myLiteral": my_literal } + end + + # Deserialize a JSON object to an instance of ANestedLiteral + # + # @param json_object [String] + # @return [SeedLiteralClient::Inlined::ANestedLiteral] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + my_literal = parsed_json["myLiteral"] + new(my_literal: my_literal, additional_properties: struct) + end + + # Serialize an instance of ANestedLiteral to a JSON object + # + # @return [String] + def to_json(*_args) + @_field_set&.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given + # hash and check each fields type against the current object's property + # definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.my_literal.is_a?(String) != false || raise("Passed value for field obj.my_literal is not the expected type, validation failed.") + end + end + end +end diff --git a/seed/ruby-model/literal/lib/seed_literal_client/inlined/types/a_top_level_literal.rb b/seed/ruby-model/literal/lib/seed_literal_client/inlined/types/a_top_level_literal.rb new file mode 100644 index 00000000000..a9a7a461c0c --- /dev/null +++ b/seed/ruby-model/literal/lib/seed_literal_client/inlined/types/a_top_level_literal.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +require_relative "a_nested_literal" +require "ostruct" +require "json" + +module SeedLiteralClient + class Inlined + class ATopLevelLiteral + # @return [SeedLiteralClient::Inlined::ANestedLiteral] + attr_reader :nested_literal + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param nested_literal [SeedLiteralClient::Inlined::ANestedLiteral] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [SeedLiteralClient::Inlined::ATopLevelLiteral] + def initialize(nested_literal:, additional_properties: nil) + @nested_literal = nested_literal + @additional_properties = additional_properties + @_field_set = { "nestedLiteral": nested_literal } + end + + # Deserialize a JSON object to an instance of ATopLevelLiteral + # + # @param json_object [String] + # @return [SeedLiteralClient::Inlined::ATopLevelLiteral] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + if parsed_json["nestedLiteral"].nil? + nested_literal = nil + else + nested_literal = parsed_json["nestedLiteral"].to_json + nested_literal = SeedLiteralClient::Inlined::ANestedLiteral.from_json(json_object: nested_literal) + end + new(nested_literal: nested_literal, additional_properties: struct) + end + + # Serialize an instance of ATopLevelLiteral to a JSON object + # + # @return [String] + def to_json(*_args) + @_field_set&.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given + # hash and check each fields type against the current object's property + # definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + SeedLiteralClient::Inlined::ANestedLiteral.validate_raw(obj: obj.nested_literal) + end + end + end +end diff --git a/seed/ruby-sdk/literal/.mock/definition/inlined.yml b/seed/ruby-sdk/literal/.mock/definition/inlined.yml index 33fda38a6d8..c2834c5c50c 100644 --- a/seed/ruby-sdk/literal/.mock/definition/inlined.yml +++ b/seed/ruby-sdk/literal/.mock/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -32,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: diff --git a/seed/ruby-sdk/literal/fern_literal.gemspec b/seed/ruby-sdk/literal/fern_literal.gemspec index 4cc0a0bc1b0..4ea948062d8 100644 --- a/seed/ruby-sdk/literal/fern_literal.gemspec +++ b/seed/ruby-sdk/literal/fern_literal.gemspec @@ -18,8 +18,4 @@ Gem::Specification.new do |spec| spec.bindir = "exe" spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency "async-http-faraday", ">= 0.0", "< 1.0" - spec.add_dependency "faraday", ">= 1.10", "< 3.0" - spec.add_dependency "faraday-net_http", ">= 1.0", "< 4.0" - spec.add_dependency "faraday-retry", ">= 1.0", "< 3.0" end diff --git a/seed/ruby-sdk/literal/lib/fern_literal.rb b/seed/ruby-sdk/literal/lib/fern_literal.rb index 5f686514ee7..1f5189a4019 100644 --- a/seed/ruby-sdk/literal/lib/fern_literal.rb +++ b/seed/ruby-sdk/literal/lib/fern_literal.rb @@ -1,79 +1,8 @@ # frozen_string_literal: true -require_relative "types_export" -require_relative "requests" -require_relative "fern_literal/headers/client" -require_relative "fern_literal/inlined/client" -require_relative "fern_literal/path/client" -require_relative "fern_literal/query/client" -require_relative "fern_literal/reference/client" - -module SeedLiteralClient - class Client - # @return [SeedLiteralClient::HeadersClient] - attr_reader :headers - # @return [SeedLiteralClient::InlinedClient] - attr_reader :inlined - # @return [SeedLiteralClient::PathClient] - attr_reader :path - # @return [SeedLiteralClient::QueryClient] - attr_reader :query - # @return [SeedLiteralClient::ReferenceClient] - attr_reader :reference - - # @param base_url [String] - # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. - # @param timeout_in_seconds [Long] - # @param version [String] - # @param audit_logging [Boolean] - # @return [SeedLiteralClient::Client] - def initialize(version:, audit_logging:, base_url: nil, max_retries: nil, timeout_in_seconds: nil) - @request_client = SeedLiteralClient::RequestClient.new( - base_url: base_url, - max_retries: max_retries, - timeout_in_seconds: timeout_in_seconds, - version: version, - audit_logging: audit_logging - ) - @headers = SeedLiteralClient::HeadersClient.new(request_client: @request_client) - @inlined = SeedLiteralClient::InlinedClient.new(request_client: @request_client) - @path = SeedLiteralClient::PathClient.new(request_client: @request_client) - @query = SeedLiteralClient::QueryClient.new(request_client: @request_client) - @reference = SeedLiteralClient::ReferenceClient.new(request_client: @request_client) - end - end - - class AsyncClient - # @return [SeedLiteralClient::AsyncHeadersClient] - attr_reader :headers - # @return [SeedLiteralClient::AsyncInlinedClient] - attr_reader :inlined - # @return [SeedLiteralClient::AsyncPathClient] - attr_reader :path - # @return [SeedLiteralClient::AsyncQueryClient] - attr_reader :query - # @return [SeedLiteralClient::AsyncReferenceClient] - attr_reader :reference - - # @param base_url [String] - # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. - # @param timeout_in_seconds [Long] - # @param version [String] - # @param audit_logging [Boolean] - # @return [SeedLiteralClient::AsyncClient] - def initialize(version:, audit_logging:, base_url: nil, max_retries: nil, timeout_in_seconds: nil) - @async_request_client = SeedLiteralClient::AsyncRequestClient.new( - base_url: base_url, - max_retries: max_retries, - timeout_in_seconds: timeout_in_seconds, - version: version, - audit_logging: audit_logging - ) - @headers = SeedLiteralClient::AsyncHeadersClient.new(request_client: @async_request_client) - @inlined = SeedLiteralClient::AsyncInlinedClient.new(request_client: @async_request_client) - @path = SeedLiteralClient::AsyncPathClient.new(request_client: @async_request_client) - @query = SeedLiteralClient::AsyncQueryClient.new(request_client: @async_request_client) - @reference = SeedLiteralClient::AsyncReferenceClient.new(request_client: @async_request_client) - end - end -end +require_relative "fern_literal/types/send_response" +require_relative "fern_literal/inlined/types/some_aliased_literal" +require_relative "fern_literal/inlined/types/a_top_level_literal" +require_relative "fern_literal/inlined/types/a_nested_literal" +require_relative "fern_literal/reference/types/send_request" +require_relative "fern_literal/reference/types/some_literal" diff --git a/seed/ruby-sdk/literal/lib/fern_literal/headers/client.rb b/seed/ruby-sdk/literal/lib/fern_literal/headers/client.rb deleted file mode 100644 index 7e85851d2aa..00000000000 --- a/seed/ruby-sdk/literal/lib/fern_literal/headers/client.rb +++ /dev/null @@ -1,99 +0,0 @@ -# frozen_string_literal: true - -require_relative "../../requests" -require_relative "../types/send_response" -require "async" - -module SeedLiteralClient - class HeadersClient - # @return [SeedLiteralClient::RequestClient] - attr_reader :request_client - - # @param request_client [SeedLiteralClient::RequestClient] - # @return [SeedLiteralClient::HeadersClient] - def initialize(request_client:) - @request_client = request_client - end - - # @param query [String] - # @param request_options [SeedLiteralClient::RequestOptions] - # @return [SeedLiteralClient::SendResponse] - # @example - # literal = SeedLiteralClient::Client.new( - # base_url: "https://api.example.com", - # version: "Version", - # audit_logging: "AuditLogging" - # ) - # literal.headers.send(query: "What is the weather today") - def send(query:, request_options: nil) - response = @request_client.conn.post do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? - req.headers["X-API-Version"] = request_options.version unless request_options&.version.nil? - unless request_options&.audit_logging.nil? - req.headers["X-API-Enable-Audit-Logging"] = - request_options.audit_logging - end - req.headers = { - **(req.headers || {}), - **@request_client.get_headers, - **(request_options&.additional_headers || {}), - "X-Endpoint-Version": "02-12-2024", - "X-Async": true - }.compact - unless request_options.nil? || request_options&.additional_query_parameters.nil? - req.params = { **(request_options&.additional_query_parameters || {}) }.compact - end - req.body = { **(request_options&.additional_body_parameters || {}), query: query }.compact - req.url "#{@request_client.get_url(request_options: request_options)}/headers" - end - SeedLiteralClient::SendResponse.from_json(json_object: response.body) - end - end - - class AsyncHeadersClient - # @return [SeedLiteralClient::AsyncRequestClient] - attr_reader :request_client - - # @param request_client [SeedLiteralClient::AsyncRequestClient] - # @return [SeedLiteralClient::AsyncHeadersClient] - def initialize(request_client:) - @request_client = request_client - end - - # @param query [String] - # @param request_options [SeedLiteralClient::RequestOptions] - # @return [SeedLiteralClient::SendResponse] - # @example - # literal = SeedLiteralClient::Client.new( - # base_url: "https://api.example.com", - # version: "Version", - # audit_logging: "AuditLogging" - # ) - # literal.headers.send(query: "What is the weather today") - def send(query:, request_options: nil) - Async do - response = @request_client.conn.post do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? - req.headers["X-API-Version"] = request_options.version unless request_options&.version.nil? - unless request_options&.audit_logging.nil? - req.headers["X-API-Enable-Audit-Logging"] = - request_options.audit_logging - end - req.headers = { - **(req.headers || {}), - **@request_client.get_headers, - **(request_options&.additional_headers || {}), - "X-Endpoint-Version": "02-12-2024", - "X-Async": true - }.compact - unless request_options.nil? || request_options&.additional_query_parameters.nil? - req.params = { **(request_options&.additional_query_parameters || {}) }.compact - end - req.body = { **(request_options&.additional_body_parameters || {}), query: query }.compact - req.url "#{@request_client.get_url(request_options: request_options)}/headers" - end - SeedLiteralClient::SendResponse.from_json(json_object: response.body) - end - end - end -end diff --git a/seed/ruby-sdk/literal/lib/fern_literal/inlined/client.rb b/seed/ruby-sdk/literal/lib/fern_literal/inlined/client.rb deleted file mode 100644 index 63fb8e478a7..00000000000 --- a/seed/ruby-sdk/literal/lib/fern_literal/inlined/client.rb +++ /dev/null @@ -1,130 +0,0 @@ -# frozen_string_literal: true - -require_relative "../../requests" -require_relative "types/some_aliased_literal" -require_relative "../types/send_response" -require "async" - -module SeedLiteralClient - class InlinedClient - # @return [SeedLiteralClient::RequestClient] - attr_reader :request_client - - # @param request_client [SeedLiteralClient::RequestClient] - # @return [SeedLiteralClient::InlinedClient] - def initialize(request_client:) - @request_client = request_client - end - - # @param query [String] - # @param temperature [Float] - # @param aliased_context [SeedLiteralClient::Inlined::SOME_ALIASED_LITERAL] - # @param maybe_context [SeedLiteralClient::Inlined::SOME_ALIASED_LITERAL] - # @param request_options [SeedLiteralClient::RequestOptions] - # @return [SeedLiteralClient::SendResponse] - # @example - # literal = SeedLiteralClient::Client.new( - # base_url: "https://api.example.com", - # version: "Version", - # audit_logging: "AuditLogging" - # ) - # literal.inlined.send( - # query: "What is the weather today", - # temperature: 10.1, - # aliased_context: "You're super wise", - # maybe_context: "You're super wise" - # ) - def send(query:, aliased_context:, temperature: nil, maybe_context: nil, request_options: nil) - response = @request_client.conn.post do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? - req.headers["X-API-Version"] = request_options.version unless request_options&.version.nil? - unless request_options&.audit_logging.nil? - req.headers["X-API-Enable-Audit-Logging"] = - request_options.audit_logging - end - req.headers = { - **(req.headers || {}), - **@request_client.get_headers, - **(request_options&.additional_headers || {}) - }.compact - unless request_options.nil? || request_options&.additional_query_parameters.nil? - req.params = { **(request_options&.additional_query_parameters || {}) }.compact - end - req.body = { - **(request_options&.additional_body_parameters || {}), - "prompt": "You are a helpful assistant", - "context": "You're super wise", - "stream": false, - query: query, - temperature: temperature, - aliasedContext: aliased_context, - maybeContext: maybe_context - }.compact - req.url "#{@request_client.get_url(request_options: request_options)}/inlined" - end - SeedLiteralClient::SendResponse.from_json(json_object: response.body) - end - end - - class AsyncInlinedClient - # @return [SeedLiteralClient::AsyncRequestClient] - attr_reader :request_client - - # @param request_client [SeedLiteralClient::AsyncRequestClient] - # @return [SeedLiteralClient::AsyncInlinedClient] - def initialize(request_client:) - @request_client = request_client - end - - # @param query [String] - # @param temperature [Float] - # @param aliased_context [SeedLiteralClient::Inlined::SOME_ALIASED_LITERAL] - # @param maybe_context [SeedLiteralClient::Inlined::SOME_ALIASED_LITERAL] - # @param request_options [SeedLiteralClient::RequestOptions] - # @return [SeedLiteralClient::SendResponse] - # @example - # literal = SeedLiteralClient::Client.new( - # base_url: "https://api.example.com", - # version: "Version", - # audit_logging: "AuditLogging" - # ) - # literal.inlined.send( - # query: "What is the weather today", - # temperature: 10.1, - # aliased_context: "You're super wise", - # maybe_context: "You're super wise" - # ) - def send(query:, aliased_context:, temperature: nil, maybe_context: nil, request_options: nil) - Async do - response = @request_client.conn.post do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? - req.headers["X-API-Version"] = request_options.version unless request_options&.version.nil? - unless request_options&.audit_logging.nil? - req.headers["X-API-Enable-Audit-Logging"] = - request_options.audit_logging - end - req.headers = { - **(req.headers || {}), - **@request_client.get_headers, - **(request_options&.additional_headers || {}) - }.compact - unless request_options.nil? || request_options&.additional_query_parameters.nil? - req.params = { **(request_options&.additional_query_parameters || {}) }.compact - end - req.body = { - **(request_options&.additional_body_parameters || {}), - "prompt": "You are a helpful assistant", - "context": "You're super wise", - "stream": false, - query: query, - temperature: temperature, - aliasedContext: aliased_context, - maybeContext: maybe_context - }.compact - req.url "#{@request_client.get_url(request_options: request_options)}/inlined" - end - SeedLiteralClient::SendResponse.from_json(json_object: response.body) - end - end - end -end diff --git a/seed/ruby-sdk/literal/lib/fern_literal/inlined/types/a_nested_literal.rb b/seed/ruby-sdk/literal/lib/fern_literal/inlined/types/a_nested_literal.rb new file mode 100644 index 00000000000..4ad6b907c81 --- /dev/null +++ b/seed/ruby-sdk/literal/lib/fern_literal/inlined/types/a_nested_literal.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +require "ostruct" +require "json" + +module SeedLiteralClient + class Inlined + class ANestedLiteral + # @return [String] + attr_reader :my_literal + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param my_literal [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [SeedLiteralClient::Inlined::ANestedLiteral] + def initialize(my_literal:, additional_properties: nil) + @my_literal = my_literal + @additional_properties = additional_properties + @_field_set = { "myLiteral": my_literal } + end + + # Deserialize a JSON object to an instance of ANestedLiteral + # + # @param json_object [String] + # @return [SeedLiteralClient::Inlined::ANestedLiteral] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + my_literal = parsed_json["myLiteral"] + new(my_literal: my_literal, additional_properties: struct) + end + + # Serialize an instance of ANestedLiteral to a JSON object + # + # @return [String] + def to_json(*_args) + @_field_set&.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given + # hash and check each fields type against the current object's property + # definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.my_literal.is_a?(String) != false || raise("Passed value for field obj.my_literal is not the expected type, validation failed.") + end + end + end +end diff --git a/seed/ruby-sdk/literal/lib/fern_literal/inlined/types/a_top_level_literal.rb b/seed/ruby-sdk/literal/lib/fern_literal/inlined/types/a_top_level_literal.rb new file mode 100644 index 00000000000..a9a7a461c0c --- /dev/null +++ b/seed/ruby-sdk/literal/lib/fern_literal/inlined/types/a_top_level_literal.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +require_relative "a_nested_literal" +require "ostruct" +require "json" + +module SeedLiteralClient + class Inlined + class ATopLevelLiteral + # @return [SeedLiteralClient::Inlined::ANestedLiteral] + attr_reader :nested_literal + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param nested_literal [SeedLiteralClient::Inlined::ANestedLiteral] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [SeedLiteralClient::Inlined::ATopLevelLiteral] + def initialize(nested_literal:, additional_properties: nil) + @nested_literal = nested_literal + @additional_properties = additional_properties + @_field_set = { "nestedLiteral": nested_literal } + end + + # Deserialize a JSON object to an instance of ATopLevelLiteral + # + # @param json_object [String] + # @return [SeedLiteralClient::Inlined::ATopLevelLiteral] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + if parsed_json["nestedLiteral"].nil? + nested_literal = nil + else + nested_literal = parsed_json["nestedLiteral"].to_json + nested_literal = SeedLiteralClient::Inlined::ANestedLiteral.from_json(json_object: nested_literal) + end + new(nested_literal: nested_literal, additional_properties: struct) + end + + # Serialize an instance of ATopLevelLiteral to a JSON object + # + # @return [String] + def to_json(*_args) + @_field_set&.to_json + end + + # Leveraged for Union-type generation, validate_raw attempts to parse the given + # hash and check each fields type against the current object's property + # definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + SeedLiteralClient::Inlined::ANestedLiteral.validate_raw(obj: obj.nested_literal) + end + end + end +end diff --git a/seed/ruby-sdk/literal/lib/fern_literal/path/client.rb b/seed/ruby-sdk/literal/lib/fern_literal/path/client.rb deleted file mode 100644 index 22be836cae7..00000000000 --- a/seed/ruby-sdk/literal/lib/fern_literal/path/client.rb +++ /dev/null @@ -1,97 +0,0 @@ -# frozen_string_literal: true - -require_relative "../../requests" -require_relative "../types/send_response" -require "async" - -module SeedLiteralClient - class PathClient - # @return [SeedLiteralClient::RequestClient] - attr_reader :request_client - - # @param request_client [SeedLiteralClient::RequestClient] - # @return [SeedLiteralClient::PathClient] - def initialize(request_client:) - @request_client = request_client - end - - # @param request_options [SeedLiteralClient::RequestOptions] - # @return [SeedLiteralClient::SendResponse] - # @example - # literal = SeedLiteralClient::Client.new( - # base_url: "https://api.example.com", - # version: "Version", - # audit_logging: "AuditLogging" - # ) - # literal.path.send - def send(request_options: nil) - response = @request_client.conn.post do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? - req.headers["X-API-Version"] = request_options.version unless request_options&.version.nil? - unless request_options&.audit_logging.nil? - req.headers["X-API-Enable-Audit-Logging"] = - request_options.audit_logging - end - req.headers = { - **(req.headers || {}), - **@request_client.get_headers, - **(request_options&.additional_headers || {}) - }.compact - unless request_options.nil? || request_options&.additional_query_parameters.nil? - req.params = { **(request_options&.additional_query_parameters || {}) }.compact - end - unless request_options.nil? || request_options&.additional_body_parameters.nil? - req.body = { **(request_options&.additional_body_parameters || {}) }.compact - end - req.url "#{@request_client.get_url(request_options: request_options)}/path/#{id}" - end - SeedLiteralClient::SendResponse.from_json(json_object: response.body) - end - end - - class AsyncPathClient - # @return [SeedLiteralClient::AsyncRequestClient] - attr_reader :request_client - - # @param request_client [SeedLiteralClient::AsyncRequestClient] - # @return [SeedLiteralClient::AsyncPathClient] - def initialize(request_client:) - @request_client = request_client - end - - # @param request_options [SeedLiteralClient::RequestOptions] - # @return [SeedLiteralClient::SendResponse] - # @example - # literal = SeedLiteralClient::Client.new( - # base_url: "https://api.example.com", - # version: "Version", - # audit_logging: "AuditLogging" - # ) - # literal.path.send - def send(request_options: nil) - Async do - response = @request_client.conn.post do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? - req.headers["X-API-Version"] = request_options.version unless request_options&.version.nil? - unless request_options&.audit_logging.nil? - req.headers["X-API-Enable-Audit-Logging"] = - request_options.audit_logging - end - req.headers = { - **(req.headers || {}), - **@request_client.get_headers, - **(request_options&.additional_headers || {}) - }.compact - unless request_options.nil? || request_options&.additional_query_parameters.nil? - req.params = { **(request_options&.additional_query_parameters || {}) }.compact - end - unless request_options.nil? || request_options&.additional_body_parameters.nil? - req.body = { **(request_options&.additional_body_parameters || {}) }.compact - end - req.url "#{@request_client.get_url(request_options: request_options)}/path/#{id}" - end - SeedLiteralClient::SendResponse.from_json(json_object: response.body) - end - end - end -end diff --git a/seed/ruby-sdk/literal/lib/fern_literal/query/client.rb b/seed/ruby-sdk/literal/lib/fern_literal/query/client.rb deleted file mode 100644 index 90666d9c9db..00000000000 --- a/seed/ruby-sdk/literal/lib/fern_literal/query/client.rb +++ /dev/null @@ -1,105 +0,0 @@ -# frozen_string_literal: true - -require_relative "../../requests" -require_relative "../types/send_response" -require "async" - -module SeedLiteralClient - class QueryClient - # @return [SeedLiteralClient::RequestClient] - attr_reader :request_client - - # @param request_client [SeedLiteralClient::RequestClient] - # @return [SeedLiteralClient::QueryClient] - def initialize(request_client:) - @request_client = request_client - end - - # @param query [String] - # @param request_options [SeedLiteralClient::RequestOptions] - # @return [SeedLiteralClient::SendResponse] - # @example - # literal = SeedLiteralClient::Client.new( - # base_url: "https://api.example.com", - # version: "Version", - # audit_logging: "AuditLogging" - # ) - # literal.query.send(query: "What is the weather today") - def send(query:, request_options: nil) - response = @request_client.conn.post do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? - req.headers["X-API-Version"] = request_options.version unless request_options&.version.nil? - unless request_options&.audit_logging.nil? - req.headers["X-API-Enable-Audit-Logging"] = - request_options.audit_logging - end - req.headers = { - **(req.headers || {}), - **@request_client.get_headers, - **(request_options&.additional_headers || {}) - }.compact - req.params = { - **(request_options&.additional_query_parameters || {}), - "prompt": "You are a helpful assistant", - "stream": false, - "query": query - }.compact - unless request_options.nil? || request_options&.additional_body_parameters.nil? - req.body = { **(request_options&.additional_body_parameters || {}) }.compact - end - req.url "#{@request_client.get_url(request_options: request_options)}/query" - end - SeedLiteralClient::SendResponse.from_json(json_object: response.body) - end - end - - class AsyncQueryClient - # @return [SeedLiteralClient::AsyncRequestClient] - attr_reader :request_client - - # @param request_client [SeedLiteralClient::AsyncRequestClient] - # @return [SeedLiteralClient::AsyncQueryClient] - def initialize(request_client:) - @request_client = request_client - end - - # @param query [String] - # @param request_options [SeedLiteralClient::RequestOptions] - # @return [SeedLiteralClient::SendResponse] - # @example - # literal = SeedLiteralClient::Client.new( - # base_url: "https://api.example.com", - # version: "Version", - # audit_logging: "AuditLogging" - # ) - # literal.query.send(query: "What is the weather today") - def send(query:, request_options: nil) - Async do - response = @request_client.conn.post do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? - req.headers["X-API-Version"] = request_options.version unless request_options&.version.nil? - unless request_options&.audit_logging.nil? - req.headers["X-API-Enable-Audit-Logging"] = - request_options.audit_logging - end - req.headers = { - **(req.headers || {}), - **@request_client.get_headers, - **(request_options&.additional_headers || {}) - }.compact - req.params = { - **(request_options&.additional_query_parameters || {}), - "prompt": "You are a helpful assistant", - "stream": false, - "query": query - }.compact - unless request_options.nil? || request_options&.additional_body_parameters.nil? - req.body = { **(request_options&.additional_body_parameters || {}) }.compact - end - req.url "#{@request_client.get_url(request_options: request_options)}/query" - end - SeedLiteralClient::SendResponse.from_json(json_object: response.body) - end - end - end -end diff --git a/seed/ruby-sdk/literal/lib/fern_literal/reference/client.rb b/seed/ruby-sdk/literal/lib/fern_literal/reference/client.rb deleted file mode 100644 index 4edf25fad17..00000000000 --- a/seed/ruby-sdk/literal/lib/fern_literal/reference/client.rb +++ /dev/null @@ -1,106 +0,0 @@ -# frozen_string_literal: true - -require_relative "../../requests" -require_relative "types/send_request" -require_relative "../types/send_response" -require "async" - -module SeedLiteralClient - class ReferenceClient - # @return [SeedLiteralClient::RequestClient] - attr_reader :request_client - - # @param request_client [SeedLiteralClient::RequestClient] - # @return [SeedLiteralClient::ReferenceClient] - def initialize(request_client:) - @request_client = request_client - end - - # @param request [Hash] Request of type SeedLiteralClient::Reference::SendRequest, as a Hash - # * :prompt (String) - # * :query (String) - # * :stream (Boolean) - # * :context (SeedLiteralClient::Reference::SOME_LITERAL) - # * :maybe_context (SeedLiteralClient::Reference::SOME_LITERAL) - # @param request_options [SeedLiteralClient::RequestOptions] - # @return [SeedLiteralClient::SendResponse] - # @example - # literal = SeedLiteralClient::Client.new( - # base_url: "https://api.example.com", - # version: "Version", - # audit_logging: "AuditLogging" - # ) - # literal.reference.send(request: { prompt: "You are a helpful assistant", stream: false, context: "You're super wise", query: "What is the weather today" }) - def send(request:, request_options: nil) - response = @request_client.conn.post do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? - req.headers["X-API-Version"] = request_options.version unless request_options&.version.nil? - unless request_options&.audit_logging.nil? - req.headers["X-API-Enable-Audit-Logging"] = - request_options.audit_logging - end - req.headers = { - **(req.headers || {}), - **@request_client.get_headers, - **(request_options&.additional_headers || {}) - }.compact - unless request_options.nil? || request_options&.additional_query_parameters.nil? - req.params = { **(request_options&.additional_query_parameters || {}) }.compact - end - req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact - req.url "#{@request_client.get_url(request_options: request_options)}/reference" - end - SeedLiteralClient::SendResponse.from_json(json_object: response.body) - end - end - - class AsyncReferenceClient - # @return [SeedLiteralClient::AsyncRequestClient] - attr_reader :request_client - - # @param request_client [SeedLiteralClient::AsyncRequestClient] - # @return [SeedLiteralClient::AsyncReferenceClient] - def initialize(request_client:) - @request_client = request_client - end - - # @param request [Hash] Request of type SeedLiteralClient::Reference::SendRequest, as a Hash - # * :prompt (String) - # * :query (String) - # * :stream (Boolean) - # * :context (SeedLiteralClient::Reference::SOME_LITERAL) - # * :maybe_context (SeedLiteralClient::Reference::SOME_LITERAL) - # @param request_options [SeedLiteralClient::RequestOptions] - # @return [SeedLiteralClient::SendResponse] - # @example - # literal = SeedLiteralClient::Client.new( - # base_url: "https://api.example.com", - # version: "Version", - # audit_logging: "AuditLogging" - # ) - # literal.reference.send(request: { prompt: "You are a helpful assistant", stream: false, context: "You're super wise", query: "What is the weather today" }) - def send(request:, request_options: nil) - Async do - response = @request_client.conn.post do |req| - req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? - req.headers["X-API-Version"] = request_options.version unless request_options&.version.nil? - unless request_options&.audit_logging.nil? - req.headers["X-API-Enable-Audit-Logging"] = - request_options.audit_logging - end - req.headers = { - **(req.headers || {}), - **@request_client.get_headers, - **(request_options&.additional_headers || {}) - }.compact - unless request_options.nil? || request_options&.additional_query_parameters.nil? - req.params = { **(request_options&.additional_query_parameters || {}) }.compact - end - req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact - req.url "#{@request_client.get_url(request_options: request_options)}/reference" - end - SeedLiteralClient::SendResponse.from_json(json_object: response.body) - end - end - end -end diff --git a/seed/ruby-sdk/literal/lib/requests.rb b/seed/ruby-sdk/literal/lib/requests.rb deleted file mode 100644 index 78bcb4f9a52..00000000000 --- a/seed/ruby-sdk/literal/lib/requests.rb +++ /dev/null @@ -1,158 +0,0 @@ -# frozen_string_literal: true - -require "faraday" -require "faraday/retry" -require "async/http/faraday" - -module SeedLiteralClient - class RequestClient - # @return [Faraday] - attr_reader :conn - # @return [String] - attr_reader :base_url - - # @param base_url [String] - # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. - # @param timeout_in_seconds [Long] - # @param version [String] - # @param audit_logging [Boolean] - # @return [SeedLiteralClient::RequestClient] - def initialize(version:, audit_logging:, base_url: nil, max_retries: nil, timeout_in_seconds: nil) - @base_url = base_url - @headers = {} - @headers["X-API-Version"] = version unless version.nil? - @headers["X-API-Enable-Audit-Logging"] = audit_logging unless audit_logging.nil? - @conn = Faraday.new(headers: @headers) do |faraday| - faraday.request :json - faraday.response :raise_error, include_request: true - faraday.request :retry, { max: max_retries } unless max_retries.nil? - faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? - end - end - - # @param request_options [SeedLiteralClient::RequestOptions] - # @return [String] - def get_url(request_options: nil) - request_options&.base_url || @base_url - end - - # @return [Hash{String => String}] - def get_headers - { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "fern_literal", "X-Fern-SDK-Version": "0.0.1" } - end - end - - class AsyncRequestClient - # @return [Faraday] - attr_reader :conn - # @return [String] - attr_reader :base_url - - # @param base_url [String] - # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. - # @param timeout_in_seconds [Long] - # @param version [String] - # @param audit_logging [Boolean] - # @return [SeedLiteralClient::AsyncRequestClient] - def initialize(version:, audit_logging:, base_url: nil, max_retries: nil, timeout_in_seconds: nil) - @base_url = base_url - @headers = {} - @headers["X-API-Version"] = version unless version.nil? - @headers["X-API-Enable-Audit-Logging"] = audit_logging unless audit_logging.nil? - @conn = Faraday.new(headers: @headers) do |faraday| - faraday.request :json - faraday.response :raise_error, include_request: true - faraday.adapter :async_http - faraday.request :retry, { max: max_retries } unless max_retries.nil? - faraday.options.timeout = timeout_in_seconds unless timeout_in_seconds.nil? - end - end - - # @param request_options [SeedLiteralClient::RequestOptions] - # @return [String] - def get_url(request_options: nil) - request_options&.base_url || @base_url - end - - # @return [Hash{String => String}] - def get_headers - { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "fern_literal", "X-Fern-SDK-Version": "0.0.1" } - end - end - - # Additional options for request-specific configuration when calling APIs via the - # SDK. - class RequestOptions - # @return [String] - attr_reader :base_url - # @return [String] - attr_reader :version - # @return [Boolean] - attr_reader :audit_logging - # @return [Hash{String => Object}] - attr_reader :additional_headers - # @return [Hash{String => Object}] - attr_reader :additional_query_parameters - # @return [Hash{String => Object}] - attr_reader :additional_body_parameters - # @return [Long] - attr_reader :timeout_in_seconds - - # @param base_url [String] - # @param version [String] - # @param audit_logging [Boolean] - # @param additional_headers [Hash{String => Object}] - # @param additional_query_parameters [Hash{String => Object}] - # @param additional_body_parameters [Hash{String => Object}] - # @param timeout_in_seconds [Long] - # @return [SeedLiteralClient::RequestOptions] - def initialize(base_url: nil, version: nil, audit_logging: nil, additional_headers: nil, - additional_query_parameters: nil, additional_body_parameters: nil, timeout_in_seconds: nil) - @base_url = base_url - @version = version - @audit_logging = audit_logging - @additional_headers = additional_headers - @additional_query_parameters = additional_query_parameters - @additional_body_parameters = additional_body_parameters - @timeout_in_seconds = timeout_in_seconds - end - end - - # Additional options for request-specific configuration when calling APIs via the - # SDK. - class IdempotencyRequestOptions - # @return [String] - attr_reader :base_url - # @return [String] - attr_reader :version - # @return [Boolean] - attr_reader :audit_logging - # @return [Hash{String => Object}] - attr_reader :additional_headers - # @return [Hash{String => Object}] - attr_reader :additional_query_parameters - # @return [Hash{String => Object}] - attr_reader :additional_body_parameters - # @return [Long] - attr_reader :timeout_in_seconds - - # @param base_url [String] - # @param version [String] - # @param audit_logging [Boolean] - # @param additional_headers [Hash{String => Object}] - # @param additional_query_parameters [Hash{String => Object}] - # @param additional_body_parameters [Hash{String => Object}] - # @param timeout_in_seconds [Long] - # @return [SeedLiteralClient::IdempotencyRequestOptions] - def initialize(base_url: nil, version: nil, audit_logging: nil, additional_headers: nil, - additional_query_parameters: nil, additional_body_parameters: nil, timeout_in_seconds: nil) - @base_url = base_url - @version = version - @audit_logging = audit_logging - @additional_headers = additional_headers - @additional_query_parameters = additional_query_parameters - @additional_body_parameters = additional_body_parameters - @timeout_in_seconds = timeout_in_seconds - end - end -end diff --git a/seed/ruby-sdk/literal/lib/types_export.rb b/seed/ruby-sdk/literal/lib/types_export.rb deleted file mode 100644 index 8fff924c3cb..00000000000 --- a/seed/ruby-sdk/literal/lib/types_export.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -require_relative "fern_literal/types/send_response" -require_relative "fern_literal/inlined/types/some_aliased_literal" -require_relative "fern_literal/reference/types/send_request" -require_relative "fern_literal/reference/types/some_literal" diff --git a/seed/ruby-sdk/literal/snippet.json b/seed/ruby-sdk/literal/snippet.json index 0058c6f3b27..e69de29bb2d 100644 --- a/seed/ruby-sdk/literal/snippet.json +++ b/seed/ruby-sdk/literal/snippet.json @@ -1,115 +0,0 @@ -{ - "endpoints": [ - { - "id": { - "path": "/headers", - "method": "POST", - "identifierOverride": "endpoint_headers.send" - }, - "snippet": { - "client": "require \"fern_literal\"\n\nliteral = SeedLiteralClient::Client.new(\n base_url: \"https://api.example.com\",\n version: \"Version\",\n audit_logging: \"AuditLogging\"\n)\nliteral.headers.send(query: \"What is the weather today\")", - "type": "ruby" - } - }, - { - "id": { - "path": "/headers", - "method": "POST", - "identifierOverride": "endpoint_headers.send" - }, - "snippet": { - "client": "require \"fern_literal\"\n\nliteral = SeedLiteralClient::Client.new(\n base_url: \"https://api.example.com\",\n version: \"Version\",\n audit_logging: \"AuditLogging\"\n)\nliteral.headers.send(query: \"What is the weather today\")", - "type": "ruby" - } - }, - { - "id": { - "path": "/inlined", - "method": "POST", - "identifierOverride": "endpoint_inlined.send" - }, - "snippet": { - "client": "require \"fern_literal\"\n\nliteral = SeedLiteralClient::Client.new(\n base_url: \"https://api.example.com\",\n version: \"Version\",\n audit_logging: \"AuditLogging\"\n)\nliteral.inlined.send(\n query: \"What is the weather today\",\n temperature: 10.1,\n aliased_context: \"You're super wise\",\n maybe_context: \"You're super wise\"\n)", - "type": "ruby" - } - }, - { - "id": { - "path": "/inlined", - "method": "POST", - "identifierOverride": "endpoint_inlined.send" - }, - "snippet": { - "client": "require \"fern_literal\"\n\nliteral = SeedLiteralClient::Client.new(\n base_url: \"https://api.example.com\",\n version: \"Version\",\n audit_logging: \"AuditLogging\"\n)\nliteral.inlined.send(\n query: \"What is the weather today\",\n temperature: 10.1,\n aliased_context: \"You're super wise\",\n maybe_context: \"You're super wise\"\n)", - "type": "ruby" - } - }, - { - "id": { - "path": "/path/{id}", - "method": "POST", - "identifierOverride": "endpoint_path.send" - }, - "snippet": { - "client": "require \"fern_literal\"\n\nliteral = SeedLiteralClient::Client.new(\n base_url: \"https://api.example.com\",\n version: \"Version\",\n audit_logging: \"AuditLogging\"\n)\nliteral.path.send", - "type": "ruby" - } - }, - { - "id": { - "path": "/path/{id}", - "method": "POST", - "identifierOverride": "endpoint_path.send" - }, - "snippet": { - "client": "require \"fern_literal\"\n\nliteral = SeedLiteralClient::Client.new(\n base_url: \"https://api.example.com\",\n version: \"Version\",\n audit_logging: \"AuditLogging\"\n)\nliteral.path.send", - "type": "ruby" - } - }, - { - "id": { - "path": "/query", - "method": "POST", - "identifierOverride": "endpoint_query.send" - }, - "snippet": { - "client": "require \"fern_literal\"\n\nliteral = SeedLiteralClient::Client.new(\n base_url: \"https://api.example.com\",\n version: \"Version\",\n audit_logging: \"AuditLogging\"\n)\nliteral.query.send(query: \"What is the weather today\")", - "type": "ruby" - } - }, - { - "id": { - "path": "/query", - "method": "POST", - "identifierOverride": "endpoint_query.send" - }, - "snippet": { - "client": "require \"fern_literal\"\n\nliteral = SeedLiteralClient::Client.new(\n base_url: \"https://api.example.com\",\n version: \"Version\",\n audit_logging: \"AuditLogging\"\n)\nliteral.query.send(query: \"What is the weather today\")", - "type": "ruby" - } - }, - { - "id": { - "path": "/reference", - "method": "POST", - "identifierOverride": "endpoint_reference.send" - }, - "snippet": { - "client": "require \"fern_literal\"\n\nliteral = SeedLiteralClient::Client.new(\n base_url: \"https://api.example.com\",\n version: \"Version\",\n audit_logging: \"AuditLogging\"\n)\nliteral.reference.send(request: { prompt: \"You are a helpful assistant\", stream: false, context: \"You're super wise\", query: \"What is the weather today\" })", - "type": "ruby" - } - }, - { - "id": { - "path": "/reference", - "method": "POST", - "identifierOverride": "endpoint_reference.send" - }, - "snippet": { - "client": "require \"fern_literal\"\n\nliteral = SeedLiteralClient::Client.new(\n base_url: \"https://api.example.com\",\n version: \"Version\",\n audit_logging: \"AuditLogging\"\n)\nliteral.reference.send(request: { prompt: \"You are a helpful assistant\", stream: false, context: \"You're super wise\", query: \"What is the weather today\" })", - "type": "ruby" - } - } - ], - "types": {} -} \ No newline at end of file diff --git a/seed/ts-express/literal/.mock/definition/inlined.yml b/seed/ts-express/literal/.mock/definition/inlined.yml index 33fda38a6d8..c2834c5c50c 100644 --- a/seed/ts-express/literal/.mock/definition/inlined.yml +++ b/seed/ts-express/literal/.mock/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -32,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: diff --git a/seed/ts-express/literal/api/resources/inlined/service/requests/SendLiteralsInlinedRequest.ts b/seed/ts-express/literal/api/resources/inlined/service/requests/SendLiteralsInlinedRequest.ts index fa5bce8160c..b7fa30f92e4 100644 --- a/seed/ts-express/literal/api/resources/inlined/service/requests/SendLiteralsInlinedRequest.ts +++ b/seed/ts-express/literal/api/resources/inlined/service/requests/SendLiteralsInlinedRequest.ts @@ -12,4 +12,5 @@ export interface SendLiteralsInlinedRequest { stream: false; aliasedContext: SeedLiteral.SomeAliasedLiteral; maybeContext?: SeedLiteral.SomeAliasedLiteral; + objectWithLiteral: SeedLiteral.ATopLevelLiteral; } diff --git a/seed/ts-express/literal/api/resources/inlined/types/ANestedLiteral.ts b/seed/ts-express/literal/api/resources/inlined/types/ANestedLiteral.ts new file mode 100644 index 00000000000..90e7f46a7b8 --- /dev/null +++ b/seed/ts-express/literal/api/resources/inlined/types/ANestedLiteral.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ANestedLiteral { + myLiteral: "How super cool"; +} diff --git a/seed/ts-express/literal/api/resources/inlined/types/ATopLevelLiteral.ts b/seed/ts-express/literal/api/resources/inlined/types/ATopLevelLiteral.ts new file mode 100644 index 00000000000..11d6b37da9d --- /dev/null +++ b/seed/ts-express/literal/api/resources/inlined/types/ATopLevelLiteral.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as SeedLiteral from "../../../index"; + +export interface ATopLevelLiteral { + nestedLiteral: SeedLiteral.ANestedLiteral; +} diff --git a/seed/ts-express/literal/api/resources/inlined/types/index.ts b/seed/ts-express/literal/api/resources/inlined/types/index.ts index fcd237d7a37..20ff37d5a30 100644 --- a/seed/ts-express/literal/api/resources/inlined/types/index.ts +++ b/seed/ts-express/literal/api/resources/inlined/types/index.ts @@ -1 +1,3 @@ export * from "./SomeAliasedLiteral"; +export * from "./ATopLevelLiteral"; +export * from "./ANestedLiteral"; diff --git a/seed/ts-express/literal/serialization/resources/inlined/service/requests/SendLiteralsInlinedRequest.ts b/seed/ts-express/literal/serialization/resources/inlined/service/requests/SendLiteralsInlinedRequest.ts index 568391f287c..31d24ffa256 100644 --- a/seed/ts-express/literal/serialization/resources/inlined/service/requests/SendLiteralsInlinedRequest.ts +++ b/seed/ts-express/literal/serialization/resources/inlined/service/requests/SendLiteralsInlinedRequest.ts @@ -17,6 +17,7 @@ export const SendLiteralsInlinedRequest: core.serialization.Schema< stream: core.serialization.booleanLiteral(false), aliasedContext: core.serialization.lazy(() => serializers.SomeAliasedLiteral), maybeContext: core.serialization.lazy(() => serializers.SomeAliasedLiteral).optional(), + objectWithLiteral: core.serialization.lazyObject(() => serializers.ATopLevelLiteral), }); export declare namespace SendLiteralsInlinedRequest { @@ -28,5 +29,6 @@ export declare namespace SendLiteralsInlinedRequest { stream: false; aliasedContext: serializers.SomeAliasedLiteral.Raw; maybeContext?: serializers.SomeAliasedLiteral.Raw | null; + objectWithLiteral: serializers.ATopLevelLiteral.Raw; } } diff --git a/seed/ts-express/literal/serialization/resources/inlined/types/ANestedLiteral.ts b/seed/ts-express/literal/serialization/resources/inlined/types/ANestedLiteral.ts new file mode 100644 index 00000000000..663353e5261 --- /dev/null +++ b/seed/ts-express/literal/serialization/resources/inlined/types/ANestedLiteral.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../index"; +import * as SeedLiteral from "../../../../api/index"; +import * as core from "../../../../core"; + +export const ANestedLiteral: core.serialization.ObjectSchema< + serializers.ANestedLiteral.Raw, + SeedLiteral.ANestedLiteral +> = core.serialization.object({ + myLiteral: core.serialization.stringLiteral("How super cool"), +}); + +export declare namespace ANestedLiteral { + interface Raw { + myLiteral: "How super cool"; + } +} diff --git a/seed/ts-express/literal/serialization/resources/inlined/types/ATopLevelLiteral.ts b/seed/ts-express/literal/serialization/resources/inlined/types/ATopLevelLiteral.ts new file mode 100644 index 00000000000..dbd11dda00a --- /dev/null +++ b/seed/ts-express/literal/serialization/resources/inlined/types/ATopLevelLiteral.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../index"; +import * as SeedLiteral from "../../../../api/index"; +import * as core from "../../../../core"; + +export const ATopLevelLiteral: core.serialization.ObjectSchema< + serializers.ATopLevelLiteral.Raw, + SeedLiteral.ATopLevelLiteral +> = core.serialization.object({ + nestedLiteral: core.serialization.lazyObject(() => serializers.ANestedLiteral), +}); + +export declare namespace ATopLevelLiteral { + interface Raw { + nestedLiteral: serializers.ANestedLiteral.Raw; + } +} diff --git a/seed/ts-express/literal/serialization/resources/inlined/types/index.ts b/seed/ts-express/literal/serialization/resources/inlined/types/index.ts index fcd237d7a37..20ff37d5a30 100644 --- a/seed/ts-express/literal/serialization/resources/inlined/types/index.ts +++ b/seed/ts-express/literal/serialization/resources/inlined/types/index.ts @@ -1 +1,3 @@ export * from "./SomeAliasedLiteral"; +export * from "./ATopLevelLiteral"; +export * from "./ANestedLiteral"; diff --git a/seed/ts-sdk/literal/.mock/definition/inlined.yml b/seed/ts-sdk/literal/.mock/definition/inlined.yml index 33fda38a6d8..c2834c5c50c 100644 --- a/seed/ts-sdk/literal/.mock/definition/inlined.yml +++ b/seed/ts-sdk/literal/.mock/definition/inlined.yml @@ -5,6 +5,14 @@ types: SomeAliasedLiteral: type: literal<"You're super wise"> + ATopLevelLiteral: + properties: + nestedLiteral: ANestedLiteral + + ANestedLiteral: + properties: + myLiteral: literal<"How super cool"> + service: auth: false base-path: "" @@ -23,6 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -32,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: diff --git a/seed/ts-sdk/literal/reference.md b/seed/ts-sdk/literal/reference.md index 2ccf0f133af..edda488551d 100644 --- a/seed/ts-sdk/literal/reference.md +++ b/seed/ts-sdk/literal/reference.md @@ -72,6 +72,11 @@ await client.inlined.send({ context: "You're super wise", aliasedContext: "You're super wise", maybeContext: "You're super wise", + objectWithLiteral: { + nestedLiteral: { + myLiteral: "How super cool", + }, + }, query: "What is the weather today", }); ``` diff --git a/seed/ts-sdk/literal/snippet-templates.json b/seed/ts-sdk/literal/snippet-templates.json index e695122462d..1a24d2506b7 100644 --- a/seed/ts-sdk/literal/snippet-templates.json +++ b/seed/ts-sdk/literal/snippet-templates.json @@ -235,6 +235,29 @@ "type": "generic" }, "type": "template" + }, + { + "value": { + "imports": [], + "templateString": "objectWithLiteral: {\n\t\t\t$FERN_INPUT\n\t\t}", + "isOptional": true, + "inputDelimiter": ",\n\t\t\t", + "templateInputs": [ + { + "value": { + "imports": [], + "templateString": "nestedLiteral: {\n\t\t\t\t$FERN_INPUT\n\t\t\t}", + "isOptional": true, + "inputDelimiter": ",\n\t\t\t\t", + "templateInputs": [], + "type": "generic" + }, + "type": "template" + } + ], + "type": "generic" + }, + "type": "template" } ], "type": "generic" diff --git a/seed/ts-sdk/literal/snippet.json b/seed/ts-sdk/literal/snippet.json index 98b790a606d..3b8ec6a5d94 100644 --- a/seed/ts-sdk/literal/snippet.json +++ b/seed/ts-sdk/literal/snippet.json @@ -19,7 +19,7 @@ }, "snippet": { "type": "typescript", - "client": "import { SeedLiteralClient } from \"@fern/literal\";\n\nconst client = new SeedLiteralClient({ environment: \"YOUR_BASE_URL\" });\nawait client.inlined.send({\n temperature: 10.1,\n context: \"You're super wise\",\n aliasedContext: \"You're super wise\",\n maybeContext: \"You're super wise\",\n query: \"What is the weather today\"\n});\n" + "client": "import { SeedLiteralClient } from \"@fern/literal\";\n\nconst client = new SeedLiteralClient({ environment: \"YOUR_BASE_URL\" });\nawait client.inlined.send({\n temperature: 10.1,\n context: \"You're super wise\",\n aliasedContext: \"You're super wise\",\n maybeContext: \"You're super wise\",\n objectWithLiteral: {\n nestedLiteral: {\n myLiteral: \"How super cool\"\n }\n },\n query: \"What is the weather today\"\n});\n" } }, { diff --git a/seed/ts-sdk/literal/src/api/resources/inlined/client/Client.ts b/seed/ts-sdk/literal/src/api/resources/inlined/client/Client.ts index bec9052bae1..2769d981d33 100644 --- a/seed/ts-sdk/literal/src/api/resources/inlined/client/Client.ts +++ b/seed/ts-sdk/literal/src/api/resources/inlined/client/Client.ts @@ -44,6 +44,11 @@ export class Inlined { * context: "You're super wise", * aliasedContext: "You're super wise", * maybeContext: "You're super wise", + * objectWithLiteral: { + * nestedLiteral: { + * myLiteral: "How super cool" + * } + * }, * query: "What is the weather today" * }) */ diff --git a/seed/ts-sdk/literal/src/api/resources/inlined/client/requests/SendLiteralsInlinedRequest.ts b/seed/ts-sdk/literal/src/api/resources/inlined/client/requests/SendLiteralsInlinedRequest.ts index a9387ec79d1..7042a209f6a 100644 --- a/seed/ts-sdk/literal/src/api/resources/inlined/client/requests/SendLiteralsInlinedRequest.ts +++ b/seed/ts-sdk/literal/src/api/resources/inlined/client/requests/SendLiteralsInlinedRequest.ts @@ -11,6 +11,11 @@ import * as SeedLiteral from "../../../../index"; * context: "You're super wise", * aliasedContext: "You're super wise", * maybeContext: "You're super wise", + * objectWithLiteral: { + * nestedLiteral: { + * myLiteral: "How super cool" + * } + * }, * query: "What is the weather today" * } */ @@ -19,4 +24,5 @@ export interface SendLiteralsInlinedRequest { query: string; temperature?: number; maybeContext?: SeedLiteral.SomeAliasedLiteral; + objectWithLiteral: SeedLiteral.ATopLevelLiteral; } diff --git a/seed/ts-sdk/literal/src/api/resources/inlined/types/ANestedLiteral.ts b/seed/ts-sdk/literal/src/api/resources/inlined/types/ANestedLiteral.ts new file mode 100644 index 00000000000..90e7f46a7b8 --- /dev/null +++ b/seed/ts-sdk/literal/src/api/resources/inlined/types/ANestedLiteral.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ANestedLiteral { + myLiteral: "How super cool"; +} diff --git a/seed/ts-sdk/literal/src/api/resources/inlined/types/ATopLevelLiteral.ts b/seed/ts-sdk/literal/src/api/resources/inlined/types/ATopLevelLiteral.ts new file mode 100644 index 00000000000..11d6b37da9d --- /dev/null +++ b/seed/ts-sdk/literal/src/api/resources/inlined/types/ATopLevelLiteral.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as SeedLiteral from "../../../index"; + +export interface ATopLevelLiteral { + nestedLiteral: SeedLiteral.ANestedLiteral; +} diff --git a/seed/ts-sdk/literal/src/api/resources/inlined/types/index.ts b/seed/ts-sdk/literal/src/api/resources/inlined/types/index.ts index fcd237d7a37..20ff37d5a30 100644 --- a/seed/ts-sdk/literal/src/api/resources/inlined/types/index.ts +++ b/seed/ts-sdk/literal/src/api/resources/inlined/types/index.ts @@ -1 +1,3 @@ export * from "./SomeAliasedLiteral"; +export * from "./ATopLevelLiteral"; +export * from "./ANestedLiteral"; diff --git a/seed/ts-sdk/literal/src/serialization/resources/inlined/client/requests/SendLiteralsInlinedRequest.ts b/seed/ts-sdk/literal/src/serialization/resources/inlined/client/requests/SendLiteralsInlinedRequest.ts index 5e3b405a3af..958f96b88ec 100644 --- a/seed/ts-sdk/literal/src/serialization/resources/inlined/client/requests/SendLiteralsInlinedRequest.ts +++ b/seed/ts-sdk/literal/src/serialization/resources/inlined/client/requests/SendLiteralsInlinedRequest.ts @@ -6,6 +6,7 @@ import * as serializers from "../../../../index"; import * as SeedLiteral from "../../../../../api/index"; import * as core from "../../../../../core"; import { SomeAliasedLiteral } from "../../types/SomeAliasedLiteral"; +import { ATopLevelLiteral } from "../../types/ATopLevelLiteral"; export const SendLiteralsInlinedRequest: core.serialization.Schema< serializers.SendLiteralsInlinedRequest.Raw, @@ -15,6 +16,7 @@ export const SendLiteralsInlinedRequest: core.serialization.Schema< query: core.serialization.string(), temperature: core.serialization.number().optional(), maybeContext: SomeAliasedLiteral.optional(), + objectWithLiteral: ATopLevelLiteral, }); export declare namespace SendLiteralsInlinedRequest { @@ -23,5 +25,6 @@ export declare namespace SendLiteralsInlinedRequest { query: string; temperature?: number | null; maybeContext?: SomeAliasedLiteral.Raw | null; + objectWithLiteral: ATopLevelLiteral.Raw; } } diff --git a/seed/ts-sdk/literal/src/serialization/resources/inlined/types/ANestedLiteral.ts b/seed/ts-sdk/literal/src/serialization/resources/inlined/types/ANestedLiteral.ts new file mode 100644 index 00000000000..663353e5261 --- /dev/null +++ b/seed/ts-sdk/literal/src/serialization/resources/inlined/types/ANestedLiteral.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../index"; +import * as SeedLiteral from "../../../../api/index"; +import * as core from "../../../../core"; + +export const ANestedLiteral: core.serialization.ObjectSchema< + serializers.ANestedLiteral.Raw, + SeedLiteral.ANestedLiteral +> = core.serialization.object({ + myLiteral: core.serialization.stringLiteral("How super cool"), +}); + +export declare namespace ANestedLiteral { + interface Raw { + myLiteral: "How super cool"; + } +} diff --git a/seed/ts-sdk/literal/src/serialization/resources/inlined/types/ATopLevelLiteral.ts b/seed/ts-sdk/literal/src/serialization/resources/inlined/types/ATopLevelLiteral.ts new file mode 100644 index 00000000000..e2384b98c2d --- /dev/null +++ b/seed/ts-sdk/literal/src/serialization/resources/inlined/types/ATopLevelLiteral.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../index"; +import * as SeedLiteral from "../../../../api/index"; +import * as core from "../../../../core"; +import { ANestedLiteral } from "./ANestedLiteral"; + +export const ATopLevelLiteral: core.serialization.ObjectSchema< + serializers.ATopLevelLiteral.Raw, + SeedLiteral.ATopLevelLiteral +> = core.serialization.object({ + nestedLiteral: ANestedLiteral, +}); + +export declare namespace ATopLevelLiteral { + interface Raw { + nestedLiteral: ANestedLiteral.Raw; + } +} diff --git a/seed/ts-sdk/literal/src/serialization/resources/inlined/types/index.ts b/seed/ts-sdk/literal/src/serialization/resources/inlined/types/index.ts index fcd237d7a37..20ff37d5a30 100644 --- a/seed/ts-sdk/literal/src/serialization/resources/inlined/types/index.ts +++ b/seed/ts-sdk/literal/src/serialization/resources/inlined/types/index.ts @@ -1 +1,3 @@ export * from "./SomeAliasedLiteral"; +export * from "./ATopLevelLiteral"; +export * from "./ANestedLiteral"; diff --git a/test-definitions/fern/apis/literal/definition/inlined.yml b/test-definitions/fern/apis/literal/definition/inlined.yml index 4bf030a9259..c2834c5c50c 100644 --- a/test-definitions/fern/apis/literal/definition/inlined.yml +++ b/test-definitions/fern/apis/literal/definition/inlined.yml @@ -31,7 +31,7 @@ service: stream: literal aliasedContext: SomeAliasedLiteral maybeContext: optional - nestedLiteral: ATopLevelLiteral + objectWithLiteral: ATopLevelLiteral response: root.SendResponse examples: @@ -41,6 +41,9 @@ service: context: "You're super wise" aliasedContext: "You're super wise" maybeContext: "You're super wise" + objectWithLiteral: + nestedLiteral: + myLiteral: "How super cool" stream: false query: "What is the weather today" response: From 0dfef98162a164668b8f0caa2041d34030377fbc Mon Sep 17 00:00:00 2001 From: armandobelardo Date: Thu, 5 Sep 2024 16:27:24 -0400 Subject: [PATCH 4/8] format --- generators/python/core_utilities/shared/pydantic_utilities.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/generators/python/core_utilities/shared/pydantic_utilities.py b/generators/python/core_utilities/shared/pydantic_utilities.py index 4bdabe86ba8..e4cfc3de628 100644 --- a/generators/python/core_utilities/shared/pydantic_utilities.py +++ b/generators/python/core_utilities/shared/pydantic_utilities.py @@ -104,7 +104,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: """ # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. - # + # # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: @@ -147,6 +147,7 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + def deep_union_pydantic_dicts( source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] ) -> typing.Dict[str, typing.Any]: @@ -159,6 +160,7 @@ def deep_union_pydantic_dicts( return destination + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 From 9529c11c84bd7fa972282216da9263e7ba4d691a Mon Sep 17 00:00:00 2001 From: armandobelardo Date: Thu, 5 Sep 2024 17:18:54 -0400 Subject: [PATCH 5/8] update seed --- .../shared/pydantic_utilities.py | 32 +++++-- .../types/core/pydantic_utilities.py | 77 ++++++++++++----- .../types/core/pydantic_utilities.py | 77 ++++++++++++----- .../types/core/pydantic_utilities.py | 77 ++++++++++++----- .../types/core/pydantic_utilities.py | 83 ++++++++++++++----- .../alias-extends/core/pydantic_utilities.py | 16 +++- seed/fastapi/alias/core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../audiences/core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../basic-auth/core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../custom-auth/core/pydantic_utilities.py | 16 +++- .../error-property/core/pydantic_utilities.py | 16 +++- .../examples/core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../pydantic-v1/core/pydantic_utilities.py | 16 +++- .../pydantic-v2/core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../extends/core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../folders/core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../grpc-proto/core/pydantic_utilities.py | 16 +++- seed/fastapi/grpc/core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../async-handlers/core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../mixed-case/core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../no-environment/core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../fastapi/object/core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../optional/core/pydantic_utilities.py | 16 +++- .../package-yml/core/pydantic_utilities.py | 16 +++- .../pagination/core/pydantic_utilities.py | 16 +++- .../plain-text/core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../simple-fhir/core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- seed/fastapi/trace/core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../fastapi/unions/core/pydantic_utilities.py | 16 +++- .../unknown/core/pydantic_utilities.py | 16 +++- .../validation/core/pydantic_utilities.py | 16 +++- .../variables/core/pydantic_utilities.py | 16 +++- .../core/pydantic_utilities.py | 16 +++- .../version/core/pydantic_utilities.py | 16 +++- .../websocket/core/pydantic_utilities.py | 16 +++- .../alias_extends/core/pydantic_utilities.py | 10 ++- .../src/seed/alias/core/pydantic_utilities.py | 10 ++- .../seed/any_auth/core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../seed/audiences/core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../basic_auth/core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../src/seed/bytes/core/pydantic_utilities.py | 10 ++- .../src/seed/api/core/pydantic_utilities.py | 10 ++- .../src/seed/api/core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../custom_auth/core/pydantic_utilities.py | 10 ++- .../src/seed/enum/core/pydantic_utilities.py | 10 ++- .../error_property/core/pydantic_utilities.py | 10 ++- .../seed/examples/core/pydantic_utilities.py | 10 ++- .../exhaustive/core/pydantic_utilities.py | 10 ++- .../exhaustive/core/pydantic_utilities.py | 10 ++- .../seed/extends/core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../file_download/core/pydantic_utilities.py | 10 ++- .../file_upload/core/pydantic_utilities.py | 10 ++- .../src/seed/api/core/pydantic_utilities.py | 10 ++- .../src/seed/api/core/pydantic_utilities.py | 10 ++- .../src/seed/api/core/pydantic_utilities.py | 10 ++- .../src/seed/api/core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../src/seed/api/core/pydantic_utilities.py | 10 ++- .../seed/literal/core/pydantic_utilities.py | 10 ++- .../mixed_case/core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../no_environment/core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../seed/object/core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../package_yml/core/pydantic_utilities.py | 10 ++- .../pagination/core/pydantic_utilities.py | 10 ++- .../plain_text/core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../nursery_api/core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../src/seed/api/core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../seed/streaming/core/pydantic_utilities.py | 10 ++- .../seed/streaming/core/pydantic_utilities.py | 10 ++- .../src/seed/trace/core/pydantic_utilities.py | 10 ++- .../core/pydantic_utilities.py | 10 ++- .../seed/unions/core/pydantic_utilities.py | 10 ++- .../unknown_as_any/core/pydantic_utilities.py | 10 ++- .../validation/core/pydantic_utilities.py | 10 ++- .../seed/variables/core/pydantic_utilities.py | 10 ++- .../seed/version/core/pydantic_utilities.py | 10 ++- .../seed/version/core/pydantic_utilities.py | 10 ++- .../seed/websocket/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../alias/src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../bytes/src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../grpc/src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../imdb/src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../trace/src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- .../src/seed/core/pydantic_utilities.py | 10 ++- 208 files changed, 2215 insertions(+), 503 deletions(-) diff --git a/generators/python/core_utilities/shared/pydantic_utilities.py b/generators/python/core_utilities/shared/pydantic_utilities.py index e4cfc3de628..b7e047ca7bb 100644 --- a/generators/python/core_utilities/shared/pydantic_utilities.py +++ b/generators/python/core_utilities/shared/pydantic_utilities.py @@ -55,7 +55,9 @@ def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: - dealiased_object = convert_and_respect_annotation_metadata(object_=object_, annotation=type_, direction="read") + dealiased_object = convert_and_respect_annotation_metadata( + object_=object_, annotation=type_, direction="read" + ) if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 return adapter.validate_python(dealiased_object) @@ -109,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ @@ -143,9 +151,13 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: **kwargs, } - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) - return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") + return convert_and_respect_annotation_metadata( + object_=dict_dump, annotation=self.__class__, direction="write" + ) def deep_union_pydantic_dicts( @@ -208,12 +220,14 @@ 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 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 5a85b5acabc..a445878af5b 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 @@ -106,36 +106,69 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + _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_include_fields: typing.Any = { + "by_alias": True, + "exclude_unset": True, + "include": _fields_set, + **kwargs, + } + + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 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 5a85b5acabc..a445878af5b 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 @@ -106,36 +106,69 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + _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_include_fields: typing.Any = { + "by_alias": True, + "exclude_unset": True, + "include": _fields_set, + **kwargs, + } + + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/generators/python/tests/utils/unaliased_models/types/core/pydantic_utilities.py b/generators/python/tests/utils/unaliased_models/types/core/pydantic_utilities.py index 5a85b5acabc..a445878af5b 100644 --- a/generators/python/tests/utils/unaliased_models/types/core/pydantic_utilities.py +++ b/generators/python/tests/utils/unaliased_models/types/core/pydantic_utilities.py @@ -106,36 +106,69 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + 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, + } + dict_dump = deep_union_pydantic_dicts( + 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: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + _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_include_fields: typing.Any = { + "by_alias": True, + "exclude_unset": True, + "include": _fields_set, + **kwargs, + } + + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 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 5a85b5acabc..1248e039417 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 @@ -106,36 +106,75 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: Override the default dict method to `exclude_unset` by default. This function patches `exclude_unset` to work include fields within non-None default 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, - } - + # Note: the logic here is multi-plexed given the levers exposed in Pydantic V1 vs V2 + # Pydantic V1's .dict can be extremely slow, so we do not want to call it twice. + # + # We'd ideally do the same for Pydantic V2, but it shells out to a library to serialize models + # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: - dict_dump = super().model_dump(**kwargs_with_defaults_exclude_unset) # type: ignore # Pydantic v2 + kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, + "by_alias": True, + "exclude_unset": True, + "exclude_none": False, + } + kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, + "by_alias": True, + "exclude_none": True, + "exclude_unset": False, + } + dict_dump = deep_union_pydantic_dicts( + super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 + super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 + ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: - dict_dump = super().dict(**kwargs_with_defaults_exclude_unset) + _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_include_fields: typing.Any = { + "by_alias": True, + "exclude_unset": True, + "include": _fields_set, + **kwargs, + } + + dict_dump = super().dict( + **kwargs_with_defaults_exclude_unset_include_fields + ) return convert_and_respect_annotation_metadata( object_=dict_dump, annotation=self.__class__, direction="write" ) +def deep_union_pydantic_dicts( + source: typing.Dict[str, typing.Any], destination: typing.Dict[str, typing.Any] +) -> typing.Dict[str, typing.Any]: + for key, value in source.items(): + if isinstance(value, dict): + node = destination.setdefault(key, {}) + deep_union_pydantic_dicts(value, node) + else: + destination[key] = value + + return destination + + if IS_PYDANTIC_V2: class V2RootModel(UniversalBaseModel, pydantic.RootModel): # type: ignore # Pydantic v2 diff --git a/seed/fastapi/alias-extends/core/pydantic_utilities.py b/seed/fastapi/alias-extends/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/alias-extends/core/pydantic_utilities.py +++ b/seed/fastapi/alias-extends/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/alias/core/pydantic_utilities.py b/seed/fastapi/alias/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/alias/core/pydantic_utilities.py +++ b/seed/fastapi/alias/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py +++ b/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/audiences/core/pydantic_utilities.py b/seed/fastapi/audiences/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/audiences/core/pydantic_utilities.py +++ b/seed/fastapi/audiences/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/basic-auth/core/pydantic_utilities.py b/seed/fastapi/basic-auth/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/basic-auth/core/pydantic_utilities.py +++ b/seed/fastapi/basic-auth/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py +++ b/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py +++ b/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/circular-references/core/pydantic_utilities.py b/seed/fastapi/circular-references/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/circular-references/core/pydantic_utilities.py +++ b/seed/fastapi/circular-references/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/cross-package-type-names/core/pydantic_utilities.py b/seed/fastapi/cross-package-type-names/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/cross-package-type-names/core/pydantic_utilities.py +++ b/seed/fastapi/cross-package-type-names/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/custom-auth/core/pydantic_utilities.py b/seed/fastapi/custom-auth/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/custom-auth/core/pydantic_utilities.py +++ b/seed/fastapi/custom-auth/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/error-property/core/pydantic_utilities.py b/seed/fastapi/error-property/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/error-property/core/pydantic_utilities.py +++ b/seed/fastapi/error-property/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/examples/core/pydantic_utilities.py b/seed/fastapi/examples/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/examples/core/pydantic_utilities.py +++ b/seed/fastapi/examples/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py b/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ 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 a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py b/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py b/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py b/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/extends/core/pydantic_utilities.py b/seed/fastapi/extends/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/extends/core/pydantic_utilities.py +++ b/seed/fastapi/extends/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/extra-properties/core/pydantic_utilities.py b/seed/fastapi/extra-properties/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/extra-properties/core/pydantic_utilities.py +++ b/seed/fastapi/extra-properties/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/folders/core/pydantic_utilities.py b/seed/fastapi/folders/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/folders/core/pydantic_utilities.py +++ b/seed/fastapi/folders/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/grpc-proto-exhaustive/core/pydantic_utilities.py b/seed/fastapi/grpc-proto-exhaustive/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/grpc-proto-exhaustive/core/pydantic_utilities.py +++ b/seed/fastapi/grpc-proto-exhaustive/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/grpc-proto/core/pydantic_utilities.py b/seed/fastapi/grpc-proto/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/grpc-proto/core/pydantic_utilities.py +++ b/seed/fastapi/grpc-proto/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/grpc/core/pydantic_utilities.py b/seed/fastapi/grpc/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/grpc/core/pydantic_utilities.py +++ b/seed/fastapi/grpc/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/idempotency-headers/core/pydantic_utilities.py b/seed/fastapi/idempotency-headers/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/idempotency-headers/core/pydantic_utilities.py +++ b/seed/fastapi/idempotency-headers/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/mixed-case/core/pydantic_utilities.py b/seed/fastapi/mixed-case/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/mixed-case/core/pydantic_utilities.py +++ b/seed/fastapi/mixed-case/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/multi-line-docs/core/pydantic_utilities.py b/seed/fastapi/multi-line-docs/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/multi-line-docs/core/pydantic_utilities.py +++ b/seed/fastapi/multi-line-docs/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 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 @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/multi-url-environment/core/pydantic_utilities.py +++ b/seed/fastapi/multi-url-environment/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/no-environment/core/pydantic_utilities.py b/seed/fastapi/no-environment/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/no-environment/core/pydantic_utilities.py +++ b/seed/fastapi/no-environment/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 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 @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 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 @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/object/core/pydantic_utilities.py b/seed/fastapi/object/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/object/core/pydantic_utilities.py +++ b/seed/fastapi/object/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/objects-with-imports/core/pydantic_utilities.py +++ b/seed/fastapi/objects-with-imports/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/optional/core/pydantic_utilities.py b/seed/fastapi/optional/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/optional/core/pydantic_utilities.py +++ b/seed/fastapi/optional/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/package-yml/core/pydantic_utilities.py b/seed/fastapi/package-yml/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/package-yml/core/pydantic_utilities.py +++ b/seed/fastapi/package-yml/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/pagination/core/pydantic_utilities.py b/seed/fastapi/pagination/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/pagination/core/pydantic_utilities.py +++ b/seed/fastapi/pagination/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/plain-text/core/pydantic_utilities.py b/seed/fastapi/plain-text/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/plain-text/core/pydantic_utilities.py +++ b/seed/fastapi/plain-text/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/reserved-keywords/core/pydantic_utilities.py b/seed/fastapi/reserved-keywords/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/reserved-keywords/core/pydantic_utilities.py +++ b/seed/fastapi/reserved-keywords/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/simple-fhir/core/pydantic_utilities.py b/seed/fastapi/simple-fhir/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/simple-fhir/core/pydantic_utilities.py +++ b/seed/fastapi/simple-fhir/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py +++ b/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 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 @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/trace/core/pydantic_utilities.py b/seed/fastapi/trace/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/trace/core/pydantic_utilities.py +++ b/seed/fastapi/trace/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py b/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py +++ b/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/unions/core/pydantic_utilities.py b/seed/fastapi/unions/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/unions/core/pydantic_utilities.py +++ b/seed/fastapi/unions/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/unknown/core/pydantic_utilities.py b/seed/fastapi/unknown/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/unknown/core/pydantic_utilities.py +++ b/seed/fastapi/unknown/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/validation/core/pydantic_utilities.py b/seed/fastapi/validation/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/validation/core/pydantic_utilities.py +++ b/seed/fastapi/validation/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/variables/core/pydantic_utilities.py b/seed/fastapi/variables/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/variables/core/pydantic_utilities.py +++ b/seed/fastapi/variables/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/version-no-default/core/pydantic_utilities.py +++ b/seed/fastapi/version-no-default/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/version/core/pydantic_utilities.py b/seed/fastapi/version/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/version/core/pydantic_utilities.py +++ b/seed/fastapi/version/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/websocket/core/pydantic_utilities.py b/seed/fastapi/websocket/core/pydantic_utilities.py index a445878af5b..a197cc9b537 100644 --- a/seed/fastapi/websocket/core/pydantic_utilities.py +++ b/seed/fastapi/websocket/core/pydantic_utilities.py @@ -113,19 +113,31 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print( + "kwargs_with_defaults_exclude_unset", + super().model_dump(**kwargs_with_defaults_exclude_unset), + ) + print( + "kwargs_with_defaults_exclude_none", + super().model_dump(**kwargs_with_defaults_exclude_none), + ) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py +++ b/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ diff --git a/seed/pydantic/any-auth/src/seed/any_auth/core/pydantic_utilities.py b/seed/pydantic/any-auth/src/seed/any_auth/core/pydantic_utilities.py index eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/any-auth/src/seed/any_auth/core/pydantic_utilities.py +++ b/seed/pydantic/any-auth/src/seed/any_auth/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py +++ b/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py +++ b/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ diff --git a/seed/pydantic/cross-package-type-names/src/seed/cross_package_type_names/core/pydantic_utilities.py b/seed/pydantic/cross-package-type-names/src/seed/cross_package_type_names/core/pydantic_utilities.py index eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/cross-package-type-names/src/seed/cross_package_type_names/core/pydantic_utilities.py +++ b/seed/pydantic/cross-package-type-names/src/seed/cross_package_type_names/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py +++ b/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py +++ b/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py +++ b/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ diff --git a/seed/pydantic/grpc-proto-exhaustive/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/grpc-proto-exhaustive/src/seed/api/core/pydantic_utilities.py index eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/grpc-proto-exhaustive/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/grpc-proto-exhaustive/src/seed/api/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ 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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py +++ b/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py +++ b/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py +++ b/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py +++ b/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py +++ b/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py +++ b/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py +++ b/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py +++ b/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py +++ b/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py +++ b/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ 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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ diff --git a/seed/python-sdk/any-auth/src/seed/core/pydantic_utilities.py b/seed/python-sdk/any-auth/src/seed/core/pydantic_utilities.py index eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/any-auth/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/any-auth/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ diff --git a/seed/python-sdk/cross-package-type-names/src/seed/core/pydantic_utilities.py b/seed/python-sdk/cross-package-type-names/src/seed/core/pydantic_utilities.py index eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/cross-package-type-names/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/cross-package-type-names/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ 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 eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ diff --git a/seed/python-sdk/grpc-proto-exhaustive/src/seed/core/pydantic_utilities.py b/seed/python-sdk/grpc-proto-exhaustive/src/seed/core/pydantic_utilities.py index eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/grpc-proto-exhaustive/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/grpc-proto-exhaustive/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ 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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/object/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/object/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ 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 eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 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 @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/version/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/version/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 eb2eaf707fd..effd2092a44 100644 --- a/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py @@ -111,19 +111,25 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: # that we have less control over, and this is less intrusive than custom serializers for now. if IS_PYDANTIC_V2: kwargs_with_defaults_exclude_unset: typing.Any = { + **kwargs, "by_alias": True, "exclude_unset": True, - **kwargs, + "exclude_none": False, } kwargs_with_defaults_exclude_none: typing.Any = { + **kwargs, "by_alias": True, "exclude_none": True, - **kwargs, + "exclude_unset": False, } dict_dump = deep_union_pydantic_dicts( super().model_dump(**kwargs_with_defaults_exclude_unset), # type: ignore # Pydantic v2 super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) + + print("dict_dump", dict_dump) + print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) + print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ From eef2a06250797aafecbdd224b6eedbb57ffb42c6 Mon Sep 17 00:00:00 2001 From: armandobelardo Date: Thu, 5 Sep 2024 17:44:52 -0400 Subject: [PATCH 6/8] lint --- .../shared/pydantic_utilities.py | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/generators/python/core_utilities/shared/pydantic_utilities.py b/generators/python/core_utilities/shared/pydantic_utilities.py index b7e047ca7bb..a0e5fc83a5f 100644 --- a/generators/python/core_utilities/shared/pydantic_utilities.py +++ b/generators/python/core_utilities/shared/pydantic_utilities.py @@ -55,9 +55,7 @@ def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T: - dealiased_object = convert_and_respect_annotation_metadata( - object_=object_, annotation=type_, direction="read" - ) + dealiased_object = convert_and_respect_annotation_metadata(object_=object_, annotation=type_, direction="read") if IS_PYDANTIC_V2: adapter = pydantic.TypeAdapter(type_) # type: ignore # Pydantic v2 return adapter.validate_python(dealiased_object) @@ -151,13 +149,9 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: **kwargs, } - dict_dump = super().dict( - **kwargs_with_defaults_exclude_unset_include_fields - ) + dict_dump = super().dict(**kwargs_with_defaults_exclude_unset_include_fields) - return convert_and_respect_annotation_metadata( - object_=dict_dump, annotation=self.__class__, direction="write" - ) + return convert_and_respect_annotation_metadata(object_=dict_dump, annotation=self.__class__, direction="write") def deep_union_pydantic_dicts( @@ -220,14 +214,12 @@ 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 From 06146d53f851e8effb08699b9cf171d8c50a0c0d Mon Sep 17 00:00:00 2001 From: armandobelardo Date: Thu, 5 Sep 2024 18:26:40 -0400 Subject: [PATCH 7/8] update snaps --- .../__test__/test-definitions/literal.json | 1221 ++++++++++++++++- .../convertIrToFdrApi.test.ts.snap | 63 + 2 files changed, 1254 insertions(+), 30 deletions(-) diff --git a/packages/cli/generation/ir-generator/src/__test__/test-definitions/literal.json b/packages/cli/generation/ir-generator/src/__test__/test-definitions/literal.json index fbe06c6ace1..b3c6e9e8521 100644 --- a/packages/cli/generation/ir-generator/src/__test__/test-definitions/literal.json +++ b/packages/cli/generation/ir-generator/src/__test__/test-definitions/literal.json @@ -362,6 +362,308 @@ "availability": null, "docs": null }, + "type_inlined:ATopLevelLiteral": { + "name": { + "name": { + "originalName": "ATopLevelLiteral", + "camelCase": { + "unsafeName": "aTopLevelLiteral", + "safeName": "aTopLevelLiteral" + }, + "snakeCase": { + "unsafeName": "a_top_level_literal", + "safeName": "a_top_level_literal" + }, + "screamingSnakeCase": { + "unsafeName": "A_TOP_LEVEL_LITERAL", + "safeName": "A_TOP_LEVEL_LITERAL" + }, + "pascalCase": { + "unsafeName": "ATopLevelLiteral", + "safeName": "ATopLevelLiteral" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + ], + "packagePath": [], + "file": { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + }, + "typeId": "type_inlined:ATopLevelLiteral" + }, + "shape": { + "_type": "object", + "extends": [], + "properties": [ + { + "name": { + "name": { + "originalName": "nestedLiteral", + "camelCase": { + "unsafeName": "nestedLiteral", + "safeName": "nestedLiteral" + }, + "snakeCase": { + "unsafeName": "nested_literal", + "safeName": "nested_literal" + }, + "screamingSnakeCase": { + "unsafeName": "NESTED_LITERAL", + "safeName": "NESTED_LITERAL" + }, + "pascalCase": { + "unsafeName": "NestedLiteral", + "safeName": "NestedLiteral" + } + }, + "wireValue": "nestedLiteral" + }, + "valueType": { + "_type": "named", + "name": { + "originalName": "ANestedLiteral", + "camelCase": { + "unsafeName": "aNestedLiteral", + "safeName": "aNestedLiteral" + }, + "snakeCase": { + "unsafeName": "a_nested_literal", + "safeName": "a_nested_literal" + }, + "screamingSnakeCase": { + "unsafeName": "A_NESTED_LITERAL", + "safeName": "A_NESTED_LITERAL" + }, + "pascalCase": { + "unsafeName": "ANestedLiteral", + "safeName": "ANestedLiteral" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + ], + "packagePath": [], + "file": { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + }, + "typeId": "type_inlined:ANestedLiteral", + "default": null, + "inline": null + }, + "availability": null, + "docs": null + } + ], + "extra-properties": false, + "extendedProperties": [] + }, + "referencedTypes": [ + "type_inlined:ANestedLiteral" + ], + "encoding": { + "json": {}, + "proto": null + }, + "source": null, + "userProvidedExamples": [], + "autogeneratedExamples": [], + "availability": null, + "docs": null + }, + "type_inlined:ANestedLiteral": { + "name": { + "name": { + "originalName": "ANestedLiteral", + "camelCase": { + "unsafeName": "aNestedLiteral", + "safeName": "aNestedLiteral" + }, + "snakeCase": { + "unsafeName": "a_nested_literal", + "safeName": "a_nested_literal" + }, + "screamingSnakeCase": { + "unsafeName": "A_NESTED_LITERAL", + "safeName": "A_NESTED_LITERAL" + }, + "pascalCase": { + "unsafeName": "ANestedLiteral", + "safeName": "ANestedLiteral" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + ], + "packagePath": [], + "file": { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + }, + "typeId": "type_inlined:ANestedLiteral" + }, + "shape": { + "_type": "object", + "extends": [], + "properties": [ + { + "name": { + "name": { + "originalName": "myLiteral", + "camelCase": { + "unsafeName": "myLiteral", + "safeName": "myLiteral" + }, + "snakeCase": { + "unsafeName": "my_literal", + "safeName": "my_literal" + }, + "screamingSnakeCase": { + "unsafeName": "MY_LITERAL", + "safeName": "MY_LITERAL" + }, + "pascalCase": { + "unsafeName": "MyLiteral", + "safeName": "MyLiteral" + } + }, + "wireValue": "myLiteral" + }, + "valueType": { + "_type": "container", + "container": { + "_type": "literal", + "literal": { + "type": "string", + "string": "How super cool" + } + } + }, + "availability": null, + "docs": null + } + ], + "extra-properties": false, + "extendedProperties": [] + }, + "referencedTypes": [], + "encoding": { + "json": {}, + "proto": null + }, + "source": null, + "userProvidedExamples": [], + "autogeneratedExamples": [], + "availability": null, + "docs": null + }, "type_reference:SendRequest": { "name": { "name": { @@ -2457,32 +2759,125 @@ } }, "docs": null - } - ], - "extra-properties": false, - "extendedProperties": [] - }, - "sdkRequest": { - "shape": { - "type": "wrapper", - "wrapperName": { - "originalName": "SendLiteralsInlinedRequest", - "camelCase": { - "unsafeName": "sendLiteralsInlinedRequest", - "safeName": "sendLiteralsInlinedRequest" - }, - "snakeCase": { - "unsafeName": "send_literals_inlined_request", - "safeName": "send_literals_inlined_request" - }, - "screamingSnakeCase": { - "unsafeName": "SEND_LITERALS_INLINED_REQUEST", - "safeName": "SEND_LITERALS_INLINED_REQUEST" - }, - "pascalCase": { - "unsafeName": "SendLiteralsInlinedRequest", - "safeName": "SendLiteralsInlinedRequest" - } + }, + { + "name": { + "name": { + "originalName": "objectWithLiteral", + "camelCase": { + "unsafeName": "objectWithLiteral", + "safeName": "objectWithLiteral" + }, + "snakeCase": { + "unsafeName": "object_with_literal", + "safeName": "object_with_literal" + }, + "screamingSnakeCase": { + "unsafeName": "OBJECT_WITH_LITERAL", + "safeName": "OBJECT_WITH_LITERAL" + }, + "pascalCase": { + "unsafeName": "ObjectWithLiteral", + "safeName": "ObjectWithLiteral" + } + }, + "wireValue": "objectWithLiteral" + }, + "valueType": { + "_type": "named", + "name": { + "originalName": "ATopLevelLiteral", + "camelCase": { + "unsafeName": "aTopLevelLiteral", + "safeName": "aTopLevelLiteral" + }, + "snakeCase": { + "unsafeName": "a_top_level_literal", + "safeName": "a_top_level_literal" + }, + "screamingSnakeCase": { + "unsafeName": "A_TOP_LEVEL_LITERAL", + "safeName": "A_TOP_LEVEL_LITERAL" + }, + "pascalCase": { + "unsafeName": "ATopLevelLiteral", + "safeName": "ATopLevelLiteral" + } + }, + "fernFilepath": { + "allParts": [ + { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + ], + "packagePath": [], + "file": { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + }, + "typeId": "type_inlined:ATopLevelLiteral", + "default": null, + "inline": null + }, + "docs": null + } + ], + "extra-properties": false, + "extendedProperties": [] + }, + "sdkRequest": { + "shape": { + "type": "wrapper", + "wrapperName": { + "originalName": "SendLiteralsInlinedRequest", + "camelCase": { + "unsafeName": "sendLiteralsInlinedRequest", + "safeName": "sendLiteralsInlinedRequest" + }, + "snakeCase": { + "unsafeName": "send_literals_inlined_request", + "safeName": "send_literals_inlined_request" + }, + "screamingSnakeCase": { + "unsafeName": "SEND_LITERALS_INLINED_REQUEST", + "safeName": "SEND_LITERALS_INLINED_REQUEST" + }, + "pascalCase": { + "unsafeName": "SendLiteralsInlinedRequest", + "safeName": "SendLiteralsInlinedRequest" + } }, "bodyKey": { "originalName": "body", @@ -2569,7 +2964,7 @@ "userSpecifiedExamples": [ { "example": { - "id": "9f3971bb6ec43b6e5c733eb3690907ef68af0d8d6d3958e92233e5c602cfc7a4", + "id": "20c26654e1be5d623d8e043282333762ca7611d2d84866f9b823b50bc6f23722", "name": null, "url": "/inlined", "rootPathParameters": [], @@ -3040,6 +3435,382 @@ }, "originalTypeDeclaration": null }, + { + "name": { + "name": { + "originalName": "objectWithLiteral", + "camelCase": { + "unsafeName": "objectWithLiteral", + "safeName": "objectWithLiteral" + }, + "snakeCase": { + "unsafeName": "object_with_literal", + "safeName": "object_with_literal" + }, + "screamingSnakeCase": { + "unsafeName": "OBJECT_WITH_LITERAL", + "safeName": "OBJECT_WITH_LITERAL" + }, + "pascalCase": { + "unsafeName": "ObjectWithLiteral", + "safeName": "ObjectWithLiteral" + } + }, + "wireValue": "objectWithLiteral" + }, + "value": { + "shape": { + "type": "named", + "typeName": { + "typeId": "type_inlined:ATopLevelLiteral", + "fernFilepath": { + "allParts": [ + { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + ], + "packagePath": [], + "file": { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + }, + "name": { + "originalName": "ATopLevelLiteral", + "camelCase": { + "unsafeName": "aTopLevelLiteral", + "safeName": "aTopLevelLiteral" + }, + "snakeCase": { + "unsafeName": "a_top_level_literal", + "safeName": "a_top_level_literal" + }, + "screamingSnakeCase": { + "unsafeName": "A_TOP_LEVEL_LITERAL", + "safeName": "A_TOP_LEVEL_LITERAL" + }, + "pascalCase": { + "unsafeName": "ATopLevelLiteral", + "safeName": "ATopLevelLiteral" + } + } + }, + "shape": { + "type": "object", + "properties": [ + { + "name": { + "name": { + "originalName": "nestedLiteral", + "camelCase": { + "unsafeName": "nestedLiteral", + "safeName": "nestedLiteral" + }, + "snakeCase": { + "unsafeName": "nested_literal", + "safeName": "nested_literal" + }, + "screamingSnakeCase": { + "unsafeName": "NESTED_LITERAL", + "safeName": "NESTED_LITERAL" + }, + "pascalCase": { + "unsafeName": "NestedLiteral", + "safeName": "NestedLiteral" + } + }, + "wireValue": "nestedLiteral" + }, + "value": { + "shape": { + "type": "named", + "typeName": { + "typeId": "type_inlined:ANestedLiteral", + "fernFilepath": { + "allParts": [ + { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + ], + "packagePath": [], + "file": { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + }, + "name": { + "originalName": "ANestedLiteral", + "camelCase": { + "unsafeName": "aNestedLiteral", + "safeName": "aNestedLiteral" + }, + "snakeCase": { + "unsafeName": "a_nested_literal", + "safeName": "a_nested_literal" + }, + "screamingSnakeCase": { + "unsafeName": "A_NESTED_LITERAL", + "safeName": "A_NESTED_LITERAL" + }, + "pascalCase": { + "unsafeName": "ANestedLiteral", + "safeName": "ANestedLiteral" + } + } + }, + "shape": { + "type": "object", + "properties": [ + { + "name": { + "name": { + "originalName": "myLiteral", + "camelCase": { + "unsafeName": "myLiteral", + "safeName": "myLiteral" + }, + "snakeCase": { + "unsafeName": "my_literal", + "safeName": "my_literal" + }, + "screamingSnakeCase": { + "unsafeName": "MY_LITERAL", + "safeName": "MY_LITERAL" + }, + "pascalCase": { + "unsafeName": "MyLiteral", + "safeName": "MyLiteral" + } + }, + "wireValue": "myLiteral" + }, + "value": { + "shape": { + "type": "container", + "container": { + "type": "literal", + "literal": { + "type": "string", + "string": { + "original": "How super cool" + } + } + } + }, + "jsonExample": "How super cool" + }, + "originalTypeDeclaration": { + "typeId": "type_inlined:ANestedLiteral", + "fernFilepath": { + "allParts": [ + { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + ], + "packagePath": [], + "file": { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + }, + "name": { + "originalName": "ANestedLiteral", + "camelCase": { + "unsafeName": "aNestedLiteral", + "safeName": "aNestedLiteral" + }, + "snakeCase": { + "unsafeName": "a_nested_literal", + "safeName": "a_nested_literal" + }, + "screamingSnakeCase": { + "unsafeName": "A_NESTED_LITERAL", + "safeName": "A_NESTED_LITERAL" + }, + "pascalCase": { + "unsafeName": "ANestedLiteral", + "safeName": "ANestedLiteral" + } + } + } + } + ] + } + }, + "jsonExample": { + "myLiteral": "How super cool" + } + }, + "originalTypeDeclaration": { + "typeId": "type_inlined:ATopLevelLiteral", + "fernFilepath": { + "allParts": [ + { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + ], + "packagePath": [], + "file": { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + }, + "name": { + "originalName": "ATopLevelLiteral", + "camelCase": { + "unsafeName": "aTopLevelLiteral", + "safeName": "aTopLevelLiteral" + }, + "snakeCase": { + "unsafeName": "a_top_level_literal", + "safeName": "a_top_level_literal" + }, + "screamingSnakeCase": { + "unsafeName": "A_TOP_LEVEL_LITERAL", + "safeName": "A_TOP_LEVEL_LITERAL" + }, + "pascalCase": { + "unsafeName": "ATopLevelLiteral", + "safeName": "ATopLevelLiteral" + } + } + } + } + ] + } + }, + "jsonExample": { + "nestedLiteral": { + "myLiteral": "How super cool" + } + } + }, + "originalTypeDeclaration": null + }, { "name": { "name": { @@ -3122,6 +3893,11 @@ "context": "You're super wise", "aliasedContext": "You're super wise", "maybeContext": "You're super wise", + "objectWithLiteral": { + "nestedLiteral": { + "myLiteral": "How super cool" + } + }, "stream": false, "query": "What is the weather today" } @@ -3839,6 +4615,382 @@ }, "originalTypeDeclaration": null }, + { + "name": { + "name": { + "originalName": "objectWithLiteral", + "camelCase": { + "unsafeName": "objectWithLiteral", + "safeName": "objectWithLiteral" + }, + "snakeCase": { + "unsafeName": "object_with_literal", + "safeName": "object_with_literal" + }, + "screamingSnakeCase": { + "unsafeName": "OBJECT_WITH_LITERAL", + "safeName": "OBJECT_WITH_LITERAL" + }, + "pascalCase": { + "unsafeName": "ObjectWithLiteral", + "safeName": "ObjectWithLiteral" + } + }, + "wireValue": "objectWithLiteral" + }, + "value": { + "shape": { + "type": "named", + "typeName": { + "typeId": "type_inlined:ATopLevelLiteral", + "fernFilepath": { + "allParts": [ + { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + ], + "packagePath": [], + "file": { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + }, + "name": { + "originalName": "ATopLevelLiteral", + "camelCase": { + "unsafeName": "aTopLevelLiteral", + "safeName": "aTopLevelLiteral" + }, + "snakeCase": { + "unsafeName": "a_top_level_literal", + "safeName": "a_top_level_literal" + }, + "screamingSnakeCase": { + "unsafeName": "A_TOP_LEVEL_LITERAL", + "safeName": "A_TOP_LEVEL_LITERAL" + }, + "pascalCase": { + "unsafeName": "ATopLevelLiteral", + "safeName": "ATopLevelLiteral" + } + } + }, + "shape": { + "type": "object", + "properties": [ + { + "name": { + "name": { + "originalName": "nestedLiteral", + "camelCase": { + "unsafeName": "nestedLiteral", + "safeName": "nestedLiteral" + }, + "snakeCase": { + "unsafeName": "nested_literal", + "safeName": "nested_literal" + }, + "screamingSnakeCase": { + "unsafeName": "NESTED_LITERAL", + "safeName": "NESTED_LITERAL" + }, + "pascalCase": { + "unsafeName": "NestedLiteral", + "safeName": "NestedLiteral" + } + }, + "wireValue": "nestedLiteral" + }, + "value": { + "shape": { + "type": "named", + "typeName": { + "typeId": "type_inlined:ANestedLiteral", + "fernFilepath": { + "allParts": [ + { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + ], + "packagePath": [], + "file": { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + }, + "name": { + "originalName": "ANestedLiteral", + "camelCase": { + "unsafeName": "aNestedLiteral", + "safeName": "aNestedLiteral" + }, + "snakeCase": { + "unsafeName": "a_nested_literal", + "safeName": "a_nested_literal" + }, + "screamingSnakeCase": { + "unsafeName": "A_NESTED_LITERAL", + "safeName": "A_NESTED_LITERAL" + }, + "pascalCase": { + "unsafeName": "ANestedLiteral", + "safeName": "ANestedLiteral" + } + } + }, + "shape": { + "type": "object", + "properties": [ + { + "name": { + "name": { + "originalName": "myLiteral", + "camelCase": { + "unsafeName": "myLiteral", + "safeName": "myLiteral" + }, + "snakeCase": { + "unsafeName": "my_literal", + "safeName": "my_literal" + }, + "screamingSnakeCase": { + "unsafeName": "MY_LITERAL", + "safeName": "MY_LITERAL" + }, + "pascalCase": { + "unsafeName": "MyLiteral", + "safeName": "MyLiteral" + } + }, + "wireValue": "myLiteral" + }, + "value": { + "shape": { + "type": "container", + "container": { + "type": "literal", + "literal": { + "type": "string", + "string": { + "original": "How super cool" + } + } + } + }, + "jsonExample": "How super cool" + }, + "originalTypeDeclaration": { + "typeId": "type_inlined:ANestedLiteral", + "fernFilepath": { + "allParts": [ + { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + ], + "packagePath": [], + "file": { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + }, + "name": { + "originalName": "ANestedLiteral", + "camelCase": { + "unsafeName": "aNestedLiteral", + "safeName": "aNestedLiteral" + }, + "snakeCase": { + "unsafeName": "a_nested_literal", + "safeName": "a_nested_literal" + }, + "screamingSnakeCase": { + "unsafeName": "A_NESTED_LITERAL", + "safeName": "A_NESTED_LITERAL" + }, + "pascalCase": { + "unsafeName": "ANestedLiteral", + "safeName": "ANestedLiteral" + } + } + } + } + ] + } + }, + "jsonExample": { + "myLiteral": "How super cool" + } + }, + "originalTypeDeclaration": { + "typeId": "type_inlined:ATopLevelLiteral", + "fernFilepath": { + "allParts": [ + { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + ], + "packagePath": [], + "file": { + "originalName": "inlined", + "camelCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "snakeCase": { + "unsafeName": "inlined", + "safeName": "inlined" + }, + "screamingSnakeCase": { + "unsafeName": "INLINED", + "safeName": "INLINED" + }, + "pascalCase": { + "unsafeName": "Inlined", + "safeName": "Inlined" + } + } + }, + "name": { + "originalName": "ATopLevelLiteral", + "camelCase": { + "unsafeName": "aTopLevelLiteral", + "safeName": "aTopLevelLiteral" + }, + "snakeCase": { + "unsafeName": "a_top_level_literal", + "safeName": "a_top_level_literal" + }, + "screamingSnakeCase": { + "unsafeName": "A_TOP_LEVEL_LITERAL", + "safeName": "A_TOP_LEVEL_LITERAL" + }, + "pascalCase": { + "unsafeName": "ATopLevelLiteral", + "safeName": "ATopLevelLiteral" + } + } + } + } + ] + } + }, + "jsonExample": { + "nestedLiteral": { + "myLiteral": "How super cool" + } + } + }, + "originalTypeDeclaration": null + }, { "name": { "name": { @@ -3921,6 +5073,11 @@ "context": "You're super wise", "aliasedContext": "You're super wise", "maybeContext": "You're super wise", + "objectWithLiteral": { + "nestedLiteral": { + "myLiteral": "How super cool" + } + }, "stream": false, "query": "What is the weather today" } @@ -4162,7 +5319,7 @@ } } }, - "id": "bd4a75a0b67fec62298c942a5e8eef41dc422318", + "id": "2c4be4961c0fd34cc469d617441cbc24934a3ba7", "docs": null } } @@ -8050,7 +9207,8 @@ "serviceTypeReferenceInfo": { "typesReferencedOnlyByService": { "service_inlined": [ - "type_inlined:SomeAliasedLiteral" + "type_inlined:SomeAliasedLiteral", + "type_inlined:ATopLevelLiteral" ], "service_reference": [ "type_reference:SendRequest" @@ -8058,6 +9216,7 @@ }, "sharedTypes": [ "type_:SendResponse", + "type_inlined:ANestedLiteral", "type_reference:SomeLiteral" ] }, @@ -8205,7 +9364,9 @@ }, "service": "service_inlined", "types": [ - "type_inlined:SomeAliasedLiteral" + "type_inlined:SomeAliasedLiteral", + "type_inlined:ATopLevelLiteral", + "type_inlined:ANestedLiteral" ], "errors": [], "subpackages": [], diff --git a/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/convertIrToFdrApi.test.ts.snap b/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/convertIrToFdrApi.test.ts.snap index ffe3a1e79b3..9ba1dafdad7 100644 --- a/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/convertIrToFdrApi.test.ts.snap +++ b/packages/cli/register/src/ir-to-fdr-converter/__test__/__snapshots__/convertIrToFdrApi.test.ts.snap @@ -14387,6 +14387,11 @@ exports[`fdr test definitions > literal 1`] = ` "aliasedContext": "You're super wise", "context": "You're super wise", "maybeContext": "You're super wise", + "objectWithLiteral": { + "nestedLiteral": { + "myLiteral": "How super cool", + }, + }, "prompt": "You are a helpful assistant", "query": "What is the weather today", "stream": false, @@ -14398,6 +14403,11 @@ exports[`fdr test definitions > literal 1`] = ` "aliasedContext": "You're super wise", "context": "You're super wise", "maybeContext": "You're super wise", + "objectWithLiteral": { + "nestedLiteral": { + "myLiteral": "How super cool", + }, + }, "prompt": "You are a helpful assistant", "query": "What is the weather today", "stream": false, @@ -14530,6 +14540,14 @@ exports[`fdr test definitions > literal 1`] = ` "type": "optional", }, }, + { + "description": undefined, + "key": "objectWithLiteral", + "valueType": { + "type": "id", + "value": "type_inlined:ATopLevelLiteral", + }, + }, ], "type": "object", }, @@ -14554,6 +14572,8 @@ exports[`fdr test definitions > literal 1`] = ` "subpackages": [], "types": [ "type_inlined:SomeAliasedLiteral", + "type_inlined:ATopLevelLiteral", + "type_inlined:ANestedLiteral", ], "webhooks": [], "websockets": [], @@ -14952,6 +14972,49 @@ exports[`fdr test definitions > literal 1`] = ` "type": "object", }, }, + "type_inlined:ANestedLiteral": { + "availability": undefined, + "description": undefined, + "name": "ANestedLiteral", + "shape": { + "extends": [], + "properties": [ + { + "availability": undefined, + "description": undefined, + "key": "myLiteral", + "valueType": { + "type": "literal", + "value": { + "type": "stringLiteral", + "value": "How super cool", + }, + }, + }, + ], + "type": "object", + }, + }, + "type_inlined:ATopLevelLiteral": { + "availability": undefined, + "description": undefined, + "name": "ATopLevelLiteral", + "shape": { + "extends": [], + "properties": [ + { + "availability": undefined, + "description": undefined, + "key": "nestedLiteral", + "valueType": { + "type": "id", + "value": "type_inlined:ANestedLiteral", + }, + }, + ], + "type": "object", + }, + }, "type_inlined:SomeAliasedLiteral": { "availability": undefined, "description": undefined, From 3245db23c69e7869bfab9bf198380205833fb3a5 Mon Sep 17 00:00:00 2001 From: armandobelardo Date: Thu, 5 Sep 2024 19:02:41 -0400 Subject: [PATCH 8/8] update once more --- .../python/core_utilities/shared/pydantic_utilities.py | 3 --- seed/fastapi/alias-extends/core/pydantic_utilities.py | 9 --------- seed/fastapi/alias/core/pydantic_utilities.py | 9 --------- .../api-wide-base-path/core/pydantic_utilities.py | 9 --------- seed/fastapi/audiences/core/pydantic_utilities.py | 9 --------- .../core/pydantic_utilities.py | 9 --------- .../core/pydantic_utilities.py | 9 --------- seed/fastapi/basic-auth/core/pydantic_utilities.py | 9 --------- .../core/pydantic_utilities.py | 9 --------- .../core/pydantic_utilities.py | 9 --------- .../circular-references/core/pydantic_utilities.py | 9 --------- .../cross-package-type-names/core/pydantic_utilities.py | 9 --------- seed/fastapi/custom-auth/core/pydantic_utilities.py | 9 --------- seed/fastapi/error-property/core/pydantic_utilities.py | 9 --------- seed/fastapi/examples/core/pydantic_utilities.py | 9 --------- .../include-validators/core/pydantic_utilities.py | 9 --------- .../no-custom-config/core/pydantic_utilities.py | 9 --------- .../exhaustive/pydantic-v1/core/pydantic_utilities.py | 9 --------- .../exhaustive/pydantic-v2/core/pydantic_utilities.py | 9 --------- .../skip-formatting/core/pydantic_utilities.py | 9 --------- seed/fastapi/extends/core/pydantic_utilities.py | 9 --------- seed/fastapi/extra-properties/core/pydantic_utilities.py | 9 --------- seed/fastapi/folders/core/pydantic_utilities.py | 9 --------- .../grpc-proto-exhaustive/core/pydantic_utilities.py | 9 --------- seed/fastapi/grpc-proto/core/pydantic_utilities.py | 9 --------- seed/fastapi/grpc/core/pydantic_utilities.py | 9 --------- .../idempotency-headers/core/pydantic_utilities.py | 9 --------- .../imdb/async-handlers/core/pydantic_utilities.py | 9 --------- .../includes-extra-fields/core/pydantic_utilities.py | 9 --------- .../imdb/no-custom-config/core/pydantic_utilities.py | 9 --------- seed/fastapi/mixed-case/core/pydantic_utilities.py | 9 --------- seed/fastapi/multi-line-docs/core/pydantic_utilities.py | 9 --------- .../core/pydantic_utilities.py | 9 --------- .../multi-url-environment/core/pydantic_utilities.py | 9 --------- seed/fastapi/no-environment/core/pydantic_utilities.py | 9 --------- .../core/pydantic_utilities.py | 9 --------- .../core/pydantic_utilities.py | 9 --------- .../core/pydantic_utilities.py | 9 --------- .../oauth-client-credentials/core/pydantic_utilities.py | 9 --------- seed/fastapi/object/core/pydantic_utilities.py | 9 --------- .../objects-with-imports/core/pydantic_utilities.py | 9 --------- seed/fastapi/optional/core/pydantic_utilities.py | 9 --------- seed/fastapi/package-yml/core/pydantic_utilities.py | 9 --------- seed/fastapi/pagination/core/pydantic_utilities.py | 9 --------- seed/fastapi/plain-text/core/pydantic_utilities.py | 9 --------- .../fastapi/reserved-keywords/core/pydantic_utilities.py | 9 --------- seed/fastapi/simple-fhir/core/pydantic_utilities.py | 9 --------- .../core/pydantic_utilities.py | 9 --------- .../core/pydantic_utilities.py | 9 --------- seed/fastapi/trace/core/pydantic_utilities.py | 9 --------- .../undiscriminated-unions/core/pydantic_utilities.py | 9 --------- seed/fastapi/unions/core/pydantic_utilities.py | 9 --------- seed/fastapi/unknown/core/pydantic_utilities.py | 9 --------- seed/fastapi/validation/core/pydantic_utilities.py | 9 --------- seed/fastapi/variables/core/pydantic_utilities.py | 9 --------- .../version-no-default/core/pydantic_utilities.py | 9 --------- seed/fastapi/version/core/pydantic_utilities.py | 9 --------- seed/fastapi/websocket/core/pydantic_utilities.py | 9 --------- .../src/seed/alias_extends/core/pydantic_utilities.py | 3 --- .../alias/src/seed/alias/core/pydantic_utilities.py | 3 --- .../src/seed/any_auth/core/pydantic_utilities.py | 3 --- .../seed/api_wide_base_path/core/pydantic_utilities.py | 3 --- .../src/seed/audiences/core/pydantic_utilities.py | 3 --- .../core/pydantic_utilities.py | 3 --- .../core/pydantic_utilities.py | 3 --- .../src/seed/basic_auth/core/pydantic_utilities.py | 3 --- .../core/pydantic_utilities.py | 3 --- .../bytes/src/seed/bytes/core/pydantic_utilities.py | 3 --- .../src/seed/api/core/pydantic_utilities.py | 3 --- .../src/seed/api/core/pydantic_utilities.py | 3 --- .../cross_package_type_names/core/pydantic_utilities.py | 3 --- .../src/seed/custom_auth/core/pydantic_utilities.py | 3 --- .../enum/src/seed/enum/core/pydantic_utilities.py | 3 --- .../src/seed/error_property/core/pydantic_utilities.py | 3 --- .../src/seed/examples/core/pydantic_utilities.py | 3 --- .../src/seed/exhaustive/core/pydantic_utilities.py | 3 --- .../src/seed/exhaustive/core/pydantic_utilities.py | 3 --- .../extends/src/seed/extends/core/pydantic_utilities.py | 3 --- .../src/seed/extra_properties/core/pydantic_utilities.py | 3 --- .../src/seed/file_download/core/pydantic_utilities.py | 3 --- .../src/seed/file_upload/core/pydantic_utilities.py | 3 --- .../folders/src/seed/api/core/pydantic_utilities.py | 3 --- .../src/seed/api/core/pydantic_utilities.py | 3 --- .../grpc-proto/src/seed/api/core/pydantic_utilities.py | 3 --- .../grpc/src/seed/api/core/pydantic_utilities.py | 3 --- .../seed/idempotency_headers/core/pydantic_utilities.py | 3 --- .../imdb/src/seed/api/core/pydantic_utilities.py | 3 --- .../literal/src/seed/literal/core/pydantic_utilities.py | 3 --- .../src/seed/mixed_case/core/pydantic_utilities.py | 3 --- .../src/seed/multi_line_docs/core/pydantic_utilities.py | 3 --- .../core/pydantic_utilities.py | 3 --- .../multi_url_environment/core/pydantic_utilities.py | 3 --- .../src/seed/no_environment/core/pydantic_utilities.py | 3 --- .../core/pydantic_utilities.py | 3 --- .../core/pydantic_utilities.py | 3 --- .../oauth_client_credentials/core/pydantic_utilities.py | 3 --- .../oauth_client_credentials/core/pydantic_utilities.py | 3 --- .../object/src/seed/object/core/pydantic_utilities.py | 3 --- .../seed/objects_with_imports/core/pydantic_utilities.py | 3 --- .../seed/objects_with_imports/core/pydantic_utilities.py | 3 --- .../src/seed/package_yml/core/pydantic_utilities.py | 3 --- .../src/seed/pagination/core/pydantic_utilities.py | 3 --- .../src/seed/plain_text/core/pydantic_utilities.py | 3 --- .../src/seed/query_parameters/core/pydantic_utilities.py | 3 --- .../src/seed/nursery_api/core/pydantic_utilities.py | 3 --- .../seed/response_property/core/pydantic_utilities.py | 3 --- .../simple-fhir/src/seed/api/core/pydantic_utilities.py | 3 --- .../core/pydantic_utilities.py | 3 --- .../core/pydantic_utilities.py | 3 --- .../src/seed/streaming/core/pydantic_utilities.py | 3 --- .../src/seed/streaming/core/pydantic_utilities.py | 3 --- .../trace/src/seed/trace/core/pydantic_utilities.py | 3 --- .../undiscriminated_unions/core/pydantic_utilities.py | 3 --- .../unions/src/seed/unions/core/pydantic_utilities.py | 3 --- .../src/seed/unknown_as_any/core/pydantic_utilities.py | 3 --- .../src/seed/validation/core/pydantic_utilities.py | 3 --- .../src/seed/variables/core/pydantic_utilities.py | 3 --- .../src/seed/version/core/pydantic_utilities.py | 3 --- .../version/src/seed/version/core/pydantic_utilities.py | 3 --- .../src/seed/websocket/core/pydantic_utilities.py | 3 --- .../alias-extends/src/seed/core/pydantic_utilities.py | 3 --- .../python-sdk/alias/src/seed/core/pydantic_utilities.py | 3 --- .../any-auth/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../audiences/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../basic-auth/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../python-sdk/bytes/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../custom-auth/src/seed/core/pydantic_utilities.py | 3 --- .../no-custom-config/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../enum/real-enum/src/seed/core/pydantic_utilities.py | 3 --- .../enum/strenum/src/seed/core/pydantic_utilities.py | 3 --- .../error-property/src/seed/core/pydantic_utilities.py | 3 --- .../client-filename/src/seed/core/pydantic_utilities.py | 3 --- .../no-custom-config/src/seed/core/pydantic_utilities.py | 3 --- .../examples/readme/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../improved_imports/src/seed/core/pydantic_utilities.py | 3 --- .../infinite-timeout/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../no-custom-config/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../pydantic-v1/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../union-utils/src/seed/core/pydantic_utilities.py | 3 --- .../extends/src/seed/core/pydantic_utilities.py | 3 --- .../extra-properties/src/seed/core/pydantic_utilities.py | 3 --- .../file-download/src/seed/core/pydantic_utilities.py | 3 --- .../file-upload/src/seed/core/pydantic_utilities.py | 3 --- .../folders/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../grpc-proto/src/seed/core/pydantic_utilities.py | 3 --- seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py | 3 --- .../no-custom-config/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../mixed-case/src/seed/core/pydantic_utilities.py | 3 --- .../multi-line-docs/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../no-environment/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../object/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../optional/src/seed/core/pydantic_utilities.py | 3 --- .../package-yml/src/seed/core/pydantic_utilities.py | 3 --- .../pagination/src/seed/core/pydantic_utilities.py | 3 --- .../plain-text/src/seed/core/pydantic_utilities.py | 3 --- .../query-parameters/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../simple-fhir/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../no-custom-config/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../python-sdk/trace/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../no-custom-config/src/seed/core/pydantic_utilities.py | 3 --- .../union-naming-v1/src/seed/core/pydantic_utilities.py | 3 --- .../union-utils/src/seed/core/pydantic_utilities.py | 3 --- .../unknown/src/seed/core/pydantic_utilities.py | 3 --- .../no-custom-config/src/seed/core/pydantic_utilities.py | 3 --- .../with-defaults/src/seed/core/pydantic_utilities.py | 3 --- .../variables/src/seed/core/pydantic_utilities.py | 3 --- .../src/seed/core/pydantic_utilities.py | 3 --- .../version/src/seed/core/pydantic_utilities.py | 3 --- .../websocket/src/seed/core/pydantic_utilities.py | 3 --- 204 files changed, 954 deletions(-) diff --git a/generators/python/core_utilities/shared/pydantic_utilities.py b/generators/python/core_utilities/shared/pydantic_utilities.py index a0e5fc83a5f..86c6fc4e425 100644 --- a/generators/python/core_utilities/shared/pydantic_utilities.py +++ b/generators/python/core_utilities/shared/pydantic_utilities.py @@ -125,9 +125,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/alias-extends/core/pydantic_utilities.py b/seed/fastapi/alias-extends/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/alias-extends/core/pydantic_utilities.py +++ b/seed/fastapi/alias-extends/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/alias/core/pydantic_utilities.py b/seed/fastapi/alias/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/alias/core/pydantic_utilities.py +++ b/seed/fastapi/alias/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py +++ b/seed/fastapi/api-wide-base-path/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/audiences/core/pydantic_utilities.py b/seed/fastapi/audiences/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/audiences/core/pydantic_utilities.py +++ b/seed/fastapi/audiences/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/auth-environment-variables/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py +++ b/seed/fastapi/basic-auth-environment-variables/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/basic-auth/core/pydantic_utilities.py b/seed/fastapi/basic-auth/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/basic-auth/core/pydantic_utilities.py +++ b/seed/fastapi/basic-auth/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py +++ b/seed/fastapi/bearer-token-environment-variable/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py +++ b/seed/fastapi/circular-references-advanced/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/circular-references/core/pydantic_utilities.py b/seed/fastapi/circular-references/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/circular-references/core/pydantic_utilities.py +++ b/seed/fastapi/circular-references/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/cross-package-type-names/core/pydantic_utilities.py b/seed/fastapi/cross-package-type-names/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/cross-package-type-names/core/pydantic_utilities.py +++ b/seed/fastapi/cross-package-type-names/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/custom-auth/core/pydantic_utilities.py b/seed/fastapi/custom-auth/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/custom-auth/core/pydantic_utilities.py +++ b/seed/fastapi/custom-auth/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/error-property/core/pydantic_utilities.py b/seed/fastapi/error-property/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/error-property/core/pydantic_utilities.py +++ b/seed/fastapi/error-property/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/examples/core/pydantic_utilities.py b/seed/fastapi/examples/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/examples/core/pydantic_utilities.py +++ b/seed/fastapi/examples/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py b/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/include-validators/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ 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 a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/no-custom-config/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py b/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/pydantic-v1/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py b/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/pydantic-v2/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py b/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py +++ b/seed/fastapi/exhaustive/skip-formatting/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/extends/core/pydantic_utilities.py b/seed/fastapi/extends/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/extends/core/pydantic_utilities.py +++ b/seed/fastapi/extends/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/extra-properties/core/pydantic_utilities.py b/seed/fastapi/extra-properties/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/extra-properties/core/pydantic_utilities.py +++ b/seed/fastapi/extra-properties/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/folders/core/pydantic_utilities.py b/seed/fastapi/folders/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/folders/core/pydantic_utilities.py +++ b/seed/fastapi/folders/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/grpc-proto-exhaustive/core/pydantic_utilities.py b/seed/fastapi/grpc-proto-exhaustive/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/grpc-proto-exhaustive/core/pydantic_utilities.py +++ b/seed/fastapi/grpc-proto-exhaustive/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/grpc-proto/core/pydantic_utilities.py b/seed/fastapi/grpc-proto/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/grpc-proto/core/pydantic_utilities.py +++ b/seed/fastapi/grpc-proto/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/grpc/core/pydantic_utilities.py b/seed/fastapi/grpc/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/grpc/core/pydantic_utilities.py +++ b/seed/fastapi/grpc/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/idempotency-headers/core/pydantic_utilities.py b/seed/fastapi/idempotency-headers/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/idempotency-headers/core/pydantic_utilities.py +++ b/seed/fastapi/idempotency-headers/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/async-handlers/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/includes-extra-fields/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py +++ b/seed/fastapi/imdb/no-custom-config/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/mixed-case/core/pydantic_utilities.py b/seed/fastapi/mixed-case/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/mixed-case/core/pydantic_utilities.py +++ b/seed/fastapi/mixed-case/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/multi-line-docs/core/pydantic_utilities.py b/seed/fastapi/multi-line-docs/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/multi-line-docs/core/pydantic_utilities.py +++ b/seed/fastapi/multi-line-docs/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 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 @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/multi-url-environment/core/pydantic_utilities.py +++ b/seed/fastapi/multi-url-environment/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/no-environment/core/pydantic_utilities.py b/seed/fastapi/no-environment/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/no-environment/core/pydantic_utilities.py +++ b/seed/fastapi/no-environment/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials-default/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 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 @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 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 @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py +++ b/seed/fastapi/oauth-client-credentials/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/object/core/pydantic_utilities.py b/seed/fastapi/object/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/object/core/pydantic_utilities.py +++ b/seed/fastapi/object/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/objects-with-imports/core/pydantic_utilities.py +++ b/seed/fastapi/objects-with-imports/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/optional/core/pydantic_utilities.py b/seed/fastapi/optional/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/optional/core/pydantic_utilities.py +++ b/seed/fastapi/optional/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/package-yml/core/pydantic_utilities.py b/seed/fastapi/package-yml/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/package-yml/core/pydantic_utilities.py +++ b/seed/fastapi/package-yml/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/pagination/core/pydantic_utilities.py b/seed/fastapi/pagination/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/pagination/core/pydantic_utilities.py +++ b/seed/fastapi/pagination/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/plain-text/core/pydantic_utilities.py b/seed/fastapi/plain-text/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/plain-text/core/pydantic_utilities.py +++ b/seed/fastapi/plain-text/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/reserved-keywords/core/pydantic_utilities.py b/seed/fastapi/reserved-keywords/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/reserved-keywords/core/pydantic_utilities.py +++ b/seed/fastapi/reserved-keywords/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/simple-fhir/core/pydantic_utilities.py b/seed/fastapi/simple-fhir/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/simple-fhir/core/pydantic_utilities.py +++ b/seed/fastapi/simple-fhir/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py +++ b/seed/fastapi/single-url-environment-default/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 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 @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/trace/core/pydantic_utilities.py b/seed/fastapi/trace/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/trace/core/pydantic_utilities.py +++ b/seed/fastapi/trace/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py b/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py +++ b/seed/fastapi/undiscriminated-unions/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/unions/core/pydantic_utilities.py b/seed/fastapi/unions/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/unions/core/pydantic_utilities.py +++ b/seed/fastapi/unions/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/unknown/core/pydantic_utilities.py b/seed/fastapi/unknown/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/unknown/core/pydantic_utilities.py +++ b/seed/fastapi/unknown/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/validation/core/pydantic_utilities.py b/seed/fastapi/validation/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/validation/core/pydantic_utilities.py +++ b/seed/fastapi/validation/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/variables/core/pydantic_utilities.py b/seed/fastapi/variables/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/variables/core/pydantic_utilities.py +++ b/seed/fastapi/variables/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/version-no-default/core/pydantic_utilities.py +++ b/seed/fastapi/version-no-default/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/version/core/pydantic_utilities.py b/seed/fastapi/version/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/version/core/pydantic_utilities.py +++ b/seed/fastapi/version/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__fields_set__ diff --git a/seed/fastapi/websocket/core/pydantic_utilities.py b/seed/fastapi/websocket/core/pydantic_utilities.py index a197cc9b537..ac22d16a187 100644 --- a/seed/fastapi/websocket/core/pydantic_utilities.py +++ b/seed/fastapi/websocket/core/pydantic_utilities.py @@ -129,15 +129,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print( - "kwargs_with_defaults_exclude_unset", - super().model_dump(**kwargs_with_defaults_exclude_unset), - ) - print( - "kwargs_with_defaults_exclude_none", - super().model_dump(**kwargs_with_defaults_exclude_none), - ) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py +++ b/seed/pydantic/alias/src/seed/alias/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ diff --git a/seed/pydantic/any-auth/src/seed/any_auth/core/pydantic_utilities.py b/seed/pydantic/any-auth/src/seed/any_auth/core/pydantic_utilities.py index effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/any-auth/src/seed/any_auth/core/pydantic_utilities.py +++ b/seed/pydantic/any-auth/src/seed/any_auth/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py +++ b/seed/pydantic/audiences/src/seed/audiences/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py +++ b/seed/pydantic/bytes/src/seed/bytes/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ diff --git a/seed/pydantic/cross-package-type-names/src/seed/cross_package_type_names/core/pydantic_utilities.py b/seed/pydantic/cross-package-type-names/src/seed/cross_package_type_names/core/pydantic_utilities.py index effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/cross-package-type-names/src/seed/cross_package_type_names/core/pydantic_utilities.py +++ b/seed/pydantic/cross-package-type-names/src/seed/cross_package_type_names/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py +++ b/seed/pydantic/enum/src/seed/enum/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py +++ b/seed/pydantic/examples/src/seed/examples/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py +++ b/seed/pydantic/extends/src/seed/extends/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/folders/src/seed/api/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ diff --git a/seed/pydantic/grpc-proto-exhaustive/src/seed/api/core/pydantic_utilities.py b/seed/pydantic/grpc-proto-exhaustive/src/seed/api/core/pydantic_utilities.py index effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/grpc-proto-exhaustive/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/grpc-proto-exhaustive/src/seed/api/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ 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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/grpc/src/seed/api/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py +++ b/seed/pydantic/imdb/src/seed/api/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py +++ b/seed/pydantic/literal/src/seed/literal/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py +++ b/seed/pydantic/object/src/seed/object/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py +++ b/seed/pydantic/pagination/src/seed/pagination/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py +++ b/seed/pydantic/streaming/src/seed/streaming/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py +++ b/seed/pydantic/trace/src/seed/trace/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py +++ b/seed/pydantic/unions/src/seed/unions/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py +++ b/seed/pydantic/validation/src/seed/validation/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py +++ b/seed/pydantic/variables/src/seed/variables/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py +++ b/seed/pydantic/version/src/seed/version/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py +++ b/seed/pydantic/websocket/src/seed/websocket/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ 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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/alias/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ diff --git a/seed/python-sdk/any-auth/src/seed/core/pydantic_utilities.py b/seed/python-sdk/any-auth/src/seed/core/pydantic_utilities.py index effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/any-auth/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/any-auth/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/audiences/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/bytes/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ diff --git a/seed/python-sdk/cross-package-type-names/src/seed/core/pydantic_utilities.py b/seed/python-sdk/cross-package-type-names/src/seed/core/pydantic_utilities.py index effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/cross-package-type-names/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/cross-package-type-names/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ 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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/extends/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/folders/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ diff --git a/seed/python-sdk/grpc-proto-exhaustive/src/seed/core/pydantic_utilities.py b/seed/python-sdk/grpc-proto-exhaustive/src/seed/core/pydantic_utilities.py index effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/grpc-proto-exhaustive/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/grpc-proto-exhaustive/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ 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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/grpc/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/imdb/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/object/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/object/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/optional/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/pagination/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/trace/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__ 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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/unknown/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/variables/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 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 @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/version/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/version/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__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 effd2092a44..3c4ca2f49b3 100644 --- a/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py +++ b/seed/python-sdk/websocket/src/seed/core/pydantic_utilities.py @@ -127,9 +127,6 @@ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: super().model_dump(**kwargs_with_defaults_exclude_none), # type: ignore # Pydantic v2 ) - print("dict_dump", dict_dump) - print("kwargs_with_defaults_exclude_unset", super().model_dump(**kwargs_with_defaults_exclude_unset)) - print("kwargs_with_defaults_exclude_none", super().model_dump(**kwargs_with_defaults_exclude_none)) else: _fields_set = self.__fields_set__