Introduce some stricter typing

This commit is contained in:
Dave Halter
2026-02-04 01:19:14 +01:00
parent c7481b3319
commit 30ef824abd
28 changed files with 171 additions and 67 deletions
+16
View File
@@ -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()