Overriding a coroutine method does not add the "async" keyword (PY-19312)

This commit is contained in:
Elizaveta Shashkova
2017-11-27 15:48:37 +03:00
parent d2fc62ac29
commit c1807315f2
4 changed files with 22 additions and 0 deletions

View File

@@ -203,6 +203,9 @@ public class PyOverrideImplementUtil {
if (anno != null && level.isAtLeast(LanguageLevel.PYTHON30)) {
pyFunctionBuilder.annotation(anno.getText());
}
if (baseFunction.isAsync()) {
pyFunctionBuilder.makeAsync();
}
final TypeEvalContext context = TypeEvalContext.userInitiated(baseFunction.getProject(), baseFunction.getContainingFile());
final List<PyCallableParameter> baseParams = baseFunction.getParameters(context);
for (PyCallableParameter parameter : baseParams) {

View File

@@ -0,0 +1,6 @@
class A:
async def foo(self):
pass
class B(A):
<caret>pass

View File

@@ -0,0 +1,8 @@
class A:
async def foo(self):
pass
class B(A):
async def foo(self):
return super().foo()

View File

@@ -188,4 +188,9 @@ public class PyOverrideTest extends PyTestCase {
PyOverrideImplementUtil.overrideMethods(myFixture.getEditor(), cls, Collections.singletonList(new PyMethodMember(method)), false);
myFixture.checkResultByFile("override/" + getTestName(true) + "_after.py", true);
}
// PY-19312
public void testAsyncMethod() {
runWithLanguageLevel(LanguageLevel.PYTHON36, () -> doTest());
}
}