]> crepu.dev Git - config.git/blame - djavu-asus/elpy/rpc-venv/lib/python3.11/site-packages/jedi/api/completion_cache.py
ActualizaciĆ³n de Readme
[config.git] / djavu-asus / elpy / rpc-venv / lib / python3.11 / site-packages / jedi / api / completion_cache.py
CommitLineData
53e6db90
DC
1from typing import Dict, Tuple, Callable
2
3CacheValues = Tuple[str, str, str]
4CacheValuesCallback = Callable[[], CacheValues]
5
6
7_cache: Dict[str, Dict[str, CacheValues]] = {}
8
9
10def save_entry(module_name: str, name: str, cache: CacheValues) -> None:
11 try:
12 module_cache = _cache[module_name]
13 except KeyError:
14 module_cache = _cache[module_name] = {}
15 module_cache[name] = cache
16
17
18def _create_get_from_cache(number: int) -> Callable[[str, str, CacheValuesCallback], str]:
19 def _get_from_cache(module_name: str, name: str, get_cache_values: CacheValuesCallback) -> str:
20 try:
21 return _cache[module_name][name][number]
22 except KeyError:
23 v = get_cache_values()
24 save_entry(module_name, name, v)
25 return v[number]
26 return _get_from_cache
27
28
29get_type = _create_get_from_cache(0)
30get_docstring_signature = _create_get_from_cache(1)
31get_docstring = _create_get_from_cache(2)