mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-459
Unreachable code positively fails - if (try.. except..) else return
This commit is contained in:
@@ -81,7 +81,7 @@ public class PyUnreachableCodeInspection extends LocalInspectionTool {
|
||||
final PsiElement e = instruction.getElement();
|
||||
if (colors[instruction.num()] != color){
|
||||
color = colors[instruction.num()];
|
||||
if (!warned[color]){
|
||||
if (color != 0 && !warned[color]){
|
||||
warned[color] = true;
|
||||
// Handle ensure parts
|
||||
if (e instanceof PyExceptPart) {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
if markup:
|
||||
try:
|
||||
return renderer
|
||||
except KeyError:
|
||||
raise Error
|
||||
else:
|
||||
return body
|
||||
@@ -0,0 +1,11 @@
|
||||
0(1) element: null
|
||||
1(2,8) element: PyIfStatement
|
||||
2(3) element: PyStatementList. Condition: markup:true
|
||||
3(4) element: PyTryExceptStatement
|
||||
4(5) element: PyTryPart
|
||||
5(10) element: PyReturnStatement
|
||||
6(7) element: PyExceptPart
|
||||
7(10) element: PyRaiseStatement
|
||||
8(9) element: PyElsePart. Condition: markup:false
|
||||
9(10) element: PyReturnStatement
|
||||
10() element: null
|
||||
@@ -78,6 +78,10 @@ public class PyControlFlowBuilderTest extends LightMarkedTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIfElseReturn() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testFunction() throws Exception {
|
||||
final String testName = getTestName(false).toLowerCase();
|
||||
configureByFile(testName + ".py");
|
||||
|
||||
Reference in New Issue
Block a user