mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 14:54:47 +08:00
Remove remap_type_vars, which was never used
This commit is contained in:
@@ -256,6 +256,15 @@ class ClassContext(use_metaclass(CachedMetaClass, ClassMixin, TreeContext)):
|
|||||||
from jedi.evaluate.gradual.typing import AnnotatedSubClass
|
from jedi.evaluate.gradual.typing import AnnotatedSubClass
|
||||||
|
|
||||||
def remap_type_vars():
|
def remap_type_vars():
|
||||||
|
"""
|
||||||
|
The TypeVars in the resulting classes have sometimes different names
|
||||||
|
and we need to check for that, e.g. a signature can be:
|
||||||
|
|
||||||
|
def iter(iterable: Iterable[_T]) -> Iterator[_T]: ...
|
||||||
|
|
||||||
|
However, the iterator is defined as Iterator[_T_co], which means it has
|
||||||
|
a different type var name.
|
||||||
|
"""
|
||||||
for type_var in self.list_type_vars():
|
for type_var in self.list_type_vars():
|
||||||
yield type_var_dict.get(type_var.py__name__(), NO_CONTEXTS)
|
yield type_var_dict.get(type_var.py__name__(), NO_CONTEXTS)
|
||||||
|
|
||||||
|
|||||||
@@ -203,26 +203,6 @@ def infer_return_types(function_execution_context):
|
|||||||
|
|
||||||
type_var_dict = infer_type_vars_for_execution(function_execution_context, all_annotations)
|
type_var_dict = infer_type_vars_for_execution(function_execution_context, all_annotations)
|
||||||
|
|
||||||
def remap_type_vars(context, type_var_dict):
|
|
||||||
"""
|
|
||||||
The TypeVars in the resulting classes have sometimes different names
|
|
||||||
and we need to check for that, e.g. a signature can be:
|
|
||||||
|
|
||||||
def iter(iterable: Iterable[_T]) -> Iterator[_T]: ...
|
|
||||||
|
|
||||||
However, the iterator is defined as Iterator[_T_co], which means it has
|
|
||||||
a different type var name.
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
func = context.list_type_vars
|
|
||||||
except AttributeError:
|
|
||||||
return type_var_dict
|
|
||||||
else:
|
|
||||||
return {
|
|
||||||
to.py__name__(): type_var_dict.get(from_.py__name__(), NO_CONTEXTS)
|
|
||||||
for from_, to in zip(unknown_type_vars, func())
|
|
||||||
}
|
|
||||||
|
|
||||||
return ContextSet(
|
return ContextSet(
|
||||||
ann.define_generics(type_var_dict)
|
ann.define_generics(type_var_dict)
|
||||||
if isinstance(ann, AbstractAnnotatedClass) else ann
|
if isinstance(ann, AbstractAnnotatedClass) else ann
|
||||||
|
|||||||
Reference in New Issue
Block a user