mirror of
https://github.com/davidhalter/jedi.git
synced 2026-03-07 00:11:54 +08:00
Add many test cases
While these definitely _ought_ to work on Python 2.7, the annotation support there is very limited and as Python 2 is deprecated it doesn't seem worth it.
This commit is contained in:
84
test/completion/pep0484_generic_passthroughs.py
Normal file
84
test/completion/pep0484_generic_passthroughs.py
Normal file
@@ -0,0 +1,84 @@
|
||||
# python >= 3.4
|
||||
from typing import Any, Iterable, List, Tuple, TypeVar
|
||||
|
||||
T = TypeVar('T')
|
||||
TList = TypeVar('TList', bound=List[Any])
|
||||
|
||||
untyped_list_str = ['abc', 'def']
|
||||
typed_list_str = ['abc', 'def'] # type: List[str]
|
||||
|
||||
untyped_tuple_str = ('abc',)
|
||||
typed_tuple_str = ('abc',) # type: Tuple[str]
|
||||
|
||||
|
||||
def untyped_passthrough(x):
|
||||
return x
|
||||
|
||||
def typed_list_generic_passthrough(x: List[T]) -> List[T]:
|
||||
return x
|
||||
|
||||
def typed_tuple_generic_passthrough(x: Tuple[T]) -> Tuple[T]:
|
||||
return x
|
||||
|
||||
def typed_iterable_generic_passthrough(x: Iterable[T]) -> Iterable[T]:
|
||||
return x
|
||||
|
||||
def typed_fully_generic_passthrough(x: T) -> T:
|
||||
return x
|
||||
|
||||
def typed_bound_generic_passthrough(x: TList) -> TList:
|
||||
return x
|
||||
|
||||
|
||||
for a in untyped_passthrough(untyped_list_str):
|
||||
#? str()
|
||||
a
|
||||
|
||||
for b in untyped_passthrough(typed_list_str):
|
||||
#? str()
|
||||
b
|
||||
|
||||
|
||||
for c in typed_list_generic_passthrough(untyped_list_str):
|
||||
#? str()
|
||||
c
|
||||
|
||||
for d in typed_list_generic_passthrough(typed_list_str):
|
||||
#? str()
|
||||
d
|
||||
|
||||
|
||||
for e in typed_iterable_generic_passthrough(untyped_list_str):
|
||||
#? str()
|
||||
e
|
||||
|
||||
for f in typed_iterable_generic_passthrough(typed_list_str):
|
||||
#? str()
|
||||
f
|
||||
|
||||
|
||||
for g in typed_tuple_generic_passthrough(untyped_tuple_str):
|
||||
#? str()
|
||||
g
|
||||
|
||||
for h in typed_tuple_generic_passthrough(typed_tuple_str):
|
||||
#? str()
|
||||
h
|
||||
|
||||
|
||||
for n in typed_fully_generic_passthrough(untyped_list_str):
|
||||
#? str()
|
||||
n
|
||||
|
||||
for o in typed_fully_generic_passthrough(typed_list_str):
|
||||
#? str()
|
||||
o
|
||||
|
||||
|
||||
for p in typed_bound_generic_passthrough(untyped_list_str):
|
||||
#? str()
|
||||
p
|
||||
|
||||
for q in typed_bound_generic_passthrough(typed_list_str):
|
||||
#? str()
|
||||
q
|
||||
Reference in New Issue
Block a user