mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 07:14:48 +08:00
Simplify early-exit code by having it once
This commit is contained in:
@@ -185,26 +185,28 @@ class TypingClassValueWithIndex(_TypingClassMixin, TypingValueWithIndex):
|
|||||||
from jedi.inference.gradual.annotation import merge_pairwise_generics, merge_type_var_dicts
|
from jedi.inference.gradual.annotation import merge_pairwise_generics, merge_type_var_dicts
|
||||||
from jedi.inference.gradual.base import GenericClass
|
from jedi.inference.gradual.base import GenericClass
|
||||||
|
|
||||||
annotation_name = self.py__name__()
|
|
||||||
type_var_dict = {}
|
type_var_dict = {}
|
||||||
annotation_generics = self.get_generics()
|
annotation_generics = self.get_generics()
|
||||||
|
|
||||||
if annotation_name == 'Type':
|
if not annotation_generics:
|
||||||
if annotation_generics:
|
return type_var_dict
|
||||||
if is_class_value:
|
|
||||||
for element in value_set:
|
|
||||||
element_name = element.py__name__()
|
|
||||||
if annotation_name == element_name:
|
|
||||||
merge_type_var_dicts(
|
|
||||||
type_var_dict,
|
|
||||||
merge_pairwise_generics(self, element),
|
|
||||||
)
|
|
||||||
|
|
||||||
else:
|
annotation_name = self.py__name__()
|
||||||
return annotation_generics[0].infer_type_vars(
|
if annotation_name == 'Type':
|
||||||
value_set,
|
if is_class_value:
|
||||||
is_class_value=True,
|
for element in value_set:
|
||||||
)
|
element_name = element.py__name__()
|
||||||
|
if annotation_name == element_name:
|
||||||
|
merge_type_var_dicts(
|
||||||
|
type_var_dict,
|
||||||
|
merge_pairwise_generics(self, element),
|
||||||
|
)
|
||||||
|
|
||||||
|
else:
|
||||||
|
return annotation_generics[0].infer_type_vars(
|
||||||
|
value_set,
|
||||||
|
is_class_value=True,
|
||||||
|
)
|
||||||
|
|
||||||
elif annotation_name == 'Callable':
|
elif annotation_name == 'Callable':
|
||||||
if len(annotation_generics) == 2:
|
if len(annotation_generics) == 2:
|
||||||
|
|||||||
Reference in New Issue
Block a user