mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Make sure param hints are working for functions
This commit is contained in:
@@ -573,6 +573,7 @@ def test_definition_goto_follow_imports(Script):
|
||||
|
||||
('n: Type[List[int]]; n', 'Type[List[int]]'),
|
||||
('n: Type[List]; n', 'Type[list]'),
|
||||
('n: List; n', 'list'),
|
||||
('n: List[int]; n', 'List[int]'),
|
||||
('n: Iterable[int]; n', 'Iterable[int]'),
|
||||
|
||||
@@ -583,9 +584,17 @@ def test_definition_goto_follow_imports(Script):
|
||||
('n = (1,); n', 'Tuple[int]'),
|
||||
('n = {1: ""}; n', 'Dict[int, str]'),
|
||||
('n = {1: "", 1.0: b""}; n', 'Dict[Union[float, int], Union[bytes, str]]'),
|
||||
|
||||
('n = next; n', 'Union[next(__i: Iterator[_T]) -> _T, '
|
||||
'next(__i: Iterator[_T], default: _VT) -> Union[_T, _VT]]'),
|
||||
('abs', 'abs(__n: SupportsAbs[_T]) -> _T'),
|
||||
('def foo(x, y): return x if xxxx else y\nfoo(str(), 1)\nfoo',
|
||||
'foo(x: str, y: int) -> Union[int, str]'),
|
||||
('def foo(x, y = None): return x if xxxx else y\nfoo(str(), 1)\nfoo',
|
||||
'foo(x: str, y: int=None) -> Union[int, str]'),
|
||||
]
|
||||
)
|
||||
def test_get_type_hint(Script, code, expected, skip_python2):
|
||||
def test_get_type_hint(Script, code, expected, skip_pre_python35):
|
||||
code = 'from typing import *\n' + code
|
||||
d, = Script(code).goto()
|
||||
assert d.get_type_hint() == expected
|
||||
|
||||
Reference in New Issue
Block a user