diff --git a/end_to_end_tests/baseline_openapi_3.0.json b/end_to_end_tests/baseline_openapi_3.0.json index c47048218..916d8df89 100644 --- a/end_to_end_tests/baseline_openapi_3.0.json +++ b/end_to_end_tests/baseline_openapi_3.0.json @@ -2495,6 +2495,17 @@ "type": "string" } }, + "ModelWithSelfNamedProperty": { + "title": "ModelWithSelfNamedProperty", + "type": "object", + "properties": { + "model_with_self_named_property": { + "type": "string", + "format": "date" + } + }, + "required": ["model_with_self_named_property"] + }, "ModelWithAdditionalPropertiesRefed": { "title": "ModelWithAdditionalPropertiesRefed", "type": "object", diff --git a/end_to_end_tests/baseline_openapi_3.1.yaml b/end_to_end_tests/baseline_openapi_3.1.yaml index 295e6818a..730114d9c 100644 --- a/end_to_end_tests/baseline_openapi_3.1.yaml +++ b/end_to_end_tests/baseline_openapi_3.1.yaml @@ -2452,6 +2452,17 @@ info: "type": "string" } }, + "ModelWithSelfNamedProperty": { + "title": "ModelWithSelfNamedProperty", + "type": "object", + "properties": { + "model_with_self_named_property": { + "type": "string", + "format": "date" + } + }, + "required": ["model_with_self_named_property"] + }, "ModelWithAdditionalPropertiesRefed": { "title": "ModelWithAdditionalPropertiesRefed", "type": "object", diff --git a/end_to_end_tests/golden-records/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_description.py b/end_to_end_tests/golden-records/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_description.py index b0be6a72c..80a34ed31 100644 --- a/end_to_end_tests/golden-records/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_description.py +++ b/end_to_end_tests/golden-records/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_description.py @@ -24,7 +24,7 @@ class ModelWithDescription: it was the epoch of belief, it was the epoch of incredulity, it was the season of light, it was the season of darkness, it was the spring of hope, it was the winter of despair. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: prop_with_no_desc = self.prop_with_no_desc @@ -54,15 +54,13 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: prop_with_long_desc = d.pop("propWithLongDesc", UNSET) - model_with_description = cls( + return cls( prop_with_no_desc=prop_with_no_desc, prop_with_desc=prop_with_desc, prop_with_long_desc=prop_with_long_desc, + additional_properties=d, ) - model_with_description.additional_properties = d - return model_with_description - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_no_description.py b/end_to_end_tests/golden-records/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_no_description.py index 0a020f657..5c370616b 100644 --- a/end_to_end_tests/golden-records/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_no_description.py +++ b/end_to_end_tests/golden-records/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_no_description.py @@ -16,7 +16,7 @@ class ModelWithNoDescription: prop_with_no_desc: str | Unset = UNSET prop_with_desc: str | Unset = UNSET """ This is a nice property. """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: prop_with_no_desc = self.prop_with_no_desc @@ -40,14 +40,12 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: prop_with_desc = d.pop("propWithDesc", UNSET) - model_with_no_description = cls( + return cls( prop_with_no_desc=prop_with_no_desc, prop_with_desc=prop_with_desc, + additional_properties=d, ) - model_with_no_description.additional_properties = d - return model_with_no_description - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/escapes-client/escapes_client/models/misc_metadata_escapes_body.py b/end_to_end_tests/golden-records/escapes-client/escapes_client/models/misc_metadata_escapes_body.py index 98db7c4f7..c1f9cbbc6 100644 --- a/end_to_end_tests/golden-records/escapes-client/escapes_client/models/misc_metadata_escapes_body.py +++ b/end_to_end_tests/golden-records/escapes-client/escapes_client/models/misc_metadata_escapes_body.py @@ -11,7 +11,7 @@ @_attrs_define class MiscMetadataEscapesBody: - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -23,10 +23,10 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - misc_metadata_escapes_body = cls() - misc_metadata_escapes_body.additional_properties = d - return misc_metadata_escapes_body + return cls( + additional_properties=d, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/escapes-client/escapes_client/models/non_string_example_body.py b/end_to_end_tests/golden-records/escapes-client/escapes_client/models/non_string_example_body.py index ad5d5d328..d797e0b56 100644 --- a/end_to_end_tests/golden-records/escapes-client/escapes_client/models/non_string_example_body.py +++ b/end_to_end_tests/golden-records/escapes-client/escapes_client/models/non_string_example_body.py @@ -24,7 +24,7 @@ class NonStringExampleBody: """ dict_example: NonStringExampleBodyDictExample | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: dict_example: dict[str, Any] | Unset = UNSET @@ -51,13 +51,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: else: dict_example = NonStringExampleBodyDictExample.from_dict(_dict_example) - non_string_example_body = cls( + return cls( dict_example=dict_example, + additional_properties=d, ) - non_string_example_body.additional_properties = d - return non_string_example_body - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/escapes-client/escapes_client/models/non_string_example_body_dict_example.py b/end_to_end_tests/golden-records/escapes-client/escapes_client/models/non_string_example_body_dict_example.py index 819e8c591..424f957d4 100644 --- a/end_to_end_tests/golden-records/escapes-client/escapes_client/models/non_string_example_body_dict_example.py +++ b/end_to_end_tests/golden-records/escapes-client/escapes_client/models/non_string_example_body_dict_example.py @@ -17,7 +17,7 @@ class NonStringExampleBodyDictExample: """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -29,10 +29,10 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - non_string_example_body_dict_example = cls() - non_string_example_body_dict_example.additional_properties = d - return non_string_example_body_dict_example + return cls( + additional_properties=d, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/escapes-client/escapes_client/models/property_escapes_model_title_printuh_oh.py b/end_to_end_tests/golden-records/escapes-client/escapes_client/models/property_escapes_model_title_printuh_oh.py index 6e7d96a98..6f958543d 100644 --- a/end_to_end_tests/golden-records/escapes-client/escapes_client/models/property_escapes_model_title_printuh_oh.py +++ b/end_to_end_tests/golden-records/escapes-client/escapes_client/models/property_escapes_model_title_printuh_oh.py @@ -25,7 +25,7 @@ class PropertyEscapesModelTitlePrintuhOh: escaped_description: str | Unset = 'default value with \\"quotes\\"' escaped_enum: PropertyEscapesModelTitlePrintuhOhEscapedEnum | Unset = UNSET escaped_const: Literal["\\\" + print('uh oh') + \\\""] | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: escaped_description = self.escaped_description @@ -66,15 +66,13 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: f"escaped_const must match const '\\\\\" + print(\\'uh oh\\') + \\\\\"', got '{escaped_const}'" ) - property_escapes_model_title_printuh_oh = cls( + return cls( escaped_description=escaped_description, escaped_enum=escaped_enum, escaped_const=escaped_const, + additional_properties=d, ) - property_escapes_model_title_printuh_oh.additional_properties = d - return property_escapes_model_title_printuh_oh - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/escapes-client/escapes_client/models/schema_printuh_oh.py b/end_to_end_tests/golden-records/escapes-client/escapes_client/models/schema_printuh_oh.py index 02caf1747..cb06272c4 100644 --- a/end_to_end_tests/golden-records/escapes-client/escapes_client/models/schema_printuh_oh.py +++ b/end_to_end_tests/golden-records/escapes-client/escapes_client/models/schema_printuh_oh.py @@ -11,7 +11,7 @@ @_attrs_define class SchemaPrintuhOh: - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -23,10 +23,10 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - schema_printuh_oh = cls() - schema_printuh_oh.additional_properties = d - return schema_printuh_oh + return cls( + additional_properties=d, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/escapes-client/escapes_client/models/with_braces_path_body.py b/end_to_end_tests/golden-records/escapes-client/escapes_client/models/with_braces_path_body.py index 390de1497..e935b54c7 100644 --- a/end_to_end_tests/golden-records/escapes-client/escapes_client/models/with_braces_path_body.py +++ b/end_to_end_tests/golden-records/escapes-client/escapes_client/models/with_braces_path_body.py @@ -11,7 +11,7 @@ @_attrs_define class WithBracesPathBody: - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -23,10 +23,10 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - with_braces_path_body = cls() - with_braces_path_body.additional_properties = d - return with_braces_path_body + return cls( + additional_properties=d, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-enum-api-client/my_enum_api_client/models/a_model.py b/end_to_end_tests/golden-records/my-enum-api-client/my_enum_api_client/models/a_model.py index 890f7507f..f80a92bd3 100644 --- a/end_to_end_tests/golden-records/my-enum-api-client/my_enum_api_client/models/a_model.py +++ b/end_to_end_tests/golden-records/my-enum-api-client/my_enum_api_client/models/a_model.py @@ -100,12 +100,10 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: nested_list_of_enums.append(nested_list_of_enums_item) - a_model = cls( + return cls( an_enum_value=an_enum_value, an_allof_enum_with_overridden_default=an_allof_enum_with_overridden_default, any_value=any_value, an_optional_allof_enum=an_optional_allof_enum, nested_list_of_enums=nested_list_of_enums, ) - - return a_model diff --git a/end_to_end_tests/golden-records/my-enum-api-client/my_enum_api_client/models/post_user_list_body.py b/end_to_end_tests/golden-records/my-enum-api-client/my_enum_api_client/models/post_user_list_body.py index 7e8e93950..49070a4e5 100644 --- a/end_to_end_tests/golden-records/my-enum-api-client/my_enum_api_client/models/post_user_list_body.py +++ b/end_to_end_tests/golden-records/my-enum-api-client/my_enum_api_client/models/post_user_list_body.py @@ -34,7 +34,7 @@ class PostUserListBody: an_allof_enum_with_overridden_default: AnAllOfEnum | Unset = "overridden_default" an_optional_allof_enum: AnAllOfEnum | Unset = UNSET nested_list_of_enums: list[list[DifferentEnum]] | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: an_enum_value: list[str] | Unset = UNSET @@ -220,18 +220,16 @@ def _parse_an_enum_value_with_null_item(data: object) -> AnEnumWithNull | None: nested_list_of_enums.append(nested_list_of_enums_item) - post_user_list_body = cls( + return cls( an_enum_value=an_enum_value, an_enum_value_with_null=an_enum_value_with_null, an_enum_value_with_only_null=an_enum_value_with_only_null, an_allof_enum_with_overridden_default=an_allof_enum_with_overridden_default, an_optional_allof_enum=an_optional_allof_enum, nested_list_of_enums=nested_list_of_enums, + additional_properties=d, ) - post_user_list_body.additional_properties = d - return post_user_list_body - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/__init__.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/__init__.py index c62e4cfa6..23bc800bf 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/__init__.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/__init__.py @@ -72,6 +72,7 @@ from .model_with_property_ref import ModelWithPropertyRef from .model_with_recursive_ref import ModelWithRecursiveRef from .model_with_recursive_ref_in_additional_properties import ModelWithRecursiveRefInAdditionalProperties +from .model_with_self_named_property import ModelWithSelfNamedProperty from .model_with_union_property import ModelWithUnionProperty from .model_with_union_property_inlined import ModelWithUnionPropertyInlined from .model_with_union_property_inlined_apples import ModelWithUnionPropertyInlinedApples @@ -161,6 +162,7 @@ "ModelWithPropertyRef", "ModelWithRecursiveRef", "ModelWithRecursiveRefInAdditionalProperties", + "ModelWithSelfNamedProperty", "ModelWithUnionProperty", "ModelWithUnionPropertyInlined", "ModelWithUnionPropertyInlinedApples", diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_discriminated_union_type_1.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_discriminated_union_type_1.py index 635661b7b..e49ec4a47 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_discriminated_union_type_1.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_discriminated_union_type_1.py @@ -19,7 +19,7 @@ class ADiscriminatedUnionType1: """ model_type: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: model_type = self.model_type @@ -37,13 +37,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) model_type = d.pop("modelType", UNSET) - a_discriminated_union_type_1 = cls( + return cls( model_type=model_type, + additional_properties=d, ) - a_discriminated_union_type_1.additional_properties = d - return a_discriminated_union_type_1 - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_discriminated_union_type_2.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_discriminated_union_type_2.py index 0797af899..77cc7fbb6 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_discriminated_union_type_2.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_discriminated_union_type_2.py @@ -19,7 +19,7 @@ class ADiscriminatedUnionType2: """ model_type: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: model_type = self.model_type @@ -37,13 +37,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) model_type = d.pop("modelType", UNSET) - a_discriminated_union_type_2 = cls( + return cls( model_type=model_type, + additional_properties=d, ) - a_discriminated_union_type_2.additional_properties = d - return a_discriminated_union_type_2 - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_form_data.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_form_data.py index 257054eb2..069275faf 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_form_data.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_form_data.py @@ -21,7 +21,7 @@ class AFormData: an_required_field: str an_optional_field: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: an_required_field = self.an_required_field @@ -47,14 +47,12 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: an_optional_field = d.pop("an_optional_field", UNSET) - a_form_data = cls( + return cls( an_required_field=an_required_field, an_optional_field=an_optional_field, + additional_properties=d, ) - a_form_data.additional_properties = d - return a_form_data - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_model.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_model.py index 4ca83858f..8f7042b65 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_model.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_model.py @@ -509,7 +509,7 @@ def _parse_not_required_nullable_model(data: object) -> ModelWithUnionProperty | not_required_nullable_model = _parse_not_required_nullable_model(d.pop("not_required_nullable_model", UNSET)) - a_model = cls( + return cls( an_enum_value=an_enum_value, an_allof_enum_with_overridden_default=an_allof_enum_with_overridden_default, a_camel_date_time=a_camel_date_time, @@ -537,5 +537,3 @@ def _parse_not_required_nullable_model(data: object) -> ModelWithUnionProperty | not_required_model=not_required_model, not_required_nullable_model=not_required_nullable_model, ) - - return a_model diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py index 4c31bf01b..d77ea816e 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py @@ -80,7 +80,7 @@ class AModelWithPropertiesReferenceThatAreNotObject: double_property_ref: float file_property_ref: File bytestream_property_ref: str - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: enum_properties_ref = [] @@ -329,7 +329,7 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: bytestream_property_ref = d.pop("bytestream_property_ref") - a_model_with_properties_reference_that_are_not_object = cls( + return cls( enum_properties_ref=enum_properties_ref, str_properties_ref=str_properties_ref, date_properties_ref=date_properties_ref, @@ -360,11 +360,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: double_property_ref=double_property_ref, file_property_ref=file_property_ref, bytestream_property_ref=bytestream_property_ref, + additional_properties=d, ) - a_model_with_properties_reference_that_are_not_object.additional_properties = d - return a_model_with_properties_reference_that_are_not_object - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/all_of_has_properties_but_no_type.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/all_of_has_properties_but_no_type.py index 3295dcf26..c937765eb 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/all_of_has_properties_but_no_type.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/all_of_has_properties_but_no_type.py @@ -24,7 +24,7 @@ class AllOfHasPropertiesButNoType: a_sub_property: str | Unset = UNSET type_: str | Unset = UNSET type_enum: AllOfHasPropertiesButNoTypeTypeEnum | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: a_sub_property = self.a_sub_property @@ -61,15 +61,13 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: else: type_enum = AllOfHasPropertiesButNoTypeTypeEnum(_type_enum) - all_of_has_properties_but_no_type = cls( + return cls( a_sub_property=a_sub_property, type_=type_, type_enum=type_enum, + additional_properties=d, ) - all_of_has_properties_but_no_type.additional_properties = d - return all_of_has_properties_but_no_type - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/all_of_required_base.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/all_of_required_base.py index b06f45c30..954f19222 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/all_of_required_base.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/all_of_required_base.py @@ -21,7 +21,7 @@ class AllOfRequiredBase: bar: str | Unset = UNSET baz: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: bar = self.bar @@ -45,14 +45,12 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: baz = d.pop("baz", UNSET) - all_of_required_base = cls( + return cls( bar=bar, baz=baz, + additional_properties=d, ) - all_of_required_base.additional_properties = d - return all_of_required_base - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/all_of_required_derived.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/all_of_required_derived.py index 505334d6b..931e79f4e 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/all_of_required_derived.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/all_of_required_derived.py @@ -21,7 +21,7 @@ class AllOfRequiredDerived: bar: str baz: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: bar = self.bar @@ -47,14 +47,12 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: baz = d.pop("baz", UNSET) - all_of_required_derived = cls( + return cls( bar=bar, baz=baz, + additional_properties=d, ) - all_of_required_derived.additional_properties = d - return all_of_required_derived - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/all_of_sub_model.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/all_of_sub_model.py index 65b6f97c6..dacc297a8 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/all_of_sub_model.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/all_of_sub_model.py @@ -24,7 +24,7 @@ class AllOfSubModel: a_sub_property: str | Unset = UNSET type_: str | Unset = UNSET type_enum: AllOfSubModelTypeEnum | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: a_sub_property = self.a_sub_property @@ -61,15 +61,13 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: else: type_enum = AllOfSubModelTypeEnum(_type_enum) - all_of_sub_model = cls( + return cls( a_sub_property=a_sub_property, type_=type_, type_enum=type_enum, + additional_properties=d, ) - all_of_sub_model.additional_properties = d - return all_of_sub_model - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py index 77453bf2c..54e740e70 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py @@ -23,7 +23,7 @@ class AnArrayWithACircularRefInItemsObjectAItem: """ circular: list[AnArrayWithACircularRefInItemsObjectBItem] | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: circular: list[dict[str, Any]] | Unset = UNSET @@ -63,13 +63,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: circular.append(componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item) - an_array_with_a_circular_ref_in_items_object_a_item = cls( + return cls( circular=circular, + additional_properties=d, ) - an_array_with_a_circular_ref_in_items_object_a_item.additional_properties = d - return an_array_with_a_circular_ref_in_items_object_a_item - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py index 8a90d0eb3..fe32b58a3 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.py @@ -18,7 +18,7 @@ @_attrs_define class AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem: additional_properties: dict[str, list[AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem]] = ( - _attrs_field(init=False, factory=dict) + _attrs_field(factory=dict) ) def to_dict(self) -> dict[str, Any]: @@ -43,7 +43,6 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: ) d = dict(src_dict) - an_array_with_a_circular_ref_in_items_object_additional_properties_a_item = cls() additional_properties = {} for prop_name, prop_dict in d.items(): @@ -64,10 +63,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: additional_properties[prop_name] = additional_property - an_array_with_a_circular_ref_in_items_object_additional_properties_a_item.additional_properties = ( - additional_properties + return cls( + additional_properties=additional_properties, ) - return an_array_with_a_circular_ref_in_items_object_additional_properties_a_item @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py index e2b3e7ef5..871f51d76 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.py @@ -18,7 +18,7 @@ @_attrs_define class AnArrayWithACircularRefInItemsObjectAdditionalPropertiesBItem: additional_properties: dict[str, list[AnArrayWithACircularRefInItemsObjectAdditionalPropertiesAItem]] = ( - _attrs_field(init=False, factory=dict) + _attrs_field(factory=dict) ) def to_dict(self) -> dict[str, Any]: @@ -43,7 +43,6 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: ) d = dict(src_dict) - an_array_with_a_circular_ref_in_items_object_additional_properties_b_item = cls() additional_properties = {} for prop_name, prop_dict in d.items(): @@ -64,10 +63,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: additional_properties[prop_name] = additional_property - an_array_with_a_circular_ref_in_items_object_additional_properties_b_item.additional_properties = ( - additional_properties + return cls( + additional_properties=additional_properties, ) - return an_array_with_a_circular_ref_in_items_object_additional_properties_b_item @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py index e4039d6be..def243901 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_b_item.py @@ -23,7 +23,7 @@ class AnArrayWithACircularRefInItemsObjectBItem: """ circular: list[AnArrayWithACircularRefInItemsObjectAItem] | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: circular: list[dict[str, Any]] | Unset = UNSET @@ -63,13 +63,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: circular.append(componentsschemas_an_array_with_a_circular_ref_in_items_object_a_item) - an_array_with_a_circular_ref_in_items_object_b_item = cls( + return cls( circular=circular, + additional_properties=d, ) - an_array_with_a_circular_ref_in_items_object_b_item.additional_properties = d - return an_array_with_a_circular_ref_in_items_object_b_item - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py index 12aba8360..e0581a39b 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_additional_properties_item.py @@ -12,7 +12,7 @@ @_attrs_define class AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem: additional_properties: dict[str, list[AnArrayWithARecursiveRefInItemsObjectAdditionalPropertiesItem]] = ( - _attrs_field(init=False, factory=dict) + _attrs_field(factory=dict) ) def to_dict(self) -> dict[str, Any]: @@ -31,7 +31,6 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - an_array_with_a_recursive_ref_in_items_object_additional_properties_item = cls() additional_properties = {} for prop_name, prop_dict in d.items(): @@ -52,10 +51,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: additional_properties[prop_name] = additional_property - an_array_with_a_recursive_ref_in_items_object_additional_properties_item.additional_properties = ( - additional_properties + return cls( + additional_properties=additional_properties, ) - return an_array_with_a_recursive_ref_in_items_object_additional_properties_item @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py index 581a9f622..9282b2d89 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/an_array_with_a_recursive_ref_in_items_object_item.py @@ -19,7 +19,7 @@ class AnArrayWithARecursiveRefInItemsObjectItem: """ recursive: list[AnArrayWithARecursiveRefInItemsObjectItem] | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: recursive: list[dict[str, Any]] | Unset = UNSET @@ -55,13 +55,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: recursive.append(componentsschemas_an_array_with_a_recursive_ref_in_items_object_item) - an_array_with_a_recursive_ref_in_items_object_item = cls( + return cls( recursive=recursive, + additional_properties=d, ) - an_array_with_a_recursive_ref_in_items_object_item.additional_properties = d - return an_array_with_a_recursive_ref_in_items_object_item - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/another_all_of_sub_model.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/another_all_of_sub_model.py index 7c58d1a9c..953f6e287 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/another_all_of_sub_model.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/another_all_of_sub_model.py @@ -25,7 +25,7 @@ class AnotherAllOfSubModel: another_sub_property: str | Unset = UNSET type_: AnotherAllOfSubModelType | Unset = UNSET type_enum: AnotherAllOfSubModelTypeEnum | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: another_sub_property = self.another_sub_property @@ -69,15 +69,13 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: else: type_enum = AnotherAllOfSubModelTypeEnum(_type_enum) - another_all_of_sub_model = cls( + return cls( another_sub_property=another_sub_property, type_=type_, type_enum=type_enum, + additional_properties=d, ) - another_all_of_sub_model.additional_properties = d - return another_all_of_sub_model - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post.py index 0b8caee2c..56911e798 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post.py @@ -64,9 +64,7 @@ class BodyUploadFileTestsUploadPost: some_array: list[AFormData] | None | Unset = UNSET some_optional_object: BodyUploadFileTestsUploadPostSomeOptionalObject | Unset = UNSET some_enum: DifferentEnum | Unset = UNSET - additional_properties: dict[str, BodyUploadFileTestsUploadPostAdditionalProperty] = _attrs_field( - init=False, factory=dict - ) + additional_properties: dict[str, BodyUploadFileTestsUploadPostAdditionalProperty] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: from ..models.body_upload_file_tests_upload_post_some_nullable_object import ( @@ -372,7 +370,13 @@ def _parse_some_array(data: object) -> list[AFormData] | None | Unset: else: some_enum = DifferentEnum(_some_enum) - body_upload_file_tests_upload_post = cls( + additional_properties = {} + for prop_name, prop_dict in d.items(): + additional_property = BodyUploadFileTestsUploadPostAdditionalProperty.from_dict(prop_dict) + + additional_properties[prop_name] = additional_property + + return cls( some_file=some_file, some_required_number=some_required_number, some_object=some_object, @@ -387,17 +391,9 @@ def _parse_some_array(data: object) -> list[AFormData] | None | Unset: some_array=some_array, some_optional_object=some_optional_object, some_enum=some_enum, + additional_properties=additional_properties, ) - additional_properties = {} - for prop_name, prop_dict in d.items(): - additional_property = BodyUploadFileTestsUploadPostAdditionalProperty.from_dict(prop_dict) - - additional_properties[prop_name] = additional_property - - body_upload_file_tests_upload_post.additional_properties = additional_properties - return body_upload_file_tests_upload_post - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py index 160cb2542..5ccc2daec 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post_additional_property.py @@ -19,7 +19,7 @@ class BodyUploadFileTestsUploadPostAdditionalProperty: """ foo: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: foo = self.foo @@ -37,13 +37,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) foo = d.pop("foo", UNSET) - body_upload_file_tests_upload_post_additional_property = cls( + return cls( foo=foo, + additional_properties=d, ) - body_upload_file_tests_upload_post_additional_property.additional_properties = d - return body_upload_file_tests_upload_post_additional_property - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py index 47796442d..c67931bb2 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post_some_nullable_object.py @@ -19,7 +19,7 @@ class BodyUploadFileTestsUploadPostSomeNullableObject: """ bar: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: bar = self.bar @@ -37,13 +37,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) bar = d.pop("bar", UNSET) - body_upload_file_tests_upload_post_some_nullable_object = cls( + return cls( bar=bar, + additional_properties=d, ) - body_upload_file_tests_upload_post_some_nullable_object.additional_properties = d - return body_upload_file_tests_upload_post_some_nullable_object - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py index 0cc39b78b..e030c81d0 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post_some_object.py @@ -19,7 +19,7 @@ class BodyUploadFileTestsUploadPostSomeObject: num: float text: str - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: num = self.num @@ -44,14 +44,12 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: text = d.pop("text") - body_upload_file_tests_upload_post_some_object = cls( + return cls( num=num, text=text, + additional_properties=d, ) - body_upload_file_tests_upload_post_some_object.additional_properties = d - return body_upload_file_tests_upload_post_some_object - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py index f5658196c..c56cd104b 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/body_upload_file_tests_upload_post_some_optional_object.py @@ -17,7 +17,7 @@ class BodyUploadFileTestsUploadPostSomeOptionalObject: """ foo: str - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: foo = self.foo @@ -37,13 +37,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) foo = d.pop("foo") - body_upload_file_tests_upload_post_some_optional_object = cls( + return cls( foo=foo, + additional_properties=d, ) - body_upload_file_tests_upload_post_some_optional_object.additional_properties = d - return body_upload_file_tests_upload_post_some_optional_object - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/extended.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/extended.py index cf4966bf0..096e6e8f4 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/extended.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/extended.py @@ -81,7 +81,7 @@ class Extended: not_required_model: ModelWithUnionProperty | Unset = UNSET not_required_nullable_model: ModelWithUnionProperty | None | Unset = UNSET from_extended: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: from ..models.free_form_model import FreeFormModel # noqa: PLC0415 @@ -518,7 +518,7 @@ def _parse_not_required_nullable_model(data: object) -> ModelWithUnionProperty | from_extended = d.pop("fromExtended", UNSET) - extended = cls( + return cls( an_enum_value=an_enum_value, an_allof_enum_with_overridden_default=an_allof_enum_with_overridden_default, a_camel_date_time=a_camel_date_time, @@ -546,11 +546,9 @@ def _parse_not_required_nullable_model(data: object) -> ModelWithUnionProperty | not_required_model=not_required_model, not_required_nullable_model=not_required_nullable_model, from_extended=from_extended, + additional_properties=d, ) - extended.additional_properties = d - return extended - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/free_form_model.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/free_form_model.py index b8465ef44..0448aee10 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/free_form_model.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/free_form_model.py @@ -11,7 +11,7 @@ @_attrs_define class FreeFormModel: - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -23,10 +23,10 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - free_form_model = cls() - free_form_model.additional_properties = d - return free_form_model + return cls( + additional_properties=d, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/get_models_allof_response_200.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/get_models_allof_response_200.py index 9ec5f68c8..b64c0bd11 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/get_models_allof_response_200.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/get_models_allof_response_200.py @@ -28,7 +28,7 @@ class GetModelsAllofResponse200: aliased: AModel | Unset = UNSET extended: Extended | Unset = UNSET model: AModel | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: aliased: dict[str, Any] | Unset = UNSET @@ -82,15 +82,13 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: else: model = AModel.from_dict(_model) - get_models_allof_response_200 = cls( + return cls( aliased=aliased, extended=extended, model=model, + additional_properties=d, ) - get_models_allof_response_200.additional_properties = d - return get_models_allof_response_200 - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py index a079b954a..b7fa75ac3 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_0.py @@ -21,7 +21,7 @@ class GetModelsOneofWithRequiredConstResponse200Type0: type_: Literal["alpha"] color: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: type_ = self.type_ @@ -49,14 +49,12 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: color = d.pop("color", UNSET) - get_models_oneof_with_required_const_response_200_type_0 = cls( + return cls( type_=type_, color=color, + additional_properties=d, ) - get_models_oneof_with_required_const_response_200_type_0.additional_properties = d - return get_models_oneof_with_required_const_response_200_type_0 - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py index 04670dcba..b49caa16f 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/get_models_oneof_with_required_const_response_200_type_1.py @@ -21,7 +21,7 @@ class GetModelsOneofWithRequiredConstResponse200Type1: type_: Literal["beta"] texture: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: type_ = self.type_ @@ -49,14 +49,12 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: texture = d.pop("texture", UNSET) - get_models_oneof_with_required_const_response_200_type_1 = cls( + return cls( type_=type_, texture=texture, + additional_properties=d, ) - get_models_oneof_with_required_const_response_200_type_1.additional_properties = d - return get_models_oneof_with_required_const_response_200_type_1 - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/http_validation_error.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/http_validation_error.py index 7ed970dde..2de396e58 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/http_validation_error.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/http_validation_error.py @@ -53,8 +53,6 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: detail.append(detail_item) - http_validation_error = cls( + return cls( detail=detail, ) - - return http_validation_error diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/import_.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/import_.py index a24ec3f3d..014b7f7bf 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/import_.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/import_.py @@ -11,7 +11,7 @@ @_attrs_define class Import: - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -23,10 +23,10 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - import_ = cls() - import_.additional_properties = d - return import_ + return cls( + additional_properties=d, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/json_like_body.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/json_like_body.py index 4e60f7ab6..c5b60c6a7 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/json_like_body.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/json_like_body.py @@ -19,7 +19,7 @@ class JsonLikeBody: """ a: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: a = self.a @@ -37,13 +37,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) a = d.pop("a", UNSET) - json_like_body = cls( + return cls( a=a, + additional_properties=d, ) - json_like_body.additional_properties = d - return json_like_body - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/mixed_case_response_200.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/mixed_case_response_200.py index 93aead870..0a498a358 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/mixed_case_response_200.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/mixed_case_response_200.py @@ -21,7 +21,7 @@ class MixedCaseResponse200: mixed_case: str | Unset = UNSET mixedCase: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: mixed_case = self.mixed_case @@ -45,14 +45,12 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: mixedCase = d.pop("mixedCase", UNSET) - mixed_case_response_200 = cls( + return cls( mixed_case=mixed_case, mixedCase=mixedCase, + additional_properties=d, ) - mixed_case_response_200.additional_properties = d - return mixed_case_response_200 - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_from_all_of.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_from_all_of.py index a8abde58a..daa5563d3 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_from_all_of.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_from_all_of.py @@ -27,7 +27,7 @@ class ModelFromAllOf: type_: AnotherAllOfSubModelType | Unset = UNSET type_enum: AnotherAllOfSubModelTypeEnum | Unset = UNSET another_sub_property: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: a_sub_property = self.a_sub_property @@ -77,16 +77,14 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: another_sub_property = d.pop("another_sub_property", UNSET) - model_from_all_of = cls( + return cls( a_sub_property=a_sub_property, type_=type_, type_enum=type_enum, another_sub_property=another_sub_property, + additional_properties=d, ) - model_from_all_of.additional_properties = d - return model_from_all_of - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_name.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_name.py index 24703fa14..d0457d385 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_name.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_name.py @@ -11,7 +11,7 @@ @_attrs_define class ModelName: - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -23,10 +23,10 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - model_name = cls() - model_name.additional_properties = d - return model_name + return cls( + additional_properties=d, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_reference_with_periods.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_reference_with_periods.py index 52caf65bb..fd91cfde4 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_reference_with_periods.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_reference_with_periods.py @@ -13,7 +13,7 @@ class ModelReferenceWithPeriods: """A Model with periods in its reference""" - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -25,10 +25,10 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - model_reference_with_periods = cls() - model_reference_with_periods.additional_properties = d - return model_reference_with_periods + return cls( + additional_properties=d, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_additional_properties_inlined.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_additional_properties_inlined.py index c1ca5e44c..f9d5701f5 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_additional_properties_inlined.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_additional_properties_inlined.py @@ -26,7 +26,7 @@ class ModelWithAdditionalPropertiesInlined: a_number: float | Unset = UNSET additional_properties: dict[str, ModelWithAdditionalPropertiesInlinedAdditionalProperty] = _attrs_field( - init=False, factory=dict + factory=dict ) def to_dict(self) -> dict[str, Any]: @@ -51,18 +51,16 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) a_number = d.pop("a_number", UNSET) - model_with_additional_properties_inlined = cls( - a_number=a_number, - ) - additional_properties = {} for prop_name, prop_dict in d.items(): additional_property = ModelWithAdditionalPropertiesInlinedAdditionalProperty.from_dict(prop_dict) additional_properties[prop_name] = additional_property - model_with_additional_properties_inlined.additional_properties = additional_properties - return model_with_additional_properties_inlined + return cls( + a_number=a_number, + additional_properties=additional_properties, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py index 8f877a575..3806e4a00 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_additional_properties_inlined_additional_property.py @@ -19,7 +19,7 @@ class ModelWithAdditionalPropertiesInlinedAdditionalProperty: """ extra_props_prop: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: extra_props_prop = self.extra_props_prop @@ -37,13 +37,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) extra_props_prop = d.pop("extra_props_prop", UNSET) - model_with_additional_properties_inlined_additional_property = cls( + return cls( extra_props_prop=extra_props_prop, + additional_properties=d, ) - model_with_additional_properties_inlined_additional_property.additional_properties = d - return model_with_additional_properties_inlined_additional_property - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_additional_properties_refed.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_additional_properties_refed.py index a7ef955fd..7da4c8695 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_additional_properties_refed.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_additional_properties_refed.py @@ -13,7 +13,7 @@ @_attrs_define class ModelWithAdditionalPropertiesRefed: - additional_properties: dict[str, AnEnum] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, AnEnum] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -26,7 +26,6 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - model_with_additional_properties_refed = cls() additional_properties = {} for prop_name, prop_dict in d.items(): @@ -34,8 +33,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: additional_properties[prop_name] = additional_property - model_with_additional_properties_refed.additional_properties = additional_properties - return model_with_additional_properties_refed + return cls( + additional_properties=additional_properties, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_any_json_properties.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_any_json_properties.py index f3d23571c..7f6ee6892 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_any_json_properties.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_any_json_properties.py @@ -19,7 +19,7 @@ class ModelWithAnyJsonProperties: additional_properties: dict[ str, bool | float | int | list[str] | ModelWithAnyJsonPropertiesAdditionalPropertyType0 | str - ] = _attrs_field(init=False, factory=dict) + ] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: from ..models.model_with_any_json_properties_additional_property_type_0 import ( @@ -45,7 +45,6 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: ) d = dict(src_dict) - model_with_any_json_properties = cls() additional_properties = {} for prop_name, prop_dict in d.items(): @@ -77,8 +76,9 @@ def _parse_additional_property( additional_properties[prop_name] = additional_property - model_with_any_json_properties.additional_properties = additional_properties - return model_with_any_json_properties + return cls( + additional_properties=additional_properties, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py index 9d75dc52c..0bf388c70 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_any_json_properties_additional_property_type_0.py @@ -11,7 +11,7 @@ @_attrs_define class ModelWithAnyJsonPropertiesAdditionalPropertyType0: - additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, str] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -23,10 +23,10 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - model_with_any_json_properties_additional_property_type_0 = cls() - model_with_any_json_properties_additional_property_type_0.additional_properties = d - return model_with_any_json_properties_additional_property_type_0 + return cls( + additional_properties=d, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_backslash_in_description.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_backslash_in_description.py index 3492b738f..5c1b9e442 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_backslash_in_description.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_backslash_in_description.py @@ -15,7 +15,7 @@ class ModelWithBackslashInDescription: """ - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -27,10 +27,10 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - model_with_backslash_in_description = cls() - model_with_backslash_in_description.additional_properties = d - return model_with_backslash_in_description + return cls( + additional_properties=d, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_circular_ref_a.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_circular_ref_a.py index a9bde2daf..1f478bcac 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_circular_ref_a.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_circular_ref_a.py @@ -23,7 +23,7 @@ class ModelWithCircularRefA: """ circular: ModelWithCircularRefB | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: circular: dict[str, Any] | Unset = UNSET @@ -50,13 +50,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: else: circular = ModelWithCircularRefB.from_dict(_circular) - model_with_circular_ref_a = cls( + return cls( circular=circular, + additional_properties=d, ) - model_with_circular_ref_a.additional_properties = d - return model_with_circular_ref_a - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_circular_ref_b.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_circular_ref_b.py index c21d33148..8100b959e 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_circular_ref_b.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_circular_ref_b.py @@ -23,7 +23,7 @@ class ModelWithCircularRefB: """ circular: ModelWithCircularRefA | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: circular: dict[str, Any] | Unset = UNSET @@ -50,13 +50,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: else: circular = ModelWithCircularRefA.from_dict(_circular) - model_with_circular_ref_b = cls( + return cls( circular=circular, + additional_properties=d, ) - model_with_circular_ref_b.additional_properties = d - return model_with_circular_ref_b - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py index fdc790779..250ba0324 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py @@ -15,9 +15,7 @@ @_attrs_define class ModelWithCircularRefInAdditionalPropertiesA: - additional_properties: dict[str, ModelWithCircularRefInAdditionalPropertiesB] = _attrs_field( - init=False, factory=dict - ) + additional_properties: dict[str, ModelWithCircularRefInAdditionalPropertiesB] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -34,7 +32,6 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: ) d = dict(src_dict) - model_with_circular_ref_in_additional_properties_a = cls() additional_properties = {} for prop_name, prop_dict in d.items(): @@ -42,8 +39,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: additional_properties[prop_name] = additional_property - model_with_circular_ref_in_additional_properties_a.additional_properties = additional_properties - return model_with_circular_ref_in_additional_properties_a + return cls( + additional_properties=additional_properties, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py index 1c3f1998c..20bf9504c 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py @@ -15,9 +15,7 @@ @_attrs_define class ModelWithCircularRefInAdditionalPropertiesB: - additional_properties: dict[str, ModelWithCircularRefInAdditionalPropertiesA] = _attrs_field( - init=False, factory=dict - ) + additional_properties: dict[str, ModelWithCircularRefInAdditionalPropertiesA] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -34,7 +32,6 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: ) d = dict(src_dict) - model_with_circular_ref_in_additional_properties_b = cls() additional_properties = {} for prop_name, prop_dict in d.items(): @@ -42,8 +39,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: additional_properties[prop_name] = additional_property - model_with_circular_ref_in_additional_properties_b.additional_properties = additional_properties - return model_with_circular_ref_in_additional_properties_b + return cls( + additional_properties=additional_properties, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_date_time_property.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_date_time_property.py index b005efa02..a7619ad87 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_date_time_property.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_date_time_property.py @@ -20,7 +20,7 @@ class ModelWithDateTimeProperty: """ datetime_: datetime.datetime | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: datetime_: str | Unset = UNSET @@ -45,13 +45,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: else: datetime_ = datetime.datetime.fromisoformat(_datetime_) - model_with_date_time_property = cls( + return cls( datetime_=datetime_, + additional_properties=d, ) - model_with_date_time_property.additional_properties = d - return model_with_date_time_property - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_discriminated_union.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_discriminated_union.py index 41b972dc4..942f7086c 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_discriminated_union.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_discriminated_union.py @@ -24,7 +24,7 @@ class ModelWithDiscriminatedUnion: """ discriminated_union: ADiscriminatedUnionType1 | ADiscriminatedUnionType2 | None | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: from ..models.a_discriminated_union_type_1 import ADiscriminatedUnionType1 # noqa: PLC0415 @@ -82,13 +82,11 @@ def _parse_discriminated_union( discriminated_union = _parse_discriminated_union(d.pop("discriminated_union", UNSET)) - model_with_discriminated_union = cls( + return cls( discriminated_union=discriminated_union, + additional_properties=d, ) - model_with_discriminated_union.additional_properties = d - return model_with_discriminated_union - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_merged_properties.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_merged_properties.py index 1ee8b4a61..99b890922 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_merged_properties.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_merged_properties.py @@ -30,7 +30,7 @@ class ModelWithMergedProperties: string_to_date: datetime.date | Unset = UNSET number_to_int: int | Unset = UNSET any_to_string: str | Unset = "x" - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: simple_string = self.simple_string @@ -86,17 +86,15 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: any_to_string = d.pop("anyToString", UNSET) - model_with_merged_properties = cls( + return cls( simple_string=simple_string, string_to_enum=string_to_enum, string_to_date=string_to_date, number_to_int=number_to_int, any_to_string=any_to_string, + additional_properties=d, ) - model_with_merged_properties.additional_properties = d - return model_with_merged_properties - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_no_properties.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_no_properties.py index 32eba322b..da0c29803 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_no_properties.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_no_properties.py @@ -18,6 +18,4 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: - model_with_no_properties = cls() - - return model_with_no_properties + return cls() diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_primitive_additional_properties.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_primitive_additional_properties.py index f4d01fd3f..6a4648712 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_primitive_additional_properties.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_primitive_additional_properties.py @@ -25,7 +25,7 @@ class ModelWithPrimitiveAdditionalProperties: """ a_date_holder: ModelWithPrimitiveAdditionalPropertiesADateHolder | Unset = UNSET - additional_properties: dict[str, str] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, str] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: a_date_holder: dict[str, Any] | Unset = UNSET @@ -54,13 +54,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: else: a_date_holder = ModelWithPrimitiveAdditionalPropertiesADateHolder.from_dict(_a_date_holder) - model_with_primitive_additional_properties = cls( + return cls( a_date_holder=a_date_holder, + additional_properties=d, ) - model_with_primitive_additional_properties.additional_properties = d - return model_with_primitive_additional_properties - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py index f5a15805d..a20603579 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py @@ -12,7 +12,7 @@ @_attrs_define class ModelWithPrimitiveAdditionalPropertiesADateHolder: - additional_properties: dict[str, datetime.datetime] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, datetime.datetime] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -25,7 +25,6 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - model_with_primitive_additional_properties_a_date_holder = cls() additional_properties = {} for prop_name, prop_dict in d.items(): @@ -33,8 +32,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: additional_properties[prop_name] = additional_property - model_with_primitive_additional_properties_a_date_holder.additional_properties = additional_properties - return model_with_primitive_additional_properties_a_date_holder + return cls( + additional_properties=additional_properties, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_property_ref.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_property_ref.py index 622c94fa4..038150339 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_property_ref.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_property_ref.py @@ -23,7 +23,7 @@ class ModelWithPropertyRef: """ inner: ModelName | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: inner: dict[str, Any] | Unset = UNSET @@ -50,13 +50,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: else: inner = ModelName.from_dict(_inner) - model_with_property_ref = cls( + return cls( inner=inner, + additional_properties=d, ) - model_with_property_ref.additional_properties = d - return model_with_property_ref - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_recursive_ref.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_recursive_ref.py index d4149434c..6663d473b 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_recursive_ref.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_recursive_ref.py @@ -19,7 +19,7 @@ class ModelWithRecursiveRef: """ recursive: ModelWithRecursiveRef | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: recursive: dict[str, Any] | Unset = UNSET @@ -44,13 +44,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: else: recursive = ModelWithRecursiveRef.from_dict(_recursive) - model_with_recursive_ref = cls( + return cls( recursive=recursive, + additional_properties=d, ) - model_with_recursive_ref.additional_properties = d - return model_with_recursive_ref - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py index f31d2f88d..54c521f73 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py @@ -11,9 +11,7 @@ @_attrs_define class ModelWithRecursiveRefInAdditionalProperties: - additional_properties: dict[str, ModelWithRecursiveRefInAdditionalProperties] = _attrs_field( - init=False, factory=dict - ) + additional_properties: dict[str, ModelWithRecursiveRefInAdditionalProperties] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -26,7 +24,6 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - model_with_recursive_ref_in_additional_properties = cls() additional_properties = {} for prop_name, prop_dict in d.items(): @@ -34,8 +31,9 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: additional_properties[prop_name] = additional_property - model_with_recursive_ref_in_additional_properties.additional_properties = additional_properties - return model_with_recursive_ref_in_additional_properties + return cls( + additional_properties=additional_properties, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_self_named_property.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_self_named_property.py new file mode 100644 index 000000000..2a1976333 --- /dev/null +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_self_named_property.py @@ -0,0 +1,60 @@ +from __future__ import annotations + +import datetime +from collections.abc import Mapping +from typing import Any, TypeVar + +from attrs import define as _attrs_define +from attrs import field as _attrs_field + +T = TypeVar("T", bound="ModelWithSelfNamedProperty") + + +@_attrs_define +class ModelWithSelfNamedProperty: + """ + Attributes: + model_with_self_named_property (datetime.date): + """ + + model_with_self_named_property: datetime.date + additional_properties: dict[str, Any] = _attrs_field(factory=dict) + + def to_dict(self) -> dict[str, Any]: + model_with_self_named_property = self.model_with_self_named_property.isoformat() + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "model_with_self_named_property": model_with_self_named_property, + } + ) + + return field_dict + + @classmethod + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + model_with_self_named_property = datetime.date.fromisoformat(d.pop("model_with_self_named_property")) + + return cls( + model_with_self_named_property=model_with_self_named_property, + additional_properties=d, + ) + + @property + def additional_keys(self) -> list[str]: + return list(self.additional_properties.keys()) + + def __getitem__(self, key: str) -> Any: + return self.additional_properties[key] + + def __setitem__(self, key: str, value: Any) -> None: + self.additional_properties[key] = value + + def __delitem__(self, key: str) -> None: + del self.additional_properties[key] + + def __contains__(self, key: str) -> bool: + return key in self.additional_properties diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_union_property.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_union_property.py index 176b3eadc..6a118d642 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_union_property.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_union_property.py @@ -61,8 +61,6 @@ def _parse_a_property(data: object) -> AnEnum | AnIntEnum | Unset: a_property = _parse_a_property(d.pop("a_property", UNSET)) - model_with_union_property = cls( + return cls( a_property=a_property, ) - - return model_with_union_property diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_union_property_inlined.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_union_property_inlined.py index fbce31507..070634b62 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_union_property_inlined.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_union_property_inlined.py @@ -77,8 +77,6 @@ def _parse_fruit( fruit = _parse_fruit(d.pop("fruit", UNSET)) - model_with_union_property_inlined = cls( + return cls( fruit=fruit, ) - - return model_with_union_property_inlined diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_union_property_inlined_apples.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_union_property_inlined_apples.py index 0ad6f0cf2..c3664b24e 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_union_property_inlined_apples.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_union_property_inlined_apples.py @@ -19,7 +19,7 @@ class ModelWithUnionPropertyInlinedApples: """ apples: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: apples = self.apples @@ -37,13 +37,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) apples = d.pop("apples", UNSET) - model_with_union_property_inlined_apples = cls( + return cls( apples=apples, + additional_properties=d, ) - model_with_union_property_inlined_apples.additional_properties = d - return model_with_union_property_inlined_apples - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_union_property_inlined_bananas.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_union_property_inlined_bananas.py index 68a54e760..a66f5805c 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_union_property_inlined_bananas.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/model_with_union_property_inlined_bananas.py @@ -19,7 +19,7 @@ class ModelWithUnionPropertyInlinedBananas: """ bananas: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: bananas = self.bananas @@ -37,13 +37,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) bananas = d.pop("bananas", UNSET) - model_with_union_property_inlined_bananas = cls( + return cls( bananas=bananas, + additional_properties=d, ) - model_with_union_property_inlined_bananas.additional_properties = d - return model_with_union_property_inlined_bananas - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/none.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/none.py index 6f7fa6047..c54dafe20 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/none.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/none.py @@ -11,7 +11,7 @@ @_attrs_define class None_: - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -23,10 +23,10 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - none = cls() - none.additional_properties = d - return none + return cls( + additional_properties=d, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/octet_stream_tests_octet_stream_post_response_200.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/octet_stream_tests_octet_stream_post_response_200.py index 8d138937a..66144b933 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/octet_stream_tests_octet_stream_post_response_200.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/octet_stream_tests_octet_stream_post_response_200.py @@ -20,7 +20,7 @@ class OctetStreamTestsOctetStreamPostResponse200: """ data: File | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: data: FileTypes | Unset = UNSET @@ -45,13 +45,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: else: data = File(payload=BytesIO(_data)) - octet_stream_tests_octet_stream_post_response_200 = cls( + return cls( data=data, + additional_properties=d, ) - octet_stream_tests_octet_stream_post_response_200.additional_properties = d - return octet_stream_tests_octet_stream_post_response_200 - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/optional_body_body.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/optional_body_body.py index 064beb792..1d4866869 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/optional_body_body.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/optional_body_body.py @@ -11,7 +11,7 @@ @_attrs_define class OptionalBodyBody: - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -23,10 +23,10 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - optional_body_body = cls() - optional_body_body.additional_properties = d - return optional_body_body + return cls( + additional_properties=d, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_bodies_multiple_data_body.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_bodies_multiple_data_body.py index d83f8d7eb..720f4ad28 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_bodies_multiple_data_body.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_bodies_multiple_data_body.py @@ -19,7 +19,7 @@ class PostBodiesMultipleDataBody: """ a: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: a = self.a @@ -37,13 +37,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) a = d.pop("a", UNSET) - post_bodies_multiple_data_body = cls( + return cls( a=a, + additional_properties=d, ) - post_bodies_multiple_data_body.additional_properties = d - return post_bodies_multiple_data_body - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_bodies_multiple_files_body.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_bodies_multiple_files_body.py index 81d7db7a7..0d3e07c1e 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_bodies_multiple_files_body.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_bodies_multiple_files_body.py @@ -20,7 +20,7 @@ class PostBodiesMultipleFilesBody: """ a: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: a = self.a @@ -49,13 +49,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) a = d.pop("a", UNSET) - post_bodies_multiple_files_body = cls( + return cls( a=a, + additional_properties=d, ) - post_bodies_multiple_files_body.additional_properties = d - return post_bodies_multiple_files_body - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_bodies_multiple_json_body.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_bodies_multiple_json_body.py index a5ec152e9..015054fca 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_bodies_multiple_json_body.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_bodies_multiple_json_body.py @@ -19,7 +19,7 @@ class PostBodiesMultipleJsonBody: """ a: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: a = self.a @@ -37,13 +37,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) a = d.pop("a", UNSET) - post_bodies_multiple_json_body = cls( + return cls( a=a, + additional_properties=d, ) - post_bodies_multiple_json_body.additional_properties = d - return post_bodies_multiple_json_body - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_form_data_inline_body.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_form_data_inline_body.py index 5d7c3982b..cc99a9e1c 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_form_data_inline_body.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_form_data_inline_body.py @@ -21,7 +21,7 @@ class PostFormDataInlineBody: a_required_field: str an_optional_field: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: a_required_field = self.a_required_field @@ -47,14 +47,12 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: an_optional_field = d.pop("an_optional_field", UNSET) - post_form_data_inline_body = cls( + return cls( a_required_field=a_required_field, an_optional_field=an_optional_field, + additional_properties=d, ) - post_form_data_inline_body.additional_properties = d - return post_form_data_inline_body - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_naming_property_conflict_with_import_body.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_naming_property_conflict_with_import_body.py index 2895d97d8..7f049211a 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_naming_property_conflict_with_import_body.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_naming_property_conflict_with_import_body.py @@ -21,7 +21,7 @@ class PostNamingPropertyConflictWithImportBody: field: str | Unset = UNSET define: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: field = self.field @@ -45,14 +45,12 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: define = d.pop("Define", UNSET) - post_naming_property_conflict_with_import_body = cls( + return cls( field=field, define=define, + additional_properties=d, ) - post_naming_property_conflict_with_import_body.additional_properties = d - return post_naming_property_conflict_with_import_body - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_naming_property_conflict_with_import_response_200.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_naming_property_conflict_with_import_response_200.py index c2a8ac7f3..efd509122 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_naming_property_conflict_with_import_response_200.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_naming_property_conflict_with_import_response_200.py @@ -21,7 +21,7 @@ class PostNamingPropertyConflictWithImportResponse200: field: str | Unset = UNSET define: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: field = self.field @@ -45,14 +45,12 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: define = d.pop("Define", UNSET) - post_naming_property_conflict_with_import_response_200 = cls( + return cls( field=field, define=define, + additional_properties=d, ) - post_naming_property_conflict_with_import_response_200.additional_properties = d - return post_naming_property_conflict_with_import_response_200 - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py index 205a1cd30..e0f576fc7 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200.py @@ -23,7 +23,7 @@ class PostResponsesUnionsSimpleBeforeComplexResponse200: """ a: PostResponsesUnionsSimpleBeforeComplexResponse200AType1 | str - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: from ..models.post_responses_unions_simple_before_complex_response_200a_type_1 import ( @@ -67,13 +67,11 @@ def _parse_a(data: object) -> PostResponsesUnionsSimpleBeforeComplexResponse200A a = _parse_a(d.pop("a")) - post_responses_unions_simple_before_complex_response_200 = cls( + return cls( a=a, + additional_properties=d, ) - post_responses_unions_simple_before_complex_response_200.additional_properties = d - return post_responses_unions_simple_before_complex_response_200 - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py index 2b6169b11..b2e95fea5 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/post_responses_unions_simple_before_complex_response_200a_type_1.py @@ -11,7 +11,7 @@ @_attrs_define class PostResponsesUnionsSimpleBeforeComplexResponse200AType1: - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: @@ -23,10 +23,10 @@ def to_dict(self) -> dict[str, Any]: @classmethod def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) - post_responses_unions_simple_before_complex_response_200a_type_1 = cls() - post_responses_unions_simple_before_complex_response_200a_type_1.additional_properties = d - return post_responses_unions_simple_before_complex_response_200a_type_1 + return cls( + additional_properties=d, + ) @property def additional_keys(self) -> list[str]: diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/status_code_patterns_response_2xx.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/status_code_patterns_response_2xx.py index 61e806ff9..5ee632dc0 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/status_code_patterns_response_2xx.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/status_code_patterns_response_2xx.py @@ -20,7 +20,7 @@ class StatusCodePatternsResponse2XX: """ status: StatusCodePatternsResponse2XXStatus | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: status: str | Unset = UNSET @@ -45,13 +45,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: else: status = StatusCodePatternsResponse2XXStatus(_status) - status_code_patterns_response_2xx = cls( + return cls( status=status, + additional_properties=d, ) - status_code_patterns_response_2xx.additional_properties = d - return status_code_patterns_response_2xx - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/status_code_patterns_response_4xx.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/status_code_patterns_response_4xx.py index f62c4168a..7ddc77d84 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/status_code_patterns_response_4xx.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/status_code_patterns_response_4xx.py @@ -19,7 +19,7 @@ class StatusCodePatternsResponse4XX: """ error: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: error = self.error @@ -37,13 +37,11 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) error = d.pop("error", UNSET) - status_code_patterns_response_4xx = cls( + return cls( error=error, + additional_properties=d, ) - status_code_patterns_response_4xx.additional_properties = d - return status_code_patterns_response_4xx - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/test_inline_objects_body.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/test_inline_objects_body.py index 73b054b24..3393367bc 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/test_inline_objects_body.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/test_inline_objects_body.py @@ -35,8 +35,6 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) a_property = d.pop("a_property", UNSET) - test_inline_objects_body = cls( + return cls( a_property=a_property, ) - - return test_inline_objects_body diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/test_inline_objects_response_200.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/test_inline_objects_response_200.py index 174a5957b..3ae8d4fa1 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/test_inline_objects_response_200.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/test_inline_objects_response_200.py @@ -35,8 +35,6 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: d = dict(src_dict) a_property = d.pop("a_property", UNSET) - test_inline_objects_response_200 = cls( + return cls( a_property=a_property, ) - - return test_inline_objects_response_200 diff --git a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/validation_error.py b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/validation_error.py index 9bb9070d6..11f8c2b8e 100644 --- a/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/validation_error.py +++ b/end_to_end_tests/golden-records/my-test-api-client/my_test_api_client/models/validation_error.py @@ -49,10 +49,8 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: type_ = d.pop("type") - validation_error = cls( + return cls( loc=loc, msg=msg, type_=type_, ) - - return validation_error diff --git a/end_to_end_tests/golden-records/test-3-1-features-client/test_3_1_features_client/models/post_const_path_body.py b/end_to_end_tests/golden-records/test-3-1-features-client/test_3_1_features_client/models/post_const_path_body.py index f59894f08..4aef9dacb 100644 --- a/end_to_end_tests/golden-records/test-3-1-features-client/test_3_1_features_client/models/post_const_path_body.py +++ b/end_to_end_tests/golden-records/test-3-1-features-client/test_3_1_features_client/models/post_const_path_body.py @@ -23,7 +23,7 @@ class PostConstPathBody: required: Literal["this always goes in the body"] nullable: Literal["this or null goes in the body"] | None optional: Literal["this sometimes goes in the body"] | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: required = self.required @@ -70,15 +70,13 @@ def _parse_nullable(data: object) -> Literal["this or null goes in the body"] | if optional != "this sometimes goes in the body" and not isinstance(optional, Unset): raise ValueError(f"optional must match const 'this sometimes goes in the body', got '{optional}'") - post_const_path_body = cls( + return cls( required=required, nullable=nullable, optional=optional, + additional_properties=d, ) - post_const_path_body.additional_properties = d - return post_const_path_body - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/end_to_end_tests/golden-records/test-3-1-features-client/test_3_1_features_client/models/post_prefix_items_body.py b/end_to_end_tests/golden-records/test-3-1-features-client/test_3_1_features_client/models/post_prefix_items_body.py index b074bb717..0ccfbbc62 100644 --- a/end_to_end_tests/golden-records/test-3-1-features-client/test_3_1_features_client/models/post_prefix_items_body.py +++ b/end_to_end_tests/golden-records/test-3-1-features-client/test_3_1_features_client/models/post_prefix_items_body.py @@ -21,7 +21,7 @@ class PostPrefixItemsBody: prefix_items_and_items: list[float | Literal["prefix"] | str] | Unset = UNSET prefix_items_only: list[float | str] | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: prefix_items_and_items: list[float | Literal["prefix"] | str] | Unset = UNSET @@ -85,14 +85,12 @@ def _parse_prefix_items_only_item(data: object) -> float | str: prefix_items_only.append(prefix_items_only_item) - post_prefix_items_body = cls( + return cls( prefix_items_and_items=prefix_items_and_items, prefix_items_only=prefix_items_only, + additional_properties=d, ) - post_prefix_items_body.additional_properties = d - return post_prefix_items_body - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/integration-tests/integration_tests/models/an_object.py b/integration-tests/integration_tests/models/an_object.py index 228568b8c..4069fb804 100644 --- a/integration-tests/integration_tests/models/an_object.py +++ b/integration-tests/integration_tests/models/an_object.py @@ -19,7 +19,7 @@ class AnObject: an_int: int a_float: float - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: an_int = self.an_int @@ -44,14 +44,12 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: a_float = d.pop("a_float") - an_object = cls( + return cls( an_int=an_int, a_float=a_float, + additional_properties=d, ) - an_object.additional_properties = d - return an_object - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/integration-tests/integration_tests/models/file.py b/integration-tests/integration_tests/models/file.py index 2380e8737..d240c1400 100644 --- a/integration-tests/integration_tests/models/file.py +++ b/integration-tests/integration_tests/models/file.py @@ -23,7 +23,7 @@ class File: data: str | Unset = UNSET name: str | Unset = UNSET content_type: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: data = self.data @@ -53,15 +53,13 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: content_type = d.pop("content_type", UNSET) - file = cls( + return cls( data=data, name=name, content_type=content_type, + additional_properties=d, ) - file.additional_properties = d - return file - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/integration-tests/integration_tests/models/post_body_multipart_body.py b/integration-tests/integration_tests/models/post_body_multipart_body.py index 0882f881b..648617bc8 100644 --- a/integration-tests/integration_tests/models/post_body_multipart_body.py +++ b/integration-tests/integration_tests/models/post_body_multipart_body.py @@ -35,7 +35,7 @@ class PostBodyMultipartBody: description: str objects: list[AnObject] times: list[datetime.datetime] - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: a_string = self.a_string @@ -123,17 +123,15 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: times.append(times_item) - post_body_multipart_body = cls( + return cls( a_string=a_string, files=files, description=description, objects=objects, times=times, + additional_properties=d, ) - post_body_multipart_body.additional_properties = d - return post_body_multipart_body - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/integration-tests/integration_tests/models/post_body_multipart_response_200.py b/integration-tests/integration_tests/models/post_body_multipart_response_200.py index be63512d2..3c4fa9ab6 100644 --- a/integration-tests/integration_tests/models/post_body_multipart_response_200.py +++ b/integration-tests/integration_tests/models/post_body_multipart_response_200.py @@ -31,7 +31,7 @@ class PostBodyMultipartResponse200: files: list[File] times: list[datetime.datetime] objects: list[AnObject] - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: a_string = self.a_string @@ -98,17 +98,15 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: objects.append(objects_item) - post_body_multipart_response_200 = cls( + return cls( a_string=a_string, description=description, files=files, times=times, objects=objects, + additional_properties=d, ) - post_body_multipart_response_200.additional_properties = d - return post_body_multipart_response_200 - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/integration-tests/integration_tests/models/post_parameters_header_response_200.py b/integration-tests/integration_tests/models/post_parameters_header_response_200.py index d5baeabbd..17c520c2b 100644 --- a/integration-tests/integration_tests/models/post_parameters_header_response_200.py +++ b/integration-tests/integration_tests/models/post_parameters_header_response_200.py @@ -23,7 +23,7 @@ class PostParametersHeaderResponse200: string: str number: float integer: int - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: boolean = self.boolean @@ -58,16 +58,14 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: integer = d.pop("integer") - post_parameters_header_response_200 = cls( + return cls( boolean=boolean, string=string, number=number, integer=integer, + additional_properties=d, ) - post_parameters_header_response_200.additional_properties = d - return post_parameters_header_response_200 - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/integration-tests/integration_tests/models/problem.py b/integration-tests/integration_tests/models/problem.py index a7f270874..8c6faafeb 100644 --- a/integration-tests/integration_tests/models/problem.py +++ b/integration-tests/integration_tests/models/problem.py @@ -21,7 +21,7 @@ class Problem: parameter_name: str | Unset = UNSET description: str | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: parameter_name = self.parameter_name @@ -45,14 +45,12 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: description = d.pop("description", UNSET) - problem = cls( + return cls( parameter_name=parameter_name, description=description, + additional_properties=d, ) - problem.additional_properties = d - return problem - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/integration-tests/integration_tests/models/public_error.py b/integration-tests/integration_tests/models/public_error.py index b4ca256d2..ab70635e4 100644 --- a/integration-tests/integration_tests/models/public_error.py +++ b/integration-tests/integration_tests/models/public_error.py @@ -29,7 +29,7 @@ class PublicError: extra_parameters: list[str] | Unset = UNSET invalid_parameters: list[Problem] | Unset = UNSET missing_parameters: list[str] | Unset = UNSET - additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, Any] = _attrs_field(factory=dict) def to_dict(self) -> dict[str, Any]: errors: list[str] | Unset = UNSET @@ -85,16 +85,14 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: missing_parameters = cast(list[str], d.pop("missing_parameters", UNSET)) - public_error = cls( + return cls( errors=errors, extra_parameters=extra_parameters, invalid_parameters=invalid_parameters, missing_parameters=missing_parameters, + additional_properties=d, ) - public_error.additional_properties = d - return public_error - @property def additional_keys(self) -> list[str]: return list(self.additional_properties.keys()) diff --git a/openapi_python_client/templates/model.py.jinja b/openapi_python_client/templates/model.py.jinja index 141635127..d5b4d2dcf 100644 --- a/openapi_python_client/templates/model.py.jinja +++ b/openapi_python_client/templates/model.py.jinja @@ -29,7 +29,6 @@ if TYPE_CHECKING: {% endif %} {% set class_name = model.class_info.name %} -{% set module_name = model.class_info.module_name %} {% from "helpers.jinja" import docstring %} @@ -82,7 +81,7 @@ class {{ class_name }}: {% endif %} {% endfor %} {% if model.additional_properties %} - additional_properties: dict[str, {{ additional_property_type }}] = _attrs_field(init=False, factory=dict) + additional_properties: dict[str, {{ additional_property_type }}] = _attrs_field(factory=dict) {% endif %} {% macro _transform_property(property, content) %} @@ -193,12 +192,6 @@ return field_dict {% endfor %} {% endif %} - {{ module_name }} = cls( -{% for property in model.required_properties + model.optional_properties %} - {{ property.python_name }}={{ property.python_name }}, -{% endfor %} - ) - {% if model.additional_properties %} {% if model.additional_properties.template %}{# Can be a bool instead of an object #} {% import "property_templates/" + model.additional_properties.template as prop_template %} @@ -217,12 +210,19 @@ return field_dict {{ prop_template.construct(model.additional_properties, "prop_dict") | indent(12) }} additional_properties[prop_name] = {{ model.additional_properties.python_name }} - {{ module_name }}.additional_properties = additional_properties + {% set additional_properties_expr = "additional_properties" %} {% else %} - {{ module_name }}.additional_properties = d + {% set additional_properties_expr = "d" %} {% endif %} {% endif %} - return {{ module_name }} + return cls( +{% for property in model.required_properties + model.optional_properties %} + {{ property.python_name }}={{ property.python_name }}, +{% endfor %} +{% if model.additional_properties %} + additional_properties={{ additional_properties_expr }}, +{% endif %} + ) {% if model.additional_properties %} @property