Skip to content

Commit 8f7d51b

Browse files
committed
Removed to_dict params and cleaned up type strings
1 parent fb4cb6f commit 8f7d51b

File tree

14 files changed

+157
-220
lines changed

14 files changed

+157
-220
lines changed

end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77
from ...client import Client
88
from ...models.an_enum import AnEnum
99
from ...models.http_validation_error import HTTPValidationError
10-
from ...types import UNSET, Response
10+
from ...types import UNSET, Response, Unset
1111

1212

1313
def _get_kwargs(
1414
*,
1515
client: Client,
1616
json_body: Dict[Any, Any],
17-
string_prop: str = "the default string",
18-
datetime_prop: datetime.datetime = isoparse("1010-10-10T00:00:00"),
19-
date_prop: datetime.date = isoparse("1010-10-10").date(),
20-
float_prop: float = 3.14,
21-
int_prop: int = 7,
22-
boolean_prop: bool = cast(bool, UNSET),
23-
list_prop: List[AnEnum] = cast(List[AnEnum], UNSET),
24-
union_prop: Union[float, str] = "not a float",
25-
enum_prop: AnEnum = cast(AnEnum, UNSET),
17+
string_prop: Union[Unset, str] = "the default string",
18+
datetime_prop: Union[Unset, datetime.datetime] = isoparse("1010-10-10T00:00:00"),
19+
date_prop: Union[Unset, datetime.date] = isoparse("1010-10-10").date(),
20+
float_prop: Union[Unset, float] = 3.14,
21+
int_prop: Union[Unset, int] = 7,
22+
boolean_prop: Union[Unset, bool] = UNSET,
23+
list_prop: Union[Unset, List[AnEnum]] = UNSET,
24+
union_prop: Union[Unset, Union[Union[Unset, float], Union[Unset, str]]] = "not a float",
25+
enum_prop: Union[Unset, AnEnum] = UNSET,
2626
) -> Dict[str, Any]:
2727
url = "{}/tests/defaults".format(client.base_url)
2828

@@ -48,7 +48,7 @@ def _get_kwargs(
4848
json_list_prop.append(list_prop_item)
4949

5050
if union_prop is UNSET:
51-
json_union_prop: Union[float, str] = UNSET
51+
json_union_prop: Union[Unset, Union[Union[Unset, float], Union[Unset, str]]] = UNSET
5252
elif isinstance(union_prop, float):
5353
json_union_prop = union_prop
5454
else:
@@ -112,15 +112,15 @@ def sync_detailed(
112112
*,
113113
client: Client,
114114
json_body: Dict[Any, Any],
115-
string_prop: str = "the default string",
116-
datetime_prop: datetime.datetime = isoparse("1010-10-10T00:00:00"),
117-
date_prop: datetime.date = isoparse("1010-10-10").date(),
118-
float_prop: float = 3.14,
119-
int_prop: int = 7,
120-
boolean_prop: bool = cast(bool, UNSET),
121-
list_prop: List[AnEnum] = cast(List[AnEnum], UNSET),
122-
union_prop: Union[float, str] = "not a float",
123-
enum_prop: AnEnum = cast(AnEnum, UNSET),
115+
string_prop: Union[Unset, str] = "the default string",
116+
datetime_prop: Union[Unset, datetime.datetime] = isoparse("1010-10-10T00:00:00"),
117+
date_prop: Union[Unset, datetime.date] = isoparse("1010-10-10").date(),
118+
float_prop: Union[Unset, float] = 3.14,
119+
int_prop: Union[Unset, int] = 7,
120+
boolean_prop: Union[Unset, bool] = UNSET,
121+
list_prop: Union[Unset, List[AnEnum]] = UNSET,
122+
union_prop: Union[Unset, Union[Union[Unset, float], Union[Unset, str]]] = "not a float",
123+
enum_prop: Union[Unset, AnEnum] = UNSET,
124124
) -> Response[Union[None, HTTPValidationError]]:
125125
kwargs = _get_kwargs(
126126
client=client,
@@ -147,15 +147,15 @@ def sync(
147147
*,
148148
client: Client,
149149
json_body: Dict[Any, Any],
150-
string_prop: str = "the default string",
151-
datetime_prop: datetime.datetime = isoparse("1010-10-10T00:00:00"),
152-
date_prop: datetime.date = isoparse("1010-10-10").date(),
153-
float_prop: float = 3.14,
154-
int_prop: int = 7,
155-
boolean_prop: bool = cast(bool, UNSET),
156-
list_prop: List[AnEnum] = cast(List[AnEnum], UNSET),
157-
union_prop: Union[float, str] = "not a float",
158-
enum_prop: AnEnum = cast(AnEnum, UNSET),
150+
string_prop: Union[Unset, str] = "the default string",
151+
datetime_prop: Union[Unset, datetime.datetime] = isoparse("1010-10-10T00:00:00"),
152+
date_prop: Union[Unset, datetime.date] = isoparse("1010-10-10").date(),
153+
float_prop: Union[Unset, float] = 3.14,
154+
int_prop: Union[Unset, int] = 7,
155+
boolean_prop: Union[Unset, bool] = UNSET,
156+
list_prop: Union[Unset, List[AnEnum]] = UNSET,
157+
union_prop: Union[Unset, Union[Union[Unset, float], Union[Unset, str]]] = "not a float",
158+
enum_prop: Union[Unset, AnEnum] = UNSET,
159159
) -> Optional[Union[None, HTTPValidationError]]:
160160
""" """
161161

@@ -178,15 +178,15 @@ async def asyncio_detailed(
178178
*,
179179
client: Client,
180180
json_body: Dict[Any, Any],
181-
string_prop: str = "the default string",
182-
datetime_prop: datetime.datetime = isoparse("1010-10-10T00:00:00"),
183-
date_prop: datetime.date = isoparse("1010-10-10").date(),
184-
float_prop: float = 3.14,
185-
int_prop: int = 7,
186-
boolean_prop: bool = cast(bool, UNSET),
187-
list_prop: List[AnEnum] = cast(List[AnEnum], UNSET),
188-
union_prop: Union[float, str] = "not a float",
189-
enum_prop: AnEnum = cast(AnEnum, UNSET),
181+
string_prop: Union[Unset, str] = "the default string",
182+
datetime_prop: Union[Unset, datetime.datetime] = isoparse("1010-10-10T00:00:00"),
183+
date_prop: Union[Unset, datetime.date] = isoparse("1010-10-10").date(),
184+
float_prop: Union[Unset, float] = 3.14,
185+
int_prop: Union[Unset, int] = 7,
186+
boolean_prop: Union[Unset, bool] = UNSET,
187+
list_prop: Union[Unset, List[AnEnum]] = UNSET,
188+
union_prop: Union[Unset, Union[Union[Unset, float], Union[Unset, str]]] = "not a float",
189+
enum_prop: Union[Unset, AnEnum] = UNSET,
190190
) -> Response[Union[None, HTTPValidationError]]:
191191
kwargs = _get_kwargs(
192192
client=client,
@@ -212,15 +212,15 @@ async def asyncio(
212212
*,
213213
client: Client,
214214
json_body: Dict[Any, Any],
215-
string_prop: str = "the default string",
216-
datetime_prop: datetime.datetime = isoparse("1010-10-10T00:00:00"),
217-
date_prop: datetime.date = isoparse("1010-10-10").date(),
218-
float_prop: float = 3.14,
219-
int_prop: int = 7,
220-
boolean_prop: bool = cast(bool, UNSET),
221-
list_prop: List[AnEnum] = cast(List[AnEnum], UNSET),
222-
union_prop: Union[float, str] = "not a float",
223-
enum_prop: AnEnum = cast(AnEnum, UNSET),
215+
string_prop: Union[Unset, str] = "the default string",
216+
datetime_prop: Union[Unset, datetime.datetime] = isoparse("1010-10-10T00:00:00"),
217+
date_prop: Union[Unset, datetime.date] = isoparse("1010-10-10").date(),
218+
float_prop: Union[Unset, float] = 3.14,
219+
int_prop: Union[Unset, int] = 7,
220+
boolean_prop: Union[Unset, bool] = UNSET,
221+
list_prop: Union[Unset, List[AnEnum]] = UNSET,
222+
union_prop: Union[Unset, Union[Union[Unset, float], Union[Unset, str]]] = "not a float",
223+
enum_prop: Union[Unset, AnEnum] = UNSET,
224224
) -> Optional[Union[None, HTTPValidationError]]:
225225
""" """
226226

end_to_end_tests/golden-record/my_test_api_client/api/tests/json_body_tests_json_body_post.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def _get_kwargs(
1717

1818
headers: Dict[str, Any] = client.get_headers()
1919

20-
json_json_body = json_body.to_dict(exclude_unset=True)
20+
json_json_body = json_body.to_dict()
2121

2222
return {
2323
"url": url,

end_to_end_tests/golden-record/my_test_api_client/api/tests/optional_value_tests_optional_query_param.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
from ...client import Client
66
from ...models.http_validation_error import HTTPValidationError
7-
from ...types import UNSET, Response
7+
from ...types import UNSET, Response, Unset
88

99

1010
def _get_kwargs(
1111
*,
1212
client: Client,
13-
query_param: List[str] = cast(List[str], UNSET),
13+
query_param: Union[Unset, List[str]] = UNSET,
1414
) -> Dict[str, Any]:
1515
url = "{}/tests/optional_query_param/".format(client.base_url)
1616

@@ -54,7 +54,7 @@ def _build_response(*, response: httpx.Response) -> Response[Union[None, HTTPVal
5454
def sync_detailed(
5555
*,
5656
client: Client,
57-
query_param: List[str] = cast(List[str], UNSET),
57+
query_param: Union[Unset, List[str]] = UNSET,
5858
) -> Response[Union[None, HTTPValidationError]]:
5959
kwargs = _get_kwargs(
6060
client=client,
@@ -71,7 +71,7 @@ def sync_detailed(
7171
def sync(
7272
*,
7373
client: Client,
74-
query_param: List[str] = cast(List[str], UNSET),
74+
query_param: Union[Unset, List[str]] = UNSET,
7575
) -> Optional[Union[None, HTTPValidationError]]:
7676
""" Test optional query parameters """
7777

@@ -84,7 +84,7 @@ def sync(
8484
async def asyncio_detailed(
8585
*,
8686
client: Client,
87-
query_param: List[str] = cast(List[str], UNSET),
87+
query_param: Union[Unset, List[str]] = UNSET,
8888
) -> Response[Union[None, HTTPValidationError]]:
8989
kwargs = _get_kwargs(
9090
client=client,
@@ -100,7 +100,7 @@ async def asyncio_detailed(
100100
async def asyncio(
101101
*,
102102
client: Client,
103-
query_param: List[str] = cast(List[str], UNSET),
103+
query_param: Union[Unset, List[str]] = UNSET,
104104
) -> Optional[Union[None, HTTPValidationError]]:
105105
""" Test optional query parameters """
106106

end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
from ...client import Client
66
from ...models.body_upload_file_tests_upload_post import BodyUploadFileTestsUploadPost
77
from ...models.http_validation_error import HTTPValidationError
8-
from ...types import UNSET, Response
8+
from ...types import UNSET, Response, Unset
99

1010

1111
def _get_kwargs(
1212
*,
1313
client: Client,
1414
multipart_data: BodyUploadFileTestsUploadPost,
15-
keep_alive: bool = cast(bool, UNSET),
15+
keep_alive: Union[Unset, bool] = UNSET,
1616
) -> Dict[str, Any]:
1717
url = "{}/tests/upload".format(client.base_url)
1818

@@ -51,7 +51,7 @@ def sync_detailed(
5151
*,
5252
client: Client,
5353
multipart_data: BodyUploadFileTestsUploadPost,
54-
keep_alive: bool = cast(bool, UNSET),
54+
keep_alive: Union[Unset, bool] = UNSET,
5555
) -> Response[Union[None, HTTPValidationError]]:
5656
kwargs = _get_kwargs(
5757
client=client,
@@ -70,7 +70,7 @@ def sync(
7070
*,
7171
client: Client,
7272
multipart_data: BodyUploadFileTestsUploadPost,
73-
keep_alive: bool = cast(bool, UNSET),
73+
keep_alive: Union[Unset, bool] = UNSET,
7474
) -> Optional[Union[None, HTTPValidationError]]:
7575
""" Upload a file """
7676

@@ -85,7 +85,7 @@ async def asyncio_detailed(
8585
*,
8686
client: Client,
8787
multipart_data: BodyUploadFileTestsUploadPost,
88-
keep_alive: bool = cast(bool, UNSET),
88+
keep_alive: Union[Unset, bool] = UNSET,
8989
) -> Response[Union[None, HTTPValidationError]]:
9090
kwargs = _get_kwargs(
9191
client=client,
@@ -103,7 +103,7 @@ async def asyncio(
103103
*,
104104
client: Client,
105105
multipart_data: BodyUploadFileTestsUploadPost,
106-
keep_alive: bool = cast(bool, UNSET),
106+
keep_alive: Union[Unset, bool] = UNSET,
107107
) -> Optional[Union[None, HTTPValidationError]]:
108108
""" Upload a file """
109109

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

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import datetime
2-
from typing import Any, Dict, List, Optional, Set, Union, cast
2+
from typing import Any, Dict, List, Optional, Union
33

44
import attr
55
from dateutil.parser import isoparse
66

77
from ..models.an_enum import AnEnum
88
from ..models.different_enum import DifferentEnum
9-
from ..types import UNSET
9+
from ..types import UNSET, Unset
1010

1111

1212
@attr.s(auto_attribs=True)
@@ -17,20 +17,14 @@ class AModel:
1717
a_camel_date_time: Union[datetime.datetime, datetime.date]
1818
a_date: datetime.date
1919
required_not_nullable: str
20-
nested_list_of_enums: List[List[DifferentEnum]] = cast(List[List[DifferentEnum]], UNSET)
20+
nested_list_of_enums: Union[Unset, List[List[DifferentEnum]]] = UNSET
2121
some_dict: Optional[Dict[Any, Any]] = None
22-
attr_1_leading_digit: str = cast(str, UNSET)
22+
attr_1_leading_digit: Union[Unset, str] = UNSET
2323
required_nullable: Optional[str] = None
24-
not_required_nullable: Optional[str] = cast(Optional[str], UNSET)
25-
not_required_not_nullable: str = cast(str, UNSET)
26-
27-
def to_dict(
28-
self,
29-
include: Optional[Set[str]] = None,
30-
exclude: Optional[Set[str]] = None,
31-
exclude_unset: bool = False,
32-
exclude_none: bool = False,
33-
) -> Dict[str, Any]:
24+
not_required_nullable: Union[Unset, Optional[str]] = UNSET
25+
not_required_not_nullable: Union[Unset, str] = UNSET
26+
27+
def to_dict(self) -> Dict[str, Any]:
3428
an_enum_value = self.an_enum_value.value
3529

3630
if isinstance(self.a_camel_date_time, datetime.datetime):
@@ -64,32 +58,24 @@ def to_dict(
6458
not_required_nullable = self.not_required_nullable
6559
not_required_not_nullable = self.not_required_not_nullable
6660

67-
all_properties = {
61+
field_dict = {
6862
"an_enum_value": an_enum_value,
6963
"aCamelDateTime": a_camel_date_time,
7064
"a_date": a_date,
7165
"required_not_nullable": required_not_nullable,
72-
"nested_list_of_enums": nested_list_of_enums,
7366
"some_dict": some_dict,
74-
"1_leading_digit": attr_1_leading_digit,
7567
"required_nullable": required_nullable,
76-
"not_required_nullable": not_required_nullable,
77-
"not_required_not_nullable": not_required_not_nullable,
7868
}
79-
80-
trimmed_properties: Dict[str, Any] = {}
81-
for property_name, property_value in all_properties.items():
82-
if include is not None and property_name not in include:
83-
continue
84-
if exclude is not None and property_name in exclude:
85-
continue
86-
if exclude_unset and property_value is UNSET:
87-
continue
88-
if exclude_none and property_value is None:
89-
continue
90-
trimmed_properties[property_name] = property_value
91-
92-
return trimmed_properties
69+
if nested_list_of_enums is not UNSET:
70+
field_dict["nested_list_of_enums"] = nested_list_of_enums
71+
if attr_1_leading_digit is not UNSET:
72+
field_dict["1_leading_digit"] = attr_1_leading_digit
73+
if not_required_nullable is not UNSET:
74+
field_dict["not_required_nullable"] = not_required_nullable
75+
if not_required_not_nullable is not UNSET:
76+
field_dict["not_required_not_nullable"] = not_required_not_nullable
77+
78+
return field_dict
9379

9480
@staticmethod
9581
def from_dict(d: Dict[str, Any]) -> "AModel":

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

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from typing import Any, Dict, Optional, Set
1+
from typing import Any, Dict
22

33
import attr
44

5-
from ..types import UNSET, File
5+
from ..types import File
66

77

88
@attr.s(auto_attribs=True)
@@ -11,32 +11,14 @@ class BodyUploadFileTestsUploadPost:
1111

1212
some_file: File
1313

14-
def to_dict(
15-
self,
16-
include: Optional[Set[str]] = None,
17-
exclude: Optional[Set[str]] = None,
18-
exclude_unset: bool = False,
19-
exclude_none: bool = False,
20-
) -> Dict[str, Any]:
14+
def to_dict(self) -> Dict[str, Any]:
2115
some_file = self.some_file.to_tuple()
2216

23-
all_properties = {
17+
field_dict = {
2418
"some_file": some_file,
2519
}
2620

27-
trimmed_properties: Dict[str, Any] = {}
28-
for property_name, property_value in all_properties.items():
29-
if include is not None and property_name not in include:
30-
continue
31-
if exclude is not None and property_name in exclude:
32-
continue
33-
if exclude_unset and property_value is UNSET:
34-
continue
35-
if exclude_none and property_value is None:
36-
continue
37-
trimmed_properties[property_name] = property_value
38-
39-
return trimmed_properties
21+
return field_dict
4022

4123
@staticmethod
4224
def from_dict(d: Dict[str, Any]) -> "BodyUploadFileTestsUploadPost":

0 commit comments

Comments
 (0)