From 1899f16a4af9f9a5e58270e493dadcf42fde3b33 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Thu, 29 May 2014 12:15:07 +0200 Subject: [PATCH] if there's a func listener, stop the execution of a function. This solves the issue of nested *args that were reported as having too many params in static analysis. --- jedi/evaluate/representation.py | 6 ++++++ test/static_analysis/star_arguments.py | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/jedi/evaluate/representation.py b/jedi/evaluate/representation.py index fc87b17a..b2609681 100644 --- a/jedi/evaluate/representation.py +++ b/jedi/evaluate/representation.py @@ -430,6 +430,12 @@ class FunctionExecution(Executable): # Feed the listeners, with the params. for listener in func.listeners: listener.execute(self._get_params()) + if func.listeners: + # If we do have listeners, that means that there's not a regular + # execution ongoing. In this case Jedi is interested in the + # inserted params, not in the actual execution of the function. + return [] + if func.is_generator and not evaluate_generator: return [iterable.Generator(self._evaluator, func, self.var_args)] else: diff --git a/test/static_analysis/star_arguments.py b/test/static_analysis/star_arguments.py index b455ffa0..61c804d6 100644 --- a/test/static_analysis/star_arguments.py +++ b/test/static_analysis/star_arguments.py @@ -1,3 +1,7 @@ +# ----------------- +# *args +# ----------------- + def simple(a): return a @@ -13,3 +17,13 @@ nested() def nested_no_call_to_function(*args): return simple(1, *args) + + +def simple2(a, b, c): + return b +def nested(*args): + return simple2(1, *args) +def nested_twice(*args1): + return nested(*args1) + +nested_twice(2, 3)