From 322b2678258d8b29fddfe81eb13922bbddc84917 Mon Sep 17 00:00:00 2001 From: Sean Breckenridge Date: Mon, 19 Apr 2021 02:31:36 -0700 Subject: [PATCH] inspect.signature throws TypeError if callable() fails it raises typeerror not sure if it also raises a valueerror --- my/core/stats.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/my/core/stats.py b/my/core/stats.py index 869b53f..12e09a7 100644 --- a/my/core/stats.py +++ b/my/core/stats.py @@ -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]