mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Don't highlight 'await' expression statements as having no effect (PY-16094)
This commit is contained in:
@@ -21,6 +21,7 @@ import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.ResolveResult;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.PyTokenTypes;
|
||||
import com.jetbrains.python.inspections.quickfix.StatementEffectFunctionCallQuickFix;
|
||||
import com.jetbrains.python.inspections.quickfix.StatementEffectIntroduceVariableQuickFix;
|
||||
import com.jetbrains.python.psi.*;
|
||||
@@ -149,6 +150,10 @@ public class PyStatementEffectInspection extends PyInspection {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (expression instanceof PyPrefixExpression) {
|
||||
final PyPrefixExpression prefixExpr = (PyPrefixExpression)expression;
|
||||
return prefixExpr.getOperator() == PyTokenTypes.AWAIT_KEYWORD;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
async def f(x):
|
||||
y = await x
|
||||
await x
|
||||
if await x:
|
||||
pass
|
||||
f(await x)
|
||||
<warning descr="Statement seems to have no effect">x</warning>
|
||||
return await x
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.jetbrains.python.inspections;
|
||||
|
||||
import com.jetbrains.python.fixtures.PyInspectionTestCase;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -26,6 +27,19 @@ public class PyStatementEffectInspectionTest extends PyInspectionTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAwait() {
|
||||
doTest(LanguageLevel.PYTHON35);
|
||||
}
|
||||
|
||||
private void doTest(@NotNull LanguageLevel level) {
|
||||
runWithLanguageLevel(level, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doTest();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Class<? extends PyInspection> getInspectionClass() {
|
||||
|
||||
Reference in New Issue
Block a user