mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-15 06:11:57 +08:00
Limit dynamic param searches to not go crazy in a lot of occasions. Refs #574.
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user