mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Suppress highlighting empty raise without exception to re-raise in functions (PY-27232)
This commit is contained in:
@@ -3,10 +3,7 @@ package com.jetbrains.python.validation;
|
||||
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.psi.PyExceptPart;
|
||||
import com.jetbrains.python.psi.PyFinallyPart;
|
||||
import com.jetbrains.python.psi.PyRaiseStatement;
|
||||
import com.jetbrains.python.psi.PyTryExceptStatement;
|
||||
import com.jetbrains.python.psi.*;
|
||||
|
||||
/**
|
||||
* Marks misplaced default 'except' clauses.
|
||||
@@ -30,7 +27,8 @@ public class TryExceptAnnotator extends PyAnnotator {
|
||||
|
||||
@Override
|
||||
public void visitPyRaiseStatement(PyRaiseStatement node) {
|
||||
if (node.getExpressions().length == 0 && PsiTreeUtil.getParentOfType(node, PyExceptPart.class, PyFinallyPart.class) == null) {
|
||||
if (node.getExpressions().length == 0 &&
|
||||
PsiTreeUtil.getParentOfType(node, PyExceptPart.class, PyFinallyPart.class, PyFunction.class) == null) {
|
||||
markError(node, "No exception to reraise");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,10 @@ except:
|
||||
try:
|
||||
raise ValueError
|
||||
finally:
|
||||
<error descr="Python version 2.7 does not support this syntax. Raise with no arguments can only be used in an except block">raise</error>
|
||||
<error descr="Python version 2.7 does not support this syntax. Raise with no arguments can only be used in an except block">raise</error>
|
||||
|
||||
|
||||
def exception_handler():
|
||||
if undefined:
|
||||
raise
|
||||
log_somehow()
|
||||
@@ -24,4 +24,9 @@ try:
|
||||
pass
|
||||
except:
|
||||
raise
|
||||
|
||||
def exception_handler():
|
||||
if undefined:
|
||||
raise
|
||||
log_somehow()
|
||||
|
||||
Reference in New Issue
Block a user