From 8e27c601206c2431115739413794a24414603a53 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 27 May 2019 09:42:50 +0200 Subject: [PATCH] Fix async function inferring with decorators, fixes #1335 --- jedi/evaluate/context/function.py | 2 +- test/completion/async_.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/jedi/evaluate/context/function.py b/jedi/evaluate/context/function.py index 7818056d..985093d6 100644 --- a/jedi/evaluate/context/function.py +++ b/jedi/evaluate/context/function.py @@ -331,7 +331,7 @@ class FunctionExecutionContext(TreeContext): Created to be used by inheritance. """ evaluator = self.evaluator - is_coroutine = self.tree_node.parent.type == 'async_stmt' + is_coroutine = self.tree_node.parent.type in ('async_stmt', 'async_funcdef') is_generator = bool(get_yield_exprs(evaluator, self.tree_node)) from jedi.evaluate.gradual.typing import AnnotatedSubClass diff --git a/test/completion/async_.py b/test/completion/async_.py index 2af7fdda..e77a290e 100644 --- a/test/completion/async_.py +++ b/test/completion/async_.py @@ -82,3 +82,28 @@ async def foo(): normal_var2 = False #? ['normal_var1', 'normal_var2'] normal_var + + +class C: + @classmethod + async def async_for_classmethod(cls) -> "C": + return + + async def async_for_method(cls) -> int: + return + + +async def f(): + c = await C.async_for_method() + #? int() + c + d = await C().async_for_method() + #? int() + d + + e = await C.async_for_classmethod() + #? C() + e + f = await C().async_for_classmethod() + #? C() + f