mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 11:20:44 +07:00
PY-80524 Explicit return statement expected false positive for an if inside try / except
(cherry picked from commit 6877fc7b34622d7ae884233af96e06ea92c918c1) IJ-MR-161824 GitOrigin-RevId: 8c3219ea8bb8f547f7c314af8cb0d432c042cd7c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a8934362ff
commit
d8f57b77c6
@@ -0,0 +1,5 @@
|
||||
def func(x, y, z):
|
||||
<weak_warning descr="Missing return statement on some paths"><caret>if x:</weak_warning>
|
||||
return 42
|
||||
elif y:
|
||||
<weak_warning descr="'return' without value is inconsistent with other paths">return</weak_warning>
|
||||
@@ -0,0 +1,6 @@
|
||||
def func(x, y, z):
|
||||
if x:
|
||||
return 42
|
||||
elif y:
|
||||
return
|
||||
return None
|
||||
@@ -0,0 +1,5 @@
|
||||
def func(x, y, z):
|
||||
<weak_warning descr="Missing return statement on some paths">if x: </weak_warning>
|
||||
return 42
|
||||
elif y:
|
||||
<weak_warning descr="'return' without value is inconsistent with other paths"><caret>return</weak_warning>
|
||||
@@ -0,0 +1,5 @@
|
||||
def func(x, y, z):
|
||||
if x:
|
||||
return 42
|
||||
elif y:
|
||||
return None
|
||||
@@ -1,15 +0,0 @@
|
||||
def f(x) -> int | None:
|
||||
y = 42
|
||||
print(y)
|
||||
<weak_warning descr="Explicit return statement expected">if x == 1:
|
||||
return 42
|
||||
elif x == 2:
|
||||
<weak_warning descr="Explicit return value expected">return<caret></weak_warning>
|
||||
elif x == 3:
|
||||
raise Exception()
|
||||
elif x == 4:
|
||||
assert False
|
||||
elif x == 5:
|
||||
<weak_warning descr="Explicit return statement expected">assert x</weak_warning>
|
||||
elif x == 4:
|
||||
<weak_warning descr="Explicit return statement expected">pass</weak_warning></weak_warning>
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
def f(x) -> int | None:
|
||||
y = 42
|
||||
print(y)
|
||||
if x == 1:
|
||||
return 42
|
||||
elif x == 2:
|
||||
return None
|
||||
elif x == 3:
|
||||
raise Exception()
|
||||
elif x == 4:
|
||||
assert False
|
||||
elif x == 5:
|
||||
assert x
|
||||
return None
|
||||
elif x == 4:
|
||||
return None
|
||||
return None
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
class NotSuppressingContext:
|
||||
def __enter__(self):
|
||||
...
|
||||
def __exit__(self, exc_type, exc_val, exc_tb) -> bool | None:
|
||||
...
|
||||
|
||||
def foo():
|
||||
with NotSuppressingContext() as st:
|
||||
foo()
|
||||
<weak_warning descr="Explicit return statement expected">if bool():
|
||||
return 1<caret></weak_warning>
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
class NotSuppressingContext:
|
||||
def __enter__(self):
|
||||
...
|
||||
def __exit__(self, exc_type, exc_val, exc_tb) -> bool | None:
|
||||
...
|
||||
|
||||
def foo():
|
||||
with NotSuppressingContext() as st:
|
||||
foo()
|
||||
if bool():
|
||||
return 1
|
||||
return None
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
class SuppressingContext:
|
||||
def __enter__(self):
|
||||
...
|
||||
def __exit__(self, exc_type, exc_val, exc_tb) -> bool:
|
||||
...
|
||||
|
||||
def foo():
|
||||
<weak_warning descr="Explicit return statement expected">with SuppressingContext() as st:
|
||||
foo()
|
||||
return 1<caret></weak_warning>
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
class SuppressingContext:
|
||||
def __enter__(self):
|
||||
...
|
||||
def __exit__(self, exc_type, exc_val, exc_tb) -> bool:
|
||||
...
|
||||
|
||||
def foo():
|
||||
with SuppressingContext() as st:
|
||||
foo()
|
||||
return 1
|
||||
return None
|
||||
Reference in New Issue
Block a user