Skip to content

Commit 7cb82c4

Browse files
fix: Expect a generic Mapping in generated from_dict
1 parent 44b1fbc commit 7cb82c4

File tree

78 files changed

+234
-155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+234
-155
lines changed

end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_description.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from collections.abc import Mapping
12
from typing import Any, TypeVar, Union
23

34
from attrs import define as _attrs_define
@@ -43,8 +44,8 @@ def to_dict(self) -> dict[str, Any]:
4344
return field_dict
4445

4546
@classmethod
46-
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
47-
d = src_dict.copy()
47+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
48+
d = dict(src_dict)
4849
prop_with_no_desc = d.pop("propWithNoDesc", UNSET)
4950

5051
prop_with_desc = d.pop("propWithDesc", UNSET)

end_to_end_tests/docstrings-on-attributes-golden-record/my_test_api_client/models/model_with_no_description.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from collections.abc import Mapping
12
from typing import Any, TypeVar, Union
23

34
from attrs import define as _attrs_define
@@ -31,8 +32,8 @@ def to_dict(self) -> dict[str, Any]:
3132
return field_dict
3233

3334
@classmethod
34-
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
35-
d = src_dict.copy()
35+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
36+
d = dict(src_dict)
3637
prop_with_no_desc = d.pop("propWithNoDesc", UNSET)
3738

3839
prop_with_desc = d.pop("propWithDesc", UNSET)

end_to_end_tests/golden-record/my_test_api_client/models/a_discriminated_union_type_1.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from collections.abc import Mapping
12
from typing import Any, TypeVar, Union
23

34
from attrs import define as _attrs_define
@@ -30,8 +31,8 @@ def to_dict(self) -> dict[str, Any]:
3031
return field_dict
3132

3233
@classmethod
33-
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
34-
d = src_dict.copy()
34+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
35+
d = dict(src_dict)
3536
model_type = d.pop("modelType", UNSET)
3637

3738
a_discriminated_union_type_1 = cls(

end_to_end_tests/golden-record/my_test_api_client/models/a_discriminated_union_type_2.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from collections.abc import Mapping
12
from typing import Any, TypeVar, Union
23

34
from attrs import define as _attrs_define
@@ -30,8 +31,8 @@ def to_dict(self) -> dict[str, Any]:
3031
return field_dict
3132

3233
@classmethod
33-
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
34-
d = src_dict.copy()
34+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
35+
d = dict(src_dict)
3536
model_type = d.pop("modelType", UNSET)
3637

3738
a_discriminated_union_type_2 = cls(

end_to_end_tests/golden-record/my_test_api_client/models/a_form_data.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from collections.abc import Mapping
12
from typing import Any, TypeVar, Union
23

34
from attrs import define as _attrs_define
@@ -38,8 +39,8 @@ def to_dict(self) -> dict[str, Any]:
3839
return field_dict
3940

4041
@classmethod
41-
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
42-
d = src_dict.copy()
42+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
43+
d = dict(src_dict)
4344
an_required_field = d.pop("an_required_field")
4445

4546
an_optional_field = d.pop("an_optional_field", UNSET)

end_to_end_tests/golden-record/my_test_api_client/models/a_model.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import datetime
2+
from collections.abc import Mapping
23
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
34
from uuid import UUID
45

@@ -252,11 +253,11 @@ def to_dict(self) -> dict[str, Any]:
252253
return field_dict
253254

254255
@classmethod
255-
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
256+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
256257
from ..models.free_form_model import FreeFormModel
257258
from ..models.model_with_union_property import ModelWithUnionProperty
258259

259-
d = src_dict.copy()
260+
d = dict(src_dict)
260261
an_enum_value = AnEnum(d.pop("an_enum_value"))
261262

262263
an_allof_enum_with_overridden_default = AnAllOfEnum(d.pop("an_allof_enum_with_overridden_default"))

end_to_end_tests/golden-record/my_test_api_client/models/a_model_with_properties_reference_that_are_not_object.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import datetime
2+
from collections.abc import Mapping
23
from io import BytesIO
34
from typing import Any, TypeVar, cast
45

@@ -213,8 +214,8 @@ def to_dict(self) -> dict[str, Any]:
213214
return field_dict
214215

215216
@classmethod
216-
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
217-
d = src_dict.copy()
217+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
218+
d = dict(src_dict)
218219
enum_properties_ref = []
219220
_enum_properties_ref = d.pop("enum_properties_ref")
220221
for componentsschemas_an_other_array_of_enum_item_data in _enum_properties_ref:

end_to_end_tests/golden-record/my_test_api_client/models/all_of_has_properties_but_no_type.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from collections.abc import Mapping
12
from typing import Any, TypeVar, Union
23

34
from attrs import define as _attrs_define
@@ -45,8 +46,8 @@ def to_dict(self) -> dict[str, Any]:
4546
return field_dict
4647

4748
@classmethod
48-
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
49-
d = src_dict.copy()
49+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
50+
d = dict(src_dict)
5051
a_sub_property = d.pop("a_sub_property", UNSET)
5152

5253
type_ = d.pop("type", UNSET)

end_to_end_tests/golden-record/my_test_api_client/models/all_of_sub_model.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from collections.abc import Mapping
12
from typing import Any, TypeVar, Union
23

34
from attrs import define as _attrs_define
@@ -45,8 +46,8 @@ def to_dict(self) -> dict[str, Any]:
4546
return field_dict
4647

4748
@classmethod
48-
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
49-
d = src_dict.copy()
49+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
50+
d = dict(src_dict)
5051
a_sub_property = d.pop("a_sub_property", UNSET)
5152

5253
type_ = d.pop("type", UNSET)

end_to_end_tests/golden-record/my_test_api_client/models/an_array_with_a_circular_ref_in_items_object_a_item.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from collections.abc import Mapping
12
from typing import TYPE_CHECKING, Any, TypeVar, Union
23

34
from attrs import define as _attrs_define
@@ -41,12 +42,12 @@ def to_dict(self) -> dict[str, Any]:
4142
return field_dict
4243

4344
@classmethod
44-
def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T:
45+
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
4546
from ..models.an_array_with_a_circular_ref_in_items_object_b_item import (
4647
AnArrayWithACircularRefInItemsObjectBItem,
4748
)
4849

49-
d = src_dict.copy()
50+
d = dict(src_dict)
5051
circular = []
5152
_circular = d.pop("circular", UNSET)
5253
for componentsschemas_an_array_with_a_circular_ref_in_items_object_b_item_data in _circular or []:

0 commit comments

Comments
 (0)