Skip to content

Commit 17c5b6d

Browse files
committed
ignore erroneous mypy error
1 parent 36bc2f1 commit 17c5b6d

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

fgpyo/util/inspect.py

+32-10
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,17 @@ 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 outer_depth_of_split >= 0, "Unpaired depth character! Likely incorrect output"
63+
assert (
64+
outer_depth_of_split >= 0
65+
), "Unpaired depth character! Likely incorrect output"
6466

6567
current_outer_splits.append(high_level_split)
6668
if outer_depth_of_split == 0:
6769
out_vals.append(split_delim.join(current_outer_splits))
6870
current_outer_splits = []
69-
assert outer_depth_of_split == 0, "Unpaired depth character! Likely incorrect output!"
71+
assert (
72+
outer_depth_of_split == 0
73+
), "Unpaired depth character! Likely incorrect output!"
7074
return out_vals
7175

7276

@@ -148,7 +152,9 @@ def get_parser() -> partial:
148152
if s == "{}"
149153
else [
150154
subtype_parser(item)
151-
for item in set(split_at_given_level(s[1:-1], split_delim=","))
155+
for item in set(
156+
split_at_given_level(s[1:-1], split_delim=",")
157+
)
152158
]
153159
)
154160
)
@@ -174,7 +180,9 @@ def tuple_parse(tuple_string: str) -> Tuple[Any, ...]:
174180
if len(tuple_string) == 0:
175181
return ()
176182
else:
177-
val_strings = split_at_given_level(tuple_string, split_delim=",")
183+
val_strings = split_at_given_level(
184+
tuple_string, split_delim=","
185+
)
178186
return tuple(
179187
parser(val_str)
180188
for parser, val_str in zip(subtype_parsers, val_strings)
@@ -210,10 +218,14 @@ def dict_parse(dict_string: str) -> Dict[Any, Any]:
210218
if len(dict_string) == 0:
211219
return {}
212220
else:
213-
outer_splits = split_at_given_level(dict_string, split_delim=",")
221+
outer_splits = split_at_given_level(
222+
dict_string, split_delim=","
223+
)
214224
out_dict = {}
215225
for outer_split in outer_splits:
216-
inner_splits = split_at_given_level(outer_split, split_delim=";")
226+
inner_splits = split_at_given_level(
227+
outer_split, split_delim=";"
228+
)
217229
assert (
218230
len(inner_splits) % 2 == 0
219231
), "Inner splits of dict didn't have matched key val pairs"
@@ -228,17 +240,23 @@ def dict_parse(dict_string: str) -> Dict[Any, Any]:
228240
return types.make_enum_parser(type_)
229241
elif types.is_constructible_from_str(type_):
230242
return functools.partial(type_)
231-
elif type_ is type(None): # type: ignore[E721]
243+
elif type_ is type(None): # type: ignore
232244
return functools.partial(types.none_parser)
233245
elif types.get_origin_type(type_) is Union:
234246
return types.make_union_parser(
235247
union=type_,
236-
parsers=[_get_parser(cls, arg, parsers) for arg in types.get_arg_types(type_)],
248+
parsers=[
249+
_get_parser(cls, arg, parsers)
250+
for arg in types.get_arg_types(type_)
251+
],
237252
)
238253
elif types.get_origin_type(type_) is Literal: # Py>=3.7.
239254
return types.make_literal_parser(
240255
type_,
241-
[_get_parser(cls, type(arg), parsers) for arg in types.get_arg_types(type_)],
256+
[
257+
_get_parser(cls, type(arg), parsers)
258+
for arg in types.get_arg_types(type_)
259+
],
242260
)
243261
else:
244262
raise ParserNotFoundException(
@@ -293,7 +311,11 @@ def attr_from(
293311
# try setting by casting
294312
# Note that while bools *can* be cast from string, all non-empty strings evaluate to
295313
# True, because python, so we need to check for that explicitly
296-
if not set_value and attribute.type is not None and not attribute.type == bool:
314+
if (
315+
not set_value
316+
and attribute.type is not None
317+
and not attribute.type == bool
318+
):
297319
try:
298320
return_value = attribute.type(str_value)
299321
set_value = True

0 commit comments

Comments
 (0)