Return annotations for compiled objects now help to infer

However only if it's a type, if it's a string, it doesn't work, yet

Fixes #1347
This commit is contained in:
Dave Halter
2019-06-22 00:15:20 +02:00
parent a62ba86d7b
commit aa2dc6be09
3 changed files with 20 additions and 1 deletions

View File

@@ -262,7 +262,7 @@ def test_completion_params():
def test_completion_param_annotations():
# Need to define this function not directly in Python. Otherwise Jedi is to
# clever and uses the Python code instead of the signature object.
code = 'def foo(a: 1, b: str, c: int = 1.0): pass'
code = 'def foo(a: 1, b: str, c: int = 1.0) -> bytes: pass'
exec_(code, locals())
script = jedi.Interpreter('foo', [locals()])
c, = script.completions()
@@ -271,6 +271,9 @@ def test_completion_param_annotations():
assert [d.name for d in b.infer()] == ['str']
assert {d.name for d in c.infer()} == {'int', 'float'}
d, = jedi.Interpreter('foo()', [locals()]).goto_definitions()
assert d.name == 'bytes'
def test_keyword_argument():
def f(some_keyword_argument):