diff --git a/test/completion/functions.py b/test/completion/functions.py index 48a5331b..7adebb2a 100644 --- a/test/completion/functions.py +++ b/test/completion/functions.py @@ -440,23 +440,6 @@ nested_def2('', c=1.0, b=1)[1] #? [] nested_def2('')[1] -# ----------------- -# function annotations (should be ignored at the moment) -# ----------------- -def annot(a:3, *args:3): - return a, args[0] - -#? str() -annot('', 1.0)[0] -#? float() -annot('', 1.0)[1] - -def annot_ret(a:3) -> 3: - return a - -#? str() -annot_ret('') - # ----------------- # magic methods # ----------------- diff --git a/test/test_evaluate/test_annotations.py b/test/test_evaluate/test_annotations.py new file mode 100644 index 00000000..1fefde3c --- /dev/null +++ b/test/test_evaluate/test_annotations.py @@ -0,0 +1,29 @@ +from textwrap import dedent + +import jedi +import pytest + + +@pytest.mark.skipif('sys.version_info[0] < 3') +def test_simple_annotations(): + """ + Annotations only exist in Python 3. + At the moment we ignore them. So they should be parsed and not interfere + with anything. + """ + + source = dedent("""\ + def annot(a:3): + return a + + annot('')""") + + assert [d.name for d in jedi.Script(source, ).goto_definitions()] == ['str'] + + source = dedent("""\ + + def annot_ret(a:3) -> 3: + return a + + annot_ret('')""") + assert [d.name for d in jedi.Script(source, ).goto_definitions()] == ['str']