mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-19 23:09:43 +08:00
cache the parsed jedi_typing module
This commit is contained in:
@@ -77,18 +77,23 @@ def find_return_types(evaluator, func):
|
|||||||
return _evaluate_for_annotation(evaluator, annotation)
|
return _evaluate_for_annotation(evaluator, annotation)
|
||||||
|
|
||||||
|
|
||||||
# TODO: Memoize
|
_typing_module = None
|
||||||
|
|
||||||
|
|
||||||
def _get_typing_replacement_module():
|
def _get_typing_replacement_module():
|
||||||
"""
|
"""
|
||||||
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
|
||||||
as discussed at https://github.com/davidhalter/jedi/issues/663
|
as discussed at https://github.com/davidhalter/jedi/issues/663
|
||||||
"""
|
"""
|
||||||
|
global _typing_module
|
||||||
typing_path = os.path.abspath(os.path.join(__file__, "../jedi_typing.py"))
|
if _typing_module is None:
|
||||||
with open(typing_path) as f:
|
typing_path = \
|
||||||
code = _compatibility.unicode(f.read())
|
os.path.abspath(os.path.join(__file__, "../jedi_typing.py"))
|
||||||
p = ParserWithRecovery(load_grammar(), code)
|
with open(typing_path) as f:
|
||||||
return p.module
|
code = _compatibility.unicode(f.read())
|
||||||
|
p = ParserWithRecovery(load_grammar(), code)
|
||||||
|
_typing_module = p.module
|
||||||
|
return _typing_module
|
||||||
|
|
||||||
|
|
||||||
def get_types_for_typing_module(evaluator, typ, node):
|
def get_types_for_typing_module(evaluator, typ, node):
|
||||||
|
|||||||
Reference in New Issue
Block a user