From ff9fa16ab8e3ba944c1eb761847b72c6cba6aeca Mon Sep 17 00:00:00 2001 From: Bouke Haarsma Date: Mon, 10 Jul 2017 22:21:55 +0200 Subject: [PATCH 1/2] Use getfullargspec if available --- invoke/tasks.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/invoke/tasks.py b/invoke/tasks.py index 8138d6f39..0f98b78e8 100644 --- a/invoke/tasks.py +++ b/invoke/tasks.py @@ -132,7 +132,12 @@ def argspec(self, body): # TODO: __call__ exhibits the 'self' arg; do we manually nix 1st result # in argspec, or is there a way to get the "really callable" spec? func = body if isinstance(body, types.FunctionType) else body.__call__ - spec = inspect.getargspec(func) + # getargspec is deprecated on Python 3 and throws an error if + # annotations are used. + try: + spec = inspect.getfullargspec(func) + except AttributeError: + spec = inspect.getargspec(func) arg_names = spec.args[:] matched_args = [reversed(x) for x in [spec.args, spec.defaults or []]] spec_dict = dict(zip_longest(*matched_args, fillvalue=NO_DEFAULT)) From d309331463f0405321e1ab6f7a1206a35ed0b7a1 Mon Sep 17 00:00:00 2001 From: Bouke Haarsma Date: Wed, 12 Jul 2017 12:18:34 +0200 Subject: [PATCH 2/2] Removed trailing space --- invoke/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/invoke/tasks.py b/invoke/tasks.py index 0f98b78e8..5c3849692 100644 --- a/invoke/tasks.py +++ b/invoke/tasks.py @@ -132,7 +132,7 @@ def argspec(self, body): # TODO: __call__ exhibits the 'self' arg; do we manually nix 1st result # in argspec, or is there a way to get the "really callable" spec? func = body if isinstance(body, types.FunctionType) else body.__call__ - # getargspec is deprecated on Python 3 and throws an error if + # getargspec is deprecated on Python 3 and throws an error if # annotations are used. try: spec = inspect.getfullargspec(func)