@@ -68,7 +68,9 @@ def split_at_given_level(
68
68
69
69
70
70
def _get_parser (
71
- cls : Type , type_ : TypeAlias , parsers : Optional [Dict [type , Callable [[str ], Any ]]] = None ,
71
+ cls : Type ,
72
+ type_ : TypeAlias ,
73
+ parsers : Optional [Dict [type , Callable [[str ], Any ]]] = None ,
72
74
) -> partial :
73
75
"""Attempts to find a parser for a provided type.
74
76
@@ -112,7 +114,11 @@ def get_parser() -> partial:
112
114
assert (
113
115
len (subtypes ) == 1
114
116
), "Lists are allowed only one subtype per PEP specification!"
115
- subtype_parser = _get_parser (cls , subtypes [0 ], parsers ,)
117
+ subtype_parser = _get_parser (
118
+ cls ,
119
+ subtypes [0 ],
120
+ parsers ,
121
+ )
116
122
return functools .partial (
117
123
lambda s : list (
118
124
[]
@@ -128,7 +134,11 @@ def get_parser() -> partial:
128
134
assert (
129
135
len (subtypes ) == 1
130
136
), "Sets are allowed only one subtype per PEP specification!"
131
- subtype_parser = _get_parser (cls , subtypes [0 ], parsers ,)
137
+ subtype_parser = _get_parser (
138
+ cls ,
139
+ subtypes [0 ],
140
+ parsers ,
141
+ )
132
142
return functools .partial (
133
143
lambda s : set (
134
144
set ({})
@@ -141,7 +151,12 @@ def get_parser() -> partial:
141
151
)
142
152
elif typing .get_origin (type_ ) == tuple :
143
153
subtype_parsers = [
144
- _get_parser (cls , subtype , parsers ,) for subtype in typing .get_args (type_ )
154
+ _get_parser (
155
+ cls ,
156
+ subtype ,
157
+ parsers ,
158
+ )
159
+ for subtype in typing .get_args (type_ )
145
160
]
146
161
147
162
def tuple_parse (tuple_string : str ) -> Tuple [Any , ...]:
@@ -170,8 +185,16 @@ def tuple_parse(tuple_string: str) -> Tuple[Any, ...]:
170
185
len (subtypes ) == 2
171
186
), "Dict object must have exactly 2 subtypes per PEP specification!"
172
187
(key_parser , val_parser ) = (
173
- _get_parser (cls , subtypes [0 ], parsers ,),
174
- _get_parser (cls , subtypes [1 ], parsers ,),
188
+ _get_parser (
189
+ cls ,
190
+ subtypes [0 ],
191
+ parsers ,
192
+ ),
193
+ _get_parser (
194
+ cls ,
195
+ subtypes [1 ],
196
+ parsers ,
197
+ ),
175
198
)
176
199
177
200
def dict_parse (dict_string : str ) -> Dict [Any , Any ]:
@@ -231,7 +254,9 @@ def dict_parse(dict_string: str) -> Dict[Any, Any]:
231
254
232
255
233
256
def attr_from (
234
- cls : Type , kwargs : Dict [str , str ], parsers : Optional [Dict [type , Callable [[str ], Any ]]] = None ,
257
+ cls : Type ,
258
+ kwargs : Dict [str , str ],
259
+ parsers : Optional [Dict [type , Callable [[str ], Any ]]] = None ,
235
260
) -> Any :
236
261
"""Builds an attr class from key-word arguments
237
262
0 commit comments