Skip to content

Commit db07091

Browse files
brianschubertharahu
andcommitted
Add test case for decorated functions that always return none
Co-authored-by: Harald Husum <[email protected]>
1 parent ab766cc commit db07091

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test-data/unit/check-expressions.test

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,32 @@ f() and b # E: "f" does not return a value (it only ever returns None)
11441144
b or f() # E: "f" does not return a value (it only ever returns None)
11451145
[builtins fixtures/bool.pyi]
11461146

1147+
[case testNoneReturnDecorated]
1148+
from typing import Any, Callable, TypeVar
1149+
1150+
F = TypeVar('F', bound=Callable[..., Any])
1151+
1152+
def deco(f: F) -> F:
1153+
pass
1154+
1155+
@deco
1156+
@deco
1157+
def f() -> None:
1158+
pass
1159+
1160+
class A:
1161+
@staticmethod
1162+
def s() -> None:
1163+
pass
1164+
1165+
if int():
1166+
x = f() # E: "f" does not return a value (it only ever returns None)
1167+
if int():
1168+
x = A.s() # E: "s" of "A" does not return a value (it only ever returns None)
1169+
if int():
1170+
x = A().s() # E: "s" of "A" does not return a value (it only ever returns None)
1171+
[builtins fixtures/staticmethod.pyi]
1172+
11471173

11481174
-- Slicing
11491175
-- -------

0 commit comments

Comments
 (0)