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