PY-52477 PY-78913 Add inspection for inconsistent returns

Merge-request: IJ-MR-154297
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

GitOrigin-RevId: e89225212cc981a5b256fca4ee23d77659b3ce5e
This commit is contained in:
Aleksandr.Govenko
2025-02-14 17:21:51 +00:00
committed by intellij-monorepo-bot
parent 6c8675e758
commit e8f5b1c631
14 changed files with 151 additions and 42 deletions
@@ -1,7 +1,15 @@
def f(x) -> int | None:
if x == 1:
y = 42
print(y)
<weak_warning descr="Explicit return statement expected">if x == 1:
return 42
elif x == 2:
<warning descr="Function returning 'int | None' has implicit 'return None'">return<caret></warning>
<weak_warning descr="Explicit return value expected">return<caret></weak_warning>
elif x == 3:
pass
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>
@@ -1,8 +1,17 @@
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