Skip to content

Commit da32b16

Browse files
STY: Apply ruff/flake8-bugbear rule B004
B004 Using `hasattr(x, "__call__")` to test if x is callable is unreliable. Use `callable(x)` for consistent results.
1 parent 325ad62 commit da32b16

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

nipype/interfaces/utility/wrappers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __init__(
7272

7373
super().__init__(**inputs)
7474
if function:
75-
if hasattr(function, "__call__"):
75+
if callable(function):
7676
try:
7777
self.inputs.function_str = getsource(function)
7878
except OSError:
@@ -103,7 +103,7 @@ def __init__(
103103

104104
def _set_function_string(self, obj, name, old, new):
105105
if name == "function_str":
106-
if hasattr(new, "__call__"):
106+
if callable(new):
107107
function_source = getsource(new)
108108
fninfo = new.__code__
109109
elif isinstance(new, (str, bytes)):

nipype/pipeline/plugins/debug.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def __init__(self, plugin_args=None):
1515
if (
1616
plugin_args
1717
and "callable" in plugin_args
18-
and hasattr(plugin_args["callable"], "__call__")
18+
and callable(plugin_args["callable"])
1919
):
2020
self._callable = plugin_args["callable"]
2121
else:

0 commit comments

Comments
 (0)