Skip to content

Commit 43969ae

Browse files
Make inner types into a set, fix List type string, add tests
1 parent b5fa15d commit 43969ae

File tree

15 files changed

+101
-97
lines changed

15 files changed

+101
-97
lines changed

end_to_end_tests/golden-record-custom/custom_e2e/api/tests/defaults_tests_defaults_post.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def httpx_request(
5252
boolean_prop: Union[Unset, bool] = False,
5353
list_prop: Union[Unset, List[AnEnum]] = UNSET,
5454
union_prop: Union[Unset, float, str] = "not a float",
55-
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
55+
union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6,
5656
enum_prop: Union[Unset, AnEnum] = UNSET,
5757
model_prop: Union[Unset, ModelWithUnionProperty] = UNSET,
5858
) -> Response[Union[None, HTTPValidationError]]:
@@ -77,7 +77,7 @@ def httpx_request(
7777
if not isinstance(date_prop, Unset):
7878
json_date_prop = date_prop.isoformat()
7979

80-
json_list_prop: Union[Unset, List[Any]] = UNSET
80+
json_list_prop: Union[Unset, List[str]] = UNSET
8181
if not isinstance(list_prop, Unset):
8282
json_list_prop = []
8383
for list_prop_item_data in list_prop:

end_to_end_tests/golden-record-custom/custom_e2e/api/tests/optional_value_tests_optional_query_param.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def httpx_request(
3939
query_param: Union[Unset, List[str]] = UNSET,
4040
) -> Response[Union[None, HTTPValidationError]]:
4141

42-
json_query_param: Union[Unset, List[Any]] = UNSET
42+
json_query_param: Union[Unset, List[str]] = UNSET
4343
if not isinstance(query_param, Unset):
4444
json_query_param = query_param
4545

end_to_end_tests/golden-record-custom/custom_e2e/models/a_model.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ class AModel:
2222
""" A Model for testing all the ways custom objects can be used """
2323

2424
an_enum_value: AnEnum
25-
a_camel_date_time: Union[datetime.datetime, datetime.date]
25+
a_camel_date_time: Union[datetime.date, datetime.datetime]
2626
a_date: datetime.date
2727
required_not_nullable: str
2828
one_of_models: Union[FreeFormModel, ModelWithUnionProperty]
2929
model: AModelModel
3030
a_nullable_date: Optional[datetime.date]
3131
required_nullable: Optional[str]
32-
nullable_one_of_models: Union[None, FreeFormModel, ModelWithUnionProperty]
32+
nullable_one_of_models: Union[FreeFormModel, ModelWithUnionProperty, None]
3333
nullable_model: Optional[AModelNullableModel]
3434
nested_list_of_enums: Union[Unset, List[List[DifferentEnum]]] = UNSET
3535
a_not_required_date: Union[Unset, datetime.date] = UNSET
3636
attr_1_leading_digit: Union[Unset, str] = UNSET
3737
not_required_nullable: Union[Unset, None, str] = UNSET
3838
not_required_not_nullable: Union[Unset, str] = UNSET
39-
not_required_one_of_models: Union[Unset, FreeFormModel, ModelWithUnionProperty] = UNSET
40-
not_required_nullable_one_of_models: Union[Unset, None, FreeFormModel, ModelWithUnionProperty, str] = UNSET
39+
not_required_one_of_models: Union[FreeFormModel, ModelWithUnionProperty, Unset] = UNSET
40+
not_required_nullable_one_of_models: Union[FreeFormModel, ModelWithUnionProperty, None, Unset, str] = UNSET
4141
not_required_model: Union[Unset, AModelNotRequiredModel] = UNSET
4242
not_required_nullable_model: Union[Unset, None, AModelNotRequiredNullableModel] = UNSET
4343

@@ -60,7 +60,7 @@ def to_dict(self) -> Dict[str, Any]:
6060

6161
model = self.model.to_dict()
6262

63-
nested_list_of_enums: Union[Unset, List[Any]] = UNSET
63+
nested_list_of_enums: Union[Unset, List[List[str]]] = UNSET
6464
if not isinstance(self.nested_list_of_enums, Unset):
6565
nested_list_of_enums = []
6666
for nested_list_of_enums_item_data in self.nested_list_of_enums:
@@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]:
8181
required_nullable = self.required_nullable
8282
not_required_nullable = self.not_required_nullable
8383
not_required_not_nullable = self.not_required_not_nullable
84-
nullable_one_of_models: Union[None, Dict[str, Any]]
84+
nullable_one_of_models: Union[Dict[str, Any], None]
8585
if self.nullable_one_of_models is None:
8686
nullable_one_of_models = None
8787
elif isinstance(self.nullable_one_of_models, FreeFormModel):
@@ -90,7 +90,7 @@ def to_dict(self) -> Dict[str, Any]:
9090
else:
9191
nullable_one_of_models = self.nullable_one_of_models.to_dict()
9292

93-
not_required_one_of_models: Union[Unset, Dict[str, Any]]
93+
not_required_one_of_models: Union[Dict[str, Any], Unset]
9494
if isinstance(self.not_required_one_of_models, Unset):
9595
not_required_one_of_models = UNSET
9696
elif isinstance(self.not_required_one_of_models, FreeFormModel):
@@ -103,7 +103,7 @@ def to_dict(self) -> Dict[str, Any]:
103103
if not isinstance(self.not_required_one_of_models, Unset):
104104
not_required_one_of_models = self.not_required_one_of_models.to_dict()
105105

106-
not_required_nullable_one_of_models: Union[Unset, None, Dict[str, Any], str]
106+
not_required_nullable_one_of_models: Union[Dict[str, Any], None, Unset, str]
107107
if isinstance(self.not_required_nullable_one_of_models, Unset):
108108
not_required_nullable_one_of_models = UNSET
109109
elif self.not_required_nullable_one_of_models is None:
@@ -174,8 +174,8 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
174174
d = src_dict.copy()
175175
an_enum_value = AnEnum(d.pop("an_enum_value"))
176176

177-
def _parse_a_camel_date_time(data: object) -> Union[datetime.datetime, datetime.date]:
178-
a_camel_date_time: Union[datetime.datetime, datetime.date]
177+
def _parse_a_camel_date_time(data: object) -> Union[datetime.date, datetime.datetime]:
178+
a_camel_date_time: Union[datetime.date, datetime.datetime]
179179
try:
180180
if not isinstance(data, str):
181181
raise TypeError()
@@ -246,8 +246,8 @@ def _parse_one_of_models(data: object) -> Union[FreeFormModel, ModelWithUnionPro
246246

247247
not_required_not_nullable = d.pop("not_required_not_nullable", UNSET)
248248

249-
def _parse_nullable_one_of_models(data: object) -> Union[None, FreeFormModel, ModelWithUnionProperty]:
250-
nullable_one_of_models: Union[None, FreeFormModel, ModelWithUnionProperty]
249+
def _parse_nullable_one_of_models(data: object) -> Union[FreeFormModel, ModelWithUnionProperty, None]:
250+
nullable_one_of_models: Union[FreeFormModel, ModelWithUnionProperty, None]
251251
if data is None:
252252
return data
253253
try:
@@ -266,8 +266,8 @@ def _parse_nullable_one_of_models(data: object) -> Union[None, FreeFormModel, Mo
266266

267267
nullable_one_of_models = _parse_nullable_one_of_models(d.pop("nullable_one_of_models"))
268268

269-
def _parse_not_required_one_of_models(data: object) -> Union[Unset, FreeFormModel, ModelWithUnionProperty]:
270-
not_required_one_of_models: Union[Unset, FreeFormModel, ModelWithUnionProperty]
269+
def _parse_not_required_one_of_models(data: object) -> Union[FreeFormModel, ModelWithUnionProperty, Unset]:
270+
not_required_one_of_models: Union[FreeFormModel, ModelWithUnionProperty, Unset]
271271
if isinstance(data, Unset):
272272
return data
273273
try:
@@ -294,8 +294,8 @@ def _parse_not_required_one_of_models(data: object) -> Union[Unset, FreeFormMode
294294

295295
def _parse_not_required_nullable_one_of_models(
296296
data: object,
297-
) -> Union[Unset, None, FreeFormModel, ModelWithUnionProperty, str]:
298-
not_required_nullable_one_of_models: Union[Unset, None, FreeFormModel, ModelWithUnionProperty, str]
297+
) -> Union[FreeFormModel, ModelWithUnionProperty, None, Unset, str]:
298+
not_required_nullable_one_of_models: Union[FreeFormModel, ModelWithUnionProperty, None, Unset, str]
299299
if data is None:
300300
return data
301301
if isinstance(data, Unset):
@@ -324,7 +324,7 @@ def _parse_not_required_nullable_one_of_models(
324324
return not_required_nullable_one_of_models
325325
except: # noqa: E722
326326
pass
327-
return cast(Union[Unset, None, FreeFormModel, ModelWithUnionProperty, str], data)
327+
return cast(Union[FreeFormModel, ModelWithUnionProperty, None, Unset, str], data)
328328

329329
not_required_nullable_one_of_models = _parse_not_required_nullable_one_of_models(
330330
d.pop("not_required_nullable_one_of_models", UNSET)

end_to_end_tests/golden-record-custom/custom_e2e/models/http_validation_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class HTTPValidationError:
1515
detail: Union[Unset, List[ValidationError]] = UNSET
1616

1717
def to_dict(self) -> Dict[str, Any]:
18-
detail: Union[Unset, List[Any]] = UNSET
18+
detail: Union[Unset, List[Dict[str, Any]]] = UNSET
1919
if not isinstance(self.detail, Unset):
2020
detail = []
2121
for detail_item_data in self.detail:

end_to_end_tests/golden-record-custom/custom_e2e/models/model_with_any_json_properties.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ModelWithAnyJsonProperties:
1212
""" """
1313

1414
additional_properties: Dict[
15-
str, Union[ModelWithAnyJsonPropertiesAdditionalProperty, List[str], str, float, int, bool]
15+
str, Union[List[str], ModelWithAnyJsonPropertiesAdditionalProperty, bool, float, int, str]
1616
] = attr.ib(init=False, factory=dict)
1717

1818
def to_dict(self) -> Dict[str, Any]:
@@ -42,9 +42,9 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
4242

4343
def _parse_additional_property(
4444
data: object,
45-
) -> Union[ModelWithAnyJsonPropertiesAdditionalProperty, List[str], str, float, int, bool]:
45+
) -> Union[List[str], ModelWithAnyJsonPropertiesAdditionalProperty, bool, float, int, str]:
4646
additional_property: Union[
47-
ModelWithAnyJsonPropertiesAdditionalProperty, List[str], str, float, int, bool
47+
List[str], ModelWithAnyJsonPropertiesAdditionalProperty, bool, float, int, str
4848
]
4949
try:
5050
if not isinstance(data, dict):
@@ -62,7 +62,7 @@ def _parse_additional_property(
6262
return additional_property
6363
except: # noqa: E722
6464
pass
65-
return cast(Union[ModelWithAnyJsonPropertiesAdditionalProperty, List[str], str, float, int, bool], data)
65+
return cast(Union[List[str], ModelWithAnyJsonPropertiesAdditionalProperty, bool, float, int, str], data)
6666

6767
additional_property = _parse_additional_property(prop_dict)
6868

@@ -77,11 +77,11 @@ def additional_keys(self) -> List[str]:
7777

7878
def __getitem__(
7979
self, key: str
80-
) -> Union[ModelWithAnyJsonPropertiesAdditionalProperty, List[str], str, float, int, bool]:
80+
) -> Union[List[str], ModelWithAnyJsonPropertiesAdditionalProperty, bool, float, int, str]:
8181
return self.additional_properties[key]
8282

8383
def __setitem__(
84-
self, key: str, value: Union[ModelWithAnyJsonPropertiesAdditionalProperty, List[str], str, float, int, bool]
84+
self, key: str, value: Union[List[str], ModelWithAnyJsonPropertiesAdditionalProperty, bool, float, int, str]
8585
) -> None:
8686
self.additional_properties[key] = value
8787

end_to_end_tests/golden-record-custom/custom_e2e/models/model_with_union_property.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
class ModelWithUnionProperty:
1414
""" """
1515

16-
a_property: Union[Unset, AnEnum, AnIntEnum] = UNSET
16+
a_property: Union[AnEnum, AnIntEnum, Unset] = UNSET
1717

1818
def to_dict(self) -> Dict[str, Any]:
19-
a_property: Union[Unset, str, int]
19+
a_property: Union[Unset, int, str]
2020
if isinstance(self.a_property, Unset):
2121
a_property = UNSET
2222
elif isinstance(self.a_property, AnEnum):
@@ -40,8 +40,8 @@ def to_dict(self) -> Dict[str, Any]:
4040
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
4141
d = src_dict.copy()
4242

43-
def _parse_a_property(data: object) -> Union[Unset, AnEnum, AnIntEnum]:
44-
a_property: Union[Unset, AnEnum, AnIntEnum]
43+
def _parse_a_property(data: object) -> Union[AnEnum, AnIntEnum, Unset]:
44+
a_property: Union[AnEnum, AnIntEnum, Unset]
4545
if isinstance(data, Unset):
4646
return data
4747
try:

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _get_kwargs(
2525
boolean_prop: Union[Unset, bool] = False,
2626
list_prop: Union[Unset, List[AnEnum]] = UNSET,
2727
union_prop: Union[Unset, float, str] = "not a float",
28-
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
28+
union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6,
2929
enum_prop: Union[Unset, AnEnum] = UNSET,
3030
model_prop: Union[Unset, ModelWithUnionProperty] = UNSET,
3131
) -> Dict[str, Any]:
@@ -53,7 +53,7 @@ def _get_kwargs(
5353
if not isinstance(date_prop, Unset):
5454
json_date_prop = date_prop.isoformat()
5555

56-
json_list_prop: Union[Unset, List[Any]] = UNSET
56+
json_list_prop: Union[Unset, List[str]] = UNSET
5757
if not isinstance(list_prop, Unset):
5858
json_list_prop = []
5959
for list_prop_item_data in list_prop:
@@ -148,7 +148,7 @@ def sync_detailed(
148148
boolean_prop: Union[Unset, bool] = False,
149149
list_prop: Union[Unset, List[AnEnum]] = UNSET,
150150
union_prop: Union[Unset, float, str] = "not a float",
151-
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
151+
union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6,
152152
enum_prop: Union[Unset, AnEnum] = UNSET,
153153
model_prop: Union[Unset, ModelWithUnionProperty] = UNSET,
154154
) -> Response[Union[None, HTTPValidationError]]:
@@ -191,7 +191,7 @@ def sync(
191191
boolean_prop: Union[Unset, bool] = False,
192192
list_prop: Union[Unset, List[AnEnum]] = UNSET,
193193
union_prop: Union[Unset, float, str] = "not a float",
194-
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
194+
union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6,
195195
enum_prop: Union[Unset, AnEnum] = UNSET,
196196
model_prop: Union[Unset, ModelWithUnionProperty] = UNSET,
197197
) -> Optional[Union[None, HTTPValidationError]]:
@@ -230,7 +230,7 @@ async def asyncio_detailed(
230230
boolean_prop: Union[Unset, bool] = False,
231231
list_prop: Union[Unset, List[AnEnum]] = UNSET,
232232
union_prop: Union[Unset, float, str] = "not a float",
233-
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
233+
union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6,
234234
enum_prop: Union[Unset, AnEnum] = UNSET,
235235
model_prop: Union[Unset, ModelWithUnionProperty] = UNSET,
236236
) -> Response[Union[None, HTTPValidationError]]:
@@ -272,7 +272,7 @@ async def asyncio(
272272
boolean_prop: Union[Unset, bool] = False,
273273
list_prop: Union[Unset, List[AnEnum]] = UNSET,
274274
union_prop: Union[Unset, float, str] = "not a float",
275-
union_prop_with_ref: Union[Unset, float, AnEnum] = 0.6,
275+
union_prop_with_ref: Union[AnEnum, Unset, float] = 0.6,
276276
enum_prop: Union[Unset, AnEnum] = UNSET,
277277
model_prop: Union[Unset, ModelWithUnionProperty] = UNSET,
278278
) -> Optional[Union[None, HTTPValidationError]]:

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

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

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

19-
json_query_param: Union[Unset, List[Any]] = UNSET
19+
json_query_param: Union[Unset, List[str]] = UNSET
2020
if not isinstance(query_param, Unset):
2121
json_query_param = query_param
2222

0 commit comments

Comments
 (0)