1
1
import datetime
2
- from typing import Any , Dict , List , Optional , Union
2
+ from typing import Any , Dict , List , Optional , Union , cast
3
3
4
4
import attr
5
5
from dateutil .parser import isoparse
@@ -17,6 +17,7 @@ class AModel:
17
17
a_camel_date_time : Union [datetime .datetime , datetime .date ]
18
18
a_date : datetime .date
19
19
required_not_nullable : str
20
+ a_nullable_date : Optional [datetime .date ]
20
21
required_nullable : Optional [str ]
21
22
nested_list_of_enums : Union [Unset , List [List [DifferentEnum ]]] = UNSET
22
23
attr_1_leading_digit : Union [Unset , str ] = UNSET
@@ -33,7 +34,6 @@ def to_dict(self) -> Dict[str, Any]:
33
34
a_camel_date_time = self .a_camel_date_time .isoformat ()
34
35
35
36
a_date = self .a_date .isoformat ()
36
-
37
37
required_not_nullable = self .required_not_nullable
38
38
nested_list_of_enums : Union [Unset , List [Any ]] = UNSET
39
39
if not isinstance (self .nested_list_of_enums , Unset ):
@@ -47,6 +47,7 @@ def to_dict(self) -> Dict[str, Any]:
47
47
48
48
nested_list_of_enums .append (nested_list_of_enums_item )
49
49
50
+ a_nullable_date = self .a_nullable_date .isoformat () if self .a_nullable_date else None
50
51
attr_1_leading_digit = self .attr_1_leading_digit
51
52
required_nullable = self .required_nullable
52
53
not_required_nullable = self .not_required_nullable
@@ -59,6 +60,7 @@ def to_dict(self) -> Dict[str, Any]:
59
60
"aCamelDateTime" : a_camel_date_time ,
60
61
"a_date" : a_date ,
61
62
"required_not_nullable" : required_not_nullable ,
63
+ "a_nullable_date" : a_nullable_date ,
62
64
"required_nullable" : required_nullable ,
63
65
}
64
66
)
@@ -109,6 +111,11 @@ def _parse_a_camel_date_time(data: Any) -> Union[datetime.datetime, datetime.dat
109
111
110
112
nested_list_of_enums .append (nested_list_of_enums_item )
111
113
114
+ a_nullable_date = None
115
+ _a_nullable_date = d .pop ("a_nullable_date" )
116
+ if _a_nullable_date is not None :
117
+ a_nullable_date = isoparse (cast (str , _a_nullable_date )).date ()
118
+
112
119
attr_1_leading_digit = d .pop ("1_leading_digit" , UNSET )
113
120
114
121
required_nullable = d .pop ("required_nullable" )
@@ -123,6 +130,7 @@ def _parse_a_camel_date_time(data: Any) -> Union[datetime.datetime, datetime.dat
123
130
a_date = a_date ,
124
131
required_not_nullable = required_not_nullable ,
125
132
nested_list_of_enums = nested_list_of_enums ,
133
+ a_nullable_date = a_nullable_date ,
126
134
attr_1_leading_digit = attr_1_leading_digit ,
127
135
required_nullable = required_nullable ,
128
136
not_required_nullable = not_required_nullable ,
0 commit comments