diff --git a/jedi/cache.py b/jedi/cache.py index 29ed979f..1ff45201 100644 --- a/jedi/cache.py +++ b/jedi/cache.py @@ -13,14 +13,15 @@ these variables are being cleaned after every API usage. """ import time from functools import wraps +from typing import Any, Dict, Tuple from jedi import settings from parso.cache import parser_cache -_time_caches = {} +_time_caches: Dict[str, Dict[Any, Tuple[float, Any]]] = {} -def clear_time_caches(delete_all=False): +def clear_time_caches(delete_all: bool = False) -> None: """ Jedi caches many things, that should be completed after each completion finishes. diff --git a/jedi/inference/filters.py b/jedi/inference/filters.py index 6551cebc..35692169 100644 --- a/jedi/inference/filters.py +++ b/jedi/inference/filters.py @@ -3,9 +3,11 @@ Filters are objects that you can use to filter names in different scopes. They are needed for name resolution. """ from abc import abstractmethod +from typing import List, MutableMapping import weakref from parso.tree import search_ancestor +from parso.python.tree import Name, UsedNamesMapping from jedi.inference import flow_analysis from jedi.inference.base_value import ValueSet, ValueWrapper, \ @@ -15,6 +17,7 @@ from jedi.inference.utils import to_list from jedi.inference.names import TreeNameDefinition, ParamName, \ AnonymousParamName, AbstractNameDefinition +_definition_name_cache: MutableMapping[UsedNamesMapping, List[Name]] _definition_name_cache = weakref.WeakKeyDictionary() diff --git a/jedi/inference/flow_analysis.py b/jedi/inference/flow_analysis.py index 184f367f..be67f23c 100644 --- a/jedi/inference/flow_analysis.py +++ b/jedi/inference/flow_analysis.py @@ -1,12 +1,14 @@ +from typing import Dict, Optional + from jedi.parser_utils import get_flow_branch_keyword, is_scope, get_parent_scope from jedi.inference.recursion import execution_allowed from jedi.inference.helpers import is_big_annoying_library class Status(object): - lookup_table = {} + lookup_table: Dict[Optional[bool], 'Status'] = {} - def __init__(self, value, name): + def __init__(self, value: Optional[bool], name: str) -> None: self._value = value self._name = name Status.lookup_table[value] = self diff --git a/jedi/inference/gradual/typeshed.py b/jedi/inference/gradual/typeshed.py index e186bfc3..6295294d 100644 --- a/jedi/inference/gradual/typeshed.py +++ b/jedi/inference/gradual/typeshed.py @@ -2,6 +2,7 @@ import os import re from functools import wraps from collections import namedtuple +from typing import Dict, Mapping, Tuple from pathlib import Path from jedi import settings @@ -74,7 +75,7 @@ def _get_typeshed_directories(version_info): yield PathInfo(str(base_path.joinpath(check_version)), is_third_party) -_version_cache = {} +_version_cache: Dict[Tuple[int, int], Mapping[str, PathInfo]] = {} def _cache_stub_file_map(version_info):