forked from VimPlug/jedi
Introduce some stricter typing
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
from typing import Any
|
||||
|
||||
from jedi import debug
|
||||
from jedi.inference.cache import inference_state_method_cache, CachedMetaClass
|
||||
from jedi.inference import compiled
|
||||
@@ -53,6 +55,10 @@ class FunctionAndClassBase(TreeValue):
|
||||
|
||||
class FunctionMixin:
|
||||
api_type = 'function'
|
||||
tree_node: Any
|
||||
py__class__: Any
|
||||
as_context: Any
|
||||
get_signature_functions: Any
|
||||
|
||||
def get_filters(self, origin_scope=None):
|
||||
cls = self.py__class__()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from abc import abstractproperty
|
||||
from typing import Any
|
||||
|
||||
from jedi import debug
|
||||
from jedi import settings
|
||||
@@ -187,6 +188,8 @@ class CompiledInstance(AbstractInstanceValue):
|
||||
|
||||
|
||||
class _BaseTreeInstance(AbstractInstanceValue):
|
||||
get_defined_names: Any
|
||||
|
||||
@property
|
||||
def array_type(self):
|
||||
name = self.class_value.py__name__()
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
Contains all classes and functions to deal with lists, dicts, generators and
|
||||
iterators in general.
|
||||
"""
|
||||
from typing import Any
|
||||
|
||||
from jedi.inference import compiled
|
||||
from jedi.inference import analysis
|
||||
from jedi.inference.lazy_value import LazyKnownValue, LazyKnownValues, \
|
||||
@@ -20,6 +22,9 @@ from jedi.inference.value.dynamic_arrays import check_array_additions
|
||||
|
||||
|
||||
class IterableMixin:
|
||||
py__iter__: Any
|
||||
inference_state: Any
|
||||
|
||||
def py__next__(self, contextualized_node=None):
|
||||
return self.py__iter__(contextualized_node)
|
||||
|
||||
@@ -128,6 +133,12 @@ def comprehension_from_atom(inference_state, value, atom):
|
||||
|
||||
|
||||
class ComprehensionMixin:
|
||||
_defining_context: Any
|
||||
_entry_node: Any
|
||||
array_type: Any
|
||||
_value_node: Any
|
||||
_sync_comp_for_node: Any
|
||||
|
||||
@inference_state_method_cache()
|
||||
def _get_comp_for_context(self, parent_context, comp_for):
|
||||
return CompForContext(parent_context, comp_for)
|
||||
@@ -176,6 +187,8 @@ class ComprehensionMixin:
|
||||
|
||||
|
||||
class _DictMixin:
|
||||
get_mapping_item_values: Any
|
||||
|
||||
def _get_generics(self):
|
||||
return tuple(c_set.py__class__() for c_set in self.get_mapping_item_values())
|
||||
|
||||
@@ -248,6 +261,9 @@ class GeneratorComprehension(_BaseComprehension, GeneratorBase):
|
||||
|
||||
|
||||
class _DictKeyMixin:
|
||||
_dict_keys: Any
|
||||
_dict_values: Any
|
||||
|
||||
# TODO merge with _DictMixin?
|
||||
def get_mapping_item_values(self):
|
||||
return self._dict_keys(), self._dict_values()
|
||||
|
||||
@@ -38,7 +38,7 @@ py__doc__() Returns the docstring for a value.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import List, Optional, Tuple
|
||||
from typing import List, Optional, Tuple, TYPE_CHECKING, Any
|
||||
|
||||
from jedi import debug
|
||||
from jedi.parser_utils import get_cached_parent_scope, expr_is_dotted, \
|
||||
@@ -61,6 +61,9 @@ from inspect import Parameter
|
||||
from jedi.inference.names import BaseTreeParamName
|
||||
from jedi.inference.signature import AbstractSignature
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from jedi.inference import InferenceState
|
||||
|
||||
|
||||
class ClassName(TreeNameDefinition):
|
||||
def __init__(self, class_value, tree_name, name_context, apply_decorators):
|
||||
@@ -197,6 +200,15 @@ def get_dataclass_param_names(cls) -> List[DataclassParamName]:
|
||||
|
||||
|
||||
class ClassMixin:
|
||||
tree_node: Any
|
||||
parent_context: Any
|
||||
inference_state: InferenceState
|
||||
py__bases__: Any
|
||||
get_metaclasses: Any
|
||||
get_metaclass_filters: Any
|
||||
get_metaclass_signatures: Any
|
||||
list_type_vars: Any
|
||||
|
||||
def is_class(self):
|
||||
return True
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
from typing import Optional, TYPE_CHECKING, Any
|
||||
|
||||
from jedi.inference.cache import inference_state_method_cache
|
||||
from jedi.inference.names import AbstractNameDefinition, ModuleName
|
||||
@@ -13,6 +13,9 @@ from jedi.inference.compiled import create_simple_object
|
||||
from jedi.inference.base_value import ValueSet
|
||||
from jedi.inference.context import ModuleContext
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from jedi.inference import InferenceState
|
||||
|
||||
|
||||
class _ModuleAttributeName(AbstractNameDefinition):
|
||||
"""
|
||||
@@ -35,6 +38,11 @@ class _ModuleAttributeName(AbstractNameDefinition):
|
||||
|
||||
|
||||
class SubModuleDictMixin:
|
||||
inference_state: "InferenceState"
|
||||
is_package: Any
|
||||
py__path__: Any
|
||||
as_context: Any
|
||||
|
||||
@inference_state_method_cache()
|
||||
def sub_modules_dict(self):
|
||||
"""
|
||||
@@ -57,6 +65,10 @@ class SubModuleDictMixin:
|
||||
|
||||
class ModuleMixin(SubModuleDictMixin):
|
||||
_module_name_class = ModuleName
|
||||
tree_node: Any
|
||||
string_names: Any
|
||||
sub_modules_dict: Any
|
||||
py__file__: Any
|
||||
|
||||
def get_filters(self, origin_scope=None):
|
||||
yield MergedFilter(
|
||||
|
||||
Reference in New Issue
Block a user