From b95d4586e2367385cd605e54593a90d3597b3ff3 Mon Sep 17 00:00:00 2001 From: Sean Breckenridge Date: Mon, 19 Apr 2021 02:22:18 -0700 Subject: [PATCH] guess_stats: test function name after signature possibility that you've just passed it a string or something which has no __name__, wait till we know it has a signature --- my/core/stats.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/my/core/stats.py b/my/core/stats.py index 1a59059..ec78839 100644 --- a/my/core/stats.py +++ b/my/core/stats.py @@ -34,9 +34,6 @@ def is_data_provider(fun: Any) -> bool: # one example which could benefit is my.pdfs if fun is None: return False - # probably a helper function? - if fun.__name__.startswith("_"): - return False # todo. uh.. very similar to what cachew is trying to do? try: sig = inspect.signature(fun) @@ -47,6 +44,10 @@ def is_data_provider(fun: Any) -> bool: if len(list(sig_required_params(sig))) > 0: return False + # probably a helper function? + if fun.__name__.startswith("_"): + return False + return_type = sig.return_annotation return type_is_iterable(return_type)