1
0
forked from VimPlug/jedi

Fix stub function inferrals

This commit is contained in:
Dave Halter
2019-05-28 01:51:37 +02:00
parent 6f41530a03
commit ec7b6b8d80
5 changed files with 65 additions and 27 deletions

View File

@@ -306,17 +306,21 @@ def union4(x: U[int, str]):
#? int() str()
x
# -------------------------
# Type Vars
# -------------------------
TYPE_VAR = typing.TypeVar('TYPE_VAR')
TYPE_VARX = typing.TypeVar('TYPE_VARX')
TYPE_VAR_CONSTRAINTSX = typing.TypeVar('TYPE_VAR_CONSTRAINTSX', str, int)
# TODO there should at least be some results.
#? []
TYPE_VAR.
#! ["TYPE_VAR = typing.TypeVar('TYPE_VAR')"]
TYPE_VAR
TYPE_VARX.
#! ["TYPE_VARX = typing.TypeVar('TYPE_VARX')"]
TYPE_VARX
class WithTypeVar(typing.Generic[TYPE_VAR]):
def lala(self) -> TYPE_VAR:
class WithTypeVar(typing.Generic[TYPE_VARX]):
def lala(self) -> TYPE_VARX:
...
@@ -324,6 +328,33 @@ def maaan(p: WithTypeVar[int]):
#? int()
p.lala()
def in_out1(x: TYPE_VARX) -> TYPE_VARX: ...
#? int()
in_out1(1)
#? str()
in_out1("")
#? str()
in_out1(str())
#?
in_out1()
def in_out2(x: TYPE_VAR_CONSTRAINTSX) -> TYPE_VAR_CONSTRAINTSX: ...
#? int()
in_out2(1)
#? str()
in_out2("")
#? str()
in_out2(str())
#? str() int()
in_out2()
##? str() int()
in_out2(1.0)
# -------------------------
# TYPE_CHECKING
# -------------------------
if typing.TYPE_CHECKING:
with_type_checking = 1
@@ -352,6 +383,10 @@ def foo(a: typing.List, b: typing.Dict, c: typing.MutableMapping) -> typing.Type
#? int
foo()
# -------------------------
# cast
# -------------------------
def cast_tests():
x = 3.0
y = typing.cast(int, x)