Don't forget about redeclaration under except (PY-28593)

This commit is contained in:
Semyon Proshev
2018-02-21 15:27:04 +03:00
parent 1454a82608
commit adf7e75b17
3 changed files with 10 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 || element instanceof PyConditionalExpression) return true;
if (element instanceof PyTryPart || element instanceof PyExceptPart || element instanceof PyConditionalExpression) return true;
if (element instanceof PyForStatement) {
final PyForPart forPart = ((PyForStatement)element).getForPart();
@@ -0,0 +1,4 @@
try:
import a
except:
a = None
@@ -164,6 +164,11 @@ public class PyRedeclarationInspectionTest extends PyInspectionTestCase {
doTest();
}
// PY-28593
public void testRedeclarationInExcept() {
doTest();
}
@NotNull
@Override
protected Class<? extends PyInspection> getInspectionClass() {