1
1
import datetime
2
- from typing import Any , Dict , List , Optional , Type , TypeVar , Union , cast
2
+ from typing import Any , Dict , List , Optional , Type , TypeVar , Union
3
3
4
4
import attr
5
5
from dateutil .parser import isoparse
@@ -28,6 +28,7 @@ class AModel:
28
28
required_nullable : Optional [str ]
29
29
nullable_model : Optional [AModelNullableModel ]
30
30
nested_list_of_enums : Union [Unset , List [List [DifferentEnum ]]] = UNSET
31
+ a_not_required_date : Union [Unset , datetime .date ] = UNSET
31
32
attr_1_leading_digit : Union [Unset , str ] = UNSET
32
33
not_required_nullable : Union [Unset , Optional [str ]] = UNSET
33
34
not_required_not_nullable : Union [Unset , str ] = UNSET
@@ -60,6 +61,10 @@ def to_dict(self) -> Dict[str, Any]:
60
61
nested_list_of_enums .append (nested_list_of_enums_item )
61
62
62
63
a_nullable_date = self .a_nullable_date .isoformat () if self .a_nullable_date else None
64
+ a_not_required_date : Union [Unset , str ] = UNSET
65
+ if not isinstance (self .a_not_required_date , Unset ):
66
+ a_not_required_date = self .a_not_required_date .isoformat ()
67
+
63
68
attr_1_leading_digit = self .attr_1_leading_digit
64
69
required_nullable = self .required_nullable
65
70
not_required_nullable = self .not_required_nullable
@@ -91,6 +96,8 @@ def to_dict(self) -> Dict[str, Any]:
91
96
)
92
97
if nested_list_of_enums is not UNSET :
93
98
field_dict ["nested_list_of_enums" ] = nested_list_of_enums
99
+ if a_not_required_date is not UNSET :
100
+ field_dict ["a_not_required_date" ] = a_not_required_date
94
101
if attr_1_leading_digit is not UNSET :
95
102
field_dict ["1_leading_digit" ] = attr_1_leading_digit
96
103
if not_required_nullable is not UNSET :
@@ -145,7 +152,12 @@ def _parse_a_camel_date_time(data: Any) -> Union[datetime.datetime, datetime.dat
145
152
a_nullable_date = None
146
153
_a_nullable_date = d .pop ("a_nullable_date" )
147
154
if _a_nullable_date is not None :
148
- a_nullable_date = isoparse (cast (str , _a_nullable_date )).date ()
155
+ a_nullable_date = isoparse (_a_nullable_date ).date ()
156
+
157
+ a_not_required_date : Union [Unset , datetime .date ] = UNSET
158
+ _a_not_required_date = d .pop ("a_not_required_date" , UNSET )
159
+ if not isinstance (_a_not_required_date , Unset ):
160
+ a_not_required_date = isoparse (_a_not_required_date ).date ()
149
161
150
162
attr_1_leading_digit = d .pop ("1_leading_digit" , UNSET )
151
163
@@ -158,19 +170,17 @@ def _parse_a_camel_date_time(data: Any) -> Union[datetime.datetime, datetime.dat
158
170
nullable_model = None
159
171
_nullable_model = d .pop ("nullable_model" )
160
172
if _nullable_model is not None :
161
- nullable_model = AModelNullableModel .from_dict (cast ( Dict [ str , Any ], _nullable_model ) )
173
+ nullable_model = AModelNullableModel .from_dict (_nullable_model )
162
174
163
175
not_required_model : Union [AModelNotRequiredModel , Unset ] = UNSET
164
176
_not_required_model = d .pop ("not_required_model" , UNSET )
165
177
if not isinstance (_not_required_model , Unset ):
166
- not_required_model = AModelNotRequiredModel .from_dict (cast ( Dict [ str , Any ], _not_required_model ) )
178
+ not_required_model = AModelNotRequiredModel .from_dict (_not_required_model )
167
179
168
180
not_required_nullable_model = None
169
181
_not_required_nullable_model = d .pop ("not_required_nullable_model" , UNSET )
170
182
if _not_required_nullable_model is not None and not isinstance (_not_required_nullable_model , Unset ):
171
- not_required_nullable_model = AModelNotRequiredNullableModel .from_dict (
172
- cast (Dict [str , Any ], _not_required_nullable_model )
173
- )
183
+ not_required_nullable_model = AModelNotRequiredNullableModel .from_dict (_not_required_nullable_model )
174
184
175
185
a_model = cls (
176
186
an_enum_value = an_enum_value ,
@@ -180,6 +190,7 @@ def _parse_a_camel_date_time(data: Any) -> Union[datetime.datetime, datetime.dat
180
190
model = model ,
181
191
nested_list_of_enums = nested_list_of_enums ,
182
192
a_nullable_date = a_nullable_date ,
193
+ a_not_required_date = a_not_required_date ,
183
194
attr_1_leading_digit = attr_1_leading_digit ,
184
195
required_nullable = required_nullable ,
185
196
not_required_nullable = not_required_nullable ,
0 commit comments