1
0
forked from VimPlug/jedi

Reset the recursion limitations at the start of the main Script calls, fixes #1796

This commit is contained in:
Dave Halter
2023-07-27 13:14:24 +02:00
parent 6ea5ad7b19
commit 01d8da8f73

View File

@@ -206,6 +206,7 @@ class Script:
before magic methods and name mangled names that start with ``__``. before magic methods and name mangled names that start with ``__``.
:rtype: list of :class:`.Completion` :rtype: list of :class:`.Completion`
""" """
self._inference_state.reset_recursion_limitations()
with debug.increase_indent_cm('complete'): with debug.increase_indent_cm('complete'):
completion = Completion( completion = Completion(
self._inference_state, self._get_module_context(), self._code_lines, self._inference_state, self._get_module_context(), self._code_lines,
@@ -215,6 +216,7 @@ class Script:
@validate_line_column @validate_line_column
def infer(self, line=None, column=None, *, only_stubs=False, prefer_stubs=False): def infer(self, line=None, column=None, *, only_stubs=False, prefer_stubs=False):
self._inference_state.reset_recursion_limitations()
""" """
Return the definitions of under the cursor. It is basically a wrapper Return the definitions of under the cursor. It is basically a wrapper
around Jedi's type inference. around Jedi's type inference.
@@ -260,6 +262,7 @@ class Script:
@validate_line_column @validate_line_column
def goto(self, line=None, column=None, *, follow_imports=False, follow_builtin_imports=False, def goto(self, line=None, column=None, *, follow_imports=False, follow_builtin_imports=False,
only_stubs=False, prefer_stubs=False): only_stubs=False, prefer_stubs=False):
self._inference_state.reset_recursion_limitations()
""" """
Goes to the name that defined the object under the cursor. Optionally Goes to the name that defined the object under the cursor. Optionally
you can follow imports. you can follow imports.
@@ -365,6 +368,7 @@ class Script:
:rtype: list of :class:`.Name` :rtype: list of :class:`.Name`
""" """
self._inference_state.reset_recursion_limitations()
definitions = self.goto(line, column, follow_imports=True) definitions = self.goto(line, column, follow_imports=True)
if definitions: if definitions:
return definitions return definitions
@@ -406,6 +410,7 @@ class Script:
the current module only. the current module only.
:rtype: list of :class:`.Name` :rtype: list of :class:`.Name`
""" """
self._inference_state.reset_recursion_limitations()
def _references(include_builtins=True, scope='project'): def _references(include_builtins=True, scope='project'):
if scope not in ('project', 'file'): if scope not in ('project', 'file'):
@@ -440,6 +445,7 @@ class Script:
:rtype: list of :class:`.Signature` :rtype: list of :class:`.Signature`
""" """
self._inference_state.reset_recursion_limitations()
pos = line, column pos = line, column
call_details = helpers.get_signature_details(self._module_node, pos) call_details = helpers.get_signature_details(self._module_node, pos)
if call_details is None: if call_details is None:
@@ -559,6 +565,7 @@ class Script:
return parso_to_jedi_errors(self._inference_state.grammar, self._module_node) return parso_to_jedi_errors(self._inference_state.grammar, self._module_node)
def _names(self, all_scopes=False, definitions=True, references=False): def _names(self, all_scopes=False, definitions=True, references=False):
self._inference_state.reset_recursion_limitations()
# Set line/column to a random position, because they don't matter. # Set line/column to a random position, because they don't matter.
module_context = self._get_module_context() module_context = self._get_module_context()
defs = [ defs = [