From 6d632a01eb384059bbc34c360ae49d2ba47a5d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= Date: Fri, 8 Nov 2019 11:07:31 +0100 Subject: [PATCH] Fix inference from type comment for function parameter with dot fix for https://github.com/davidhalter/jedi/issues/1437 --- jedi/inference/gradual/annotation.py | 2 +- test/completion/pep0484_comments.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/jedi/inference/gradual/annotation.py b/jedi/inference/gradual/annotation.py index 257de6e5..cfde9f0f 100644 --- a/jedi/inference/gradual/annotation.py +++ b/jedi/inference/gradual/annotation.py @@ -91,7 +91,7 @@ def _split_comment_param_declaration(decl_text): debug.warning('Comment annotation is not valid Python: %s' % decl_text) return [] - if node.type == 'name': + if node.type in ['name', 'atom_expr', 'power']: return [node.get_code().strip()] params = [] diff --git a/test/completion/pep0484_comments.py b/test/completion/pep0484_comments.py index 9f0661ec..902d1a15 100644 --- a/test/completion/pep0484_comments.py +++ b/test/completion/pep0484_comments.py @@ -38,6 +38,20 @@ def test(a, b): #? str() e +class AA: + class BB: + pass + +def test(a): + # type: (AA.BB) -> None + #? AA.BB() + a + +def test(a): + # type: (AA.BB,) -> None + #? AA.BB() + a + a,b = 1, 2 # type: str, float #? str() a