mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-27 07:41:20 +08:00
Make it possible to infer Callable TypeVars, fixes #1449
This commit is contained in:
@@ -420,6 +420,19 @@ xxx([0])[1]
|
||||
#?
|
||||
xxx([0])[2]
|
||||
|
||||
def call_pls() -> typing.Callable[[TYPE_VARX], TYPE_VARX]: ...
|
||||
#? int()
|
||||
call_pls()(1)
|
||||
|
||||
def call2_pls() -> typing.Callable[[str, typing.Callable[[int], TYPE_VARX]], TYPE_VARX]: ...
|
||||
#? float()
|
||||
call2_pls('')(1, lambda x: 3.0)
|
||||
|
||||
def call3_pls() -> typing.Callable[[typing.Callable[[int], TYPE_VARX]], typing.List[TYPE_VARX]]: ...
|
||||
def the_callable() -> float: ...
|
||||
#? float()
|
||||
call3_pls()(the_callable)[0]
|
||||
|
||||
# -------------------------
|
||||
# TYPE_CHECKING
|
||||
# -------------------------
|
||||
|
||||
@@ -329,3 +329,24 @@ X.attr_y.value
|
||||
X().name
|
||||
#? float()
|
||||
X().attr_x.attr_y.value
|
||||
|
||||
|
||||
# -----------------
|
||||
# functools Python 3.8
|
||||
# -----------------
|
||||
|
||||
# python >= 3.8
|
||||
|
||||
@functools.lru_cache
|
||||
def x() -> int: ...
|
||||
@functools.lru_cache()
|
||||
def y() -> float: ...
|
||||
@functools.lru_cache(8)
|
||||
def z() -> str: ...
|
||||
|
||||
#? int()
|
||||
x()
|
||||
#? float()
|
||||
y()
|
||||
#? str()
|
||||
z()
|
||||
|
||||
Reference in New Issue
Block a user