mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
Avoid recursion issues for the typing module
This commit is contained in:
@@ -219,6 +219,14 @@ _typing_module = None
|
|||||||
_typing_module_code_lines = None
|
_typing_module_code_lines = None
|
||||||
|
|
||||||
|
|
||||||
|
class TypingModuleContext(ModuleContext):
|
||||||
|
"""
|
||||||
|
TODO this is currently used for recursion checks. We should just completely
|
||||||
|
refactor the typing module integration.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _get_typing_replacement_module(grammar):
|
def _get_typing_replacement_module(grammar):
|
||||||
"""
|
"""
|
||||||
The idea is to return our jedi replacement for the PEP-0484 typing module
|
The idea is to return our jedi replacement for the PEP-0484 typing module
|
||||||
@@ -263,7 +271,7 @@ def py__getitem__(context, typ, node):
|
|||||||
return context.eval_node(nodes[0])
|
return context.eval_node(nodes[0])
|
||||||
|
|
||||||
module_node, code_lines = _get_typing_replacement_module(context.evaluator.latest_grammar)
|
module_node, code_lines = _get_typing_replacement_module(context.evaluator.latest_grammar)
|
||||||
typing = ModuleContext(
|
typing = TypingModuleContext(
|
||||||
context.evaluator,
|
context.evaluator,
|
||||||
module_node=module_node,
|
module_node=module_node,
|
||||||
path=None,
|
path=None,
|
||||||
|
|||||||
@@ -116,7 +116,9 @@ class ExecutionRecursionDetector(object):
|
|||||||
self._parent_execution_funcs.append(funcdef)
|
self._parent_execution_funcs.append(funcdef)
|
||||||
|
|
||||||
module = execution.get_root_context()
|
module = execution.get_root_context()
|
||||||
if module == self._evaluator.builtins_module:
|
|
||||||
|
from jedi.evaluate.pep0484 import TypingModuleContext
|
||||||
|
if module == self._evaluator.builtins_module or isinstance(module, TypingModuleContext):
|
||||||
# We have control over builtins so we know they are not recursing
|
# We have control over builtins so we know they are not recursing
|
||||||
# like crazy. Therefore we just let them execute always, because
|
# like crazy. Therefore we just let them execute always, because
|
||||||
# they usually just help a lot with getting good results.
|
# they usually just help a lot with getting good results.
|
||||||
|
|||||||
Reference in New Issue
Block a user