mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Don't process assignments in conditional expressions (PY-19856)
They lead to syntax error.
This commit is contained in:
@@ -172,7 +172,7 @@ public class PyRedeclarationInspection extends PyInspection {
|
||||
final PsiElement element = instruction.getElement();
|
||||
if (element == null) return false;
|
||||
|
||||
if (element instanceof PyTryExceptStatement) return true;
|
||||
if (element instanceof PyTryExceptStatement || element instanceof PyConditionalExpression) return true;
|
||||
|
||||
if (element instanceof PyForStatement) {
|
||||
final PyForPart forPart = ((PyForStatement)element).getForPart();
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
x = 1
|
||||
res1 = None if False else x = 2
|
||||
res2 = x = 2 if True else None
|
||||
@@ -160,6 +160,10 @@ public class PyRedeclarationInspectionTest extends PyInspectionTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testConditionalExpression() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected Class<? extends PyInspection> getInspectionClass() {
|
||||
|
||||
Reference in New Issue
Block a user