@@ -57,17 +57,13 @@ def split_at_given_level(
57
57
decrease_in_depth += high_level_split .count (char )
58
58
outer_depth_of_split += increase_in_depth - decrease_in_depth
59
59
60
- assert (
61
- outer_depth_of_split >= 0
62
- ), "Unpaired depth character! Likely incorrect output"
60
+ assert outer_depth_of_split >= 0 , "Unpaired depth character! Likely incorrect output"
63
61
64
62
current_outer_splits .append (high_level_split )
65
63
if outer_depth_of_split == 0 :
66
64
out_vals .append (split_delim .join (current_outer_splits ))
67
65
current_outer_splits = []
68
- assert (
69
- outer_depth_of_split == 0
70
- ), "Unpaired depth character! Likely incorrect output!"
66
+ assert outer_depth_of_split == 0 , "Unpaired depth character! Likely incorrect output!"
71
67
return out_vals
72
68
73
69
@@ -149,9 +145,7 @@ def get_parser() -> partial:
149
145
if s == "{}"
150
146
else [
151
147
subtype_parser (item )
152
- for item in set (
153
- split_at_given_level (s [1 :- 1 ], split_delim = "," )
154
- )
148
+ for item in set (split_at_given_level (s [1 :- 1 ], split_delim = "," ))
155
149
]
156
150
)
157
151
)
@@ -177,9 +171,7 @@ def tuple_parse(tuple_string: str) -> Tuple[Any, ...]:
177
171
if len (tuple_string ) == 0 :
178
172
return ()
179
173
else :
180
- val_strings = split_at_given_level (
181
- tuple_string , split_delim = ","
182
- )
174
+ val_strings = split_at_given_level (tuple_string , split_delim = "," )
183
175
return tuple (
184
176
parser (val_str )
185
177
for parser , val_str in zip (subtype_parsers , val_strings )
@@ -215,14 +207,10 @@ def dict_parse(dict_string: str) -> Dict[Any, Any]:
215
207
if len (dict_string ) == 0 :
216
208
return {}
217
209
else :
218
- outer_splits = split_at_given_level (
219
- dict_string , split_delim = ","
220
- )
210
+ outer_splits = split_at_given_level (dict_string , split_delim = "," )
221
211
out_dict = {}
222
212
for outer_split in outer_splits :
223
- inner_splits = split_at_given_level (
224
- outer_split , split_delim = ";"
225
- )
213
+ inner_splits = split_at_given_level (outer_split , split_delim = ";" )
226
214
assert (
227
215
len (inner_splits ) % 2 == 0
228
216
), "Inner splits of dict didn't have matched key val pairs"
@@ -242,18 +230,12 @@ def dict_parse(dict_string: str) -> Dict[Any, Any]:
242
230
elif typing .get_origin (type_ ) is Union :
243
231
return types .make_union_parser (
244
232
union = type_ ,
245
- parsers = [
246
- _get_parser (cls , arg , parsers )
247
- for arg in typing .get_args (type_ )
248
- ],
233
+ parsers = [_get_parser (cls , arg , parsers ) for arg in typing .get_args (type_ )],
249
234
)
250
235
elif typing .get_origin (type_ ) is Literal : # Py>=3.7.
251
236
return types .make_literal_parser (
252
237
type_ ,
253
- [
254
- _get_parser (cls , type (arg ), parsers )
255
- for arg in typing .get_args (type_ )
256
- ],
238
+ [_get_parser (cls , type (arg ), parsers ) for arg in typing .get_args (type_ )],
257
239
)
258
240
else :
259
241
raise ParserNotFoundException (
@@ -308,11 +290,7 @@ def attr_from(
308
290
# try setting by casting
309
291
# Note that while bools *can* be cast from string, all non-empty strings evaluate to
310
292
# True, because python, so we need to check for that explicitly
311
- if (
312
- not set_value
313
- and attribute .type is not None
314
- and not attribute .type == bool
315
- ):
293
+ if not set_value and attribute .type is not None and not attribute .type == bool :
316
294
try :
317
295
return_value = attribute .type (str_value )
318
296
set_value = True
0 commit comments