Skip to content

Commit 4f04849

Browse files
author
Joel Collins
committed
Fixed broken rapply
1 parent 7c80f5a commit 4f04849

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/labthings/utilities.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,7 @@ def merge(first: dict, second: dict) -> dict:
212212

213213

214214
def rapply(
215-
data: Union[Dict, List, Tuple, Iterable],
216-
func: Callable,
217-
*args,
218-
apply_to_iterables: bool = True,
219-
**kwargs
215+
data: Any, func: Callable, *args, apply_to_iterables: bool = True, **kwargs
220216
) -> Union[Dict, List]:
221217
"""Recursively apply a function to a dictionary, list, array, or tuple
222218
@@ -240,7 +236,7 @@ def rapply(
240236
for key, val in data.items()
241237
}
242238
# If the object is a list, tuple, or range
243-
elif apply_to_iterables and (isinstance(data, Iterable)):
239+
elif apply_to_iterables and (isinstance(data, (list, tuple, range))):
244240
return [
245241
rapply(x, func, *args, apply_to_iterables=apply_to_iterables, **kwargs)
246242
for x in data

0 commit comments

Comments
 (0)