inspect.signature throws TypeError

if callable() fails it raises typeerror
not sure if it also raises a valueerror
This commit is contained in:
Sean Breckenridge 2021-04-19 02:31:36 -07:00
parent fa5983613b
commit 322b267825

View file

@ -37,7 +37,7 @@ def is_data_provider(fun: Any) -> bool:
# todo. uh.. very similar to what cachew is trying to do?
try:
sig = inspect.signature(fun)
except ValueError: # not a function?
except (ValueError, TypeError): # not a function?
return False
# has at least one argument without default values
@ -56,6 +56,7 @@ def test_is_data_provider() -> None:
idp = is_data_provider
assert not idp(None)
assert not idp(int)
assert not idp("x")
def no_return_type():
return [1, 2 ,3]