Skip to content

Commit 89c855a

Browse files
committed
reformat
1 parent 17c5b6d commit 89c855a

File tree

1 file changed

+9
-31
lines changed

1 file changed

+9
-31
lines changed

fgpyo/util/inspect.py

+9-31
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,13 @@ def split_at_given_level(
6060
decrease_in_depth += high_level_split.count(char)
6161
outer_depth_of_split += increase_in_depth - decrease_in_depth
6262

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"
6664

6765
current_outer_splits.append(high_level_split)
6866
if outer_depth_of_split == 0:
6967
out_vals.append(split_delim.join(current_outer_splits))
7068
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!"
7470
return out_vals
7571

7672

@@ -152,9 +148,7 @@ def get_parser() -> partial:
152148
if s == "{}"
153149
else [
154150
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=","))
158152
]
159153
)
160154
)
@@ -180,9 +174,7 @@ def tuple_parse(tuple_string: str) -> Tuple[Any, ...]:
180174
if len(tuple_string) == 0:
181175
return ()
182176
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=",")
186178
return tuple(
187179
parser(val_str)
188180
for parser, val_str in zip(subtype_parsers, val_strings)
@@ -218,14 +210,10 @@ def dict_parse(dict_string: str) -> Dict[Any, Any]:
218210
if len(dict_string) == 0:
219211
return {}
220212
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=",")
224214
out_dict = {}
225215
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=";")
229217
assert (
230218
len(inner_splits) % 2 == 0
231219
), "Inner splits of dict didn't have matched key val pairs"
@@ -245,18 +233,12 @@ def dict_parse(dict_string: str) -> Dict[Any, Any]:
245233
elif types.get_origin_type(type_) is Union:
246234
return types.make_union_parser(
247235
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_)],
252237
)
253238
elif types.get_origin_type(type_) is Literal: # Py>=3.7.
254239
return types.make_literal_parser(
255240
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_)],
260242
)
261243
else:
262244
raise ParserNotFoundException(
@@ -311,11 +293,7 @@ def attr_from(
311293
# try setting by casting
312294
# Note that while bools *can* be cast from string, all non-empty strings evaluate to
313295
# 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:
319297
try:
320298
return_value = attribute.type(str_value)
321299
set_value = True

0 commit comments

Comments
 (0)