mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24:27 +08:00
Make sure Callable TypeVars are better identified, solves a part of #1413
This commit is contained in:
@@ -315,6 +315,17 @@ def _infer_type_vars(annotation_value, value_set, is_class_value=False):
|
|||||||
is_class_value=True,
|
is_class_value=True,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
elif name == 'Callable':
|
||||||
|
given = annotation_value.get_generics()
|
||||||
|
if len(given) == 2:
|
||||||
|
for nested_annotation_value in given[1]:
|
||||||
|
_merge_type_var_dicts(
|
||||||
|
type_var_dict,
|
||||||
|
_infer_type_vars(
|
||||||
|
nested_annotation_value,
|
||||||
|
value_set.execute_annotation(),
|
||||||
|
)
|
||||||
|
)
|
||||||
elif isinstance(annotation_value, LazyGenericClass):
|
elif isinstance(annotation_value, LazyGenericClass):
|
||||||
name = annotation_value.py__name__()
|
name = annotation_value.py__name__()
|
||||||
if name == 'Iterable':
|
if name == 'Iterable':
|
||||||
|
|||||||
@@ -402,6 +402,15 @@ type_in_out2()
|
|||||||
#? float()
|
#? float()
|
||||||
type_in_out2(float)
|
type_in_out2(float)
|
||||||
|
|
||||||
|
def ma(a: typing.Callable[[str], TYPE_VARX]) -> typing.Callable[[str], TYPE_VARX]:
|
||||||
|
return a
|
||||||
|
|
||||||
|
def mf(s: str) -> int:
|
||||||
|
return int(s)
|
||||||
|
|
||||||
|
#? int()
|
||||||
|
ma(mf)('2')
|
||||||
|
|
||||||
# -------------------------
|
# -------------------------
|
||||||
# TYPE_CHECKING
|
# TYPE_CHECKING
|
||||||
# -------------------------
|
# -------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user