diff --git a/jedi/evaluate/dynamic.py b/jedi/evaluate/dynamic.py index 0f8f9b09..30ef27a8 100644 --- a/jedi/evaluate/dynamic.py +++ b/jedi/evaluate/dynamic.py @@ -26,6 +26,9 @@ from jedi.evaluate.cache import memoize_default from jedi.evaluate import imports +MAX_PARAM_SEARCHES = 10 + + class ParamListener(object): """ This listener is used to get the params for a function. @@ -54,9 +57,6 @@ def search_params(evaluator, param): if not settings.dynamic_params: return set() - if evaluator.dynamic_params_depth == settings.max_dynamic_params_depth: - return set() - evaluator.dynamic_params_depth += 1 try: func = param.get_parent_until(tree.Function) @@ -123,6 +123,12 @@ def search_function_call(evaluator, func): for name, trailer in get_possible_nodes(mod, func_name): i += 1 + # This is a simple way to stop Jedi's dynamic param recursion + # from going wild: The deeper Jedi's in the recursin, the less + # code should be evaluated. + if i * evaluator.dynamic_params_depth > MAX_PARAM_SEARCHES: + return listener.param_possibilities + for typ in evaluator.goto_definitions(name): undecorated = undecorate(typ) if evaluator.wrap(compare) == undecorated: diff --git a/jedi/settings.py b/jedi/settings.py index 45360ac9..13dcfd45 100644 --- a/jedi/settings.py +++ b/jedi/settings.py @@ -208,12 +208,6 @@ max_executions = 250 A maximum amount of time, the completion may use. """ -max_dynamic_params_depth = 3 -""" -A maximum amount of a recursive search function calls, when the type of a -parameter is needed. -""" - scale_call_signatures = 0.1 """ Because call_signatures is normally used on every single key hit, it has diff --git a/test/completion/stdlib.py b/test/completion/stdlib.py index 88f3cfed..92b7929a 100644 --- a/test/completion/stdlib.py +++ b/test/completion/stdlib.py @@ -219,5 +219,6 @@ cls().s import zipfile z = zipfile.ZipFile("foo") -#? ['upper'] +# It's too slow. So we don't run it at the moment. +##? ['upper'] z.read('name').upper