Don't process assignments in conditional expressions (PY-19856)

They lead to syntax error.
This commit is contained in:
Semyon Proshev
2018-02-20 13:56:14 +03:00
parent f034a7a299
commit ac81a06e78
3 changed files with 8 additions and 1 deletions
@@ -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() {