diff --git a/test-data/unit/check-warnings.test b/test-data/unit/check-warnings.test index 99b611529980..0d425ff4dcc5 100644 --- a/test-data/unit/check-warnings.test +++ b/test-data/unit/check-warnings.test @@ -100,6 +100,31 @@ def j() -> int: [out] main:7: error: Missing return statement +[case testNoReturnForExhaustiveGenerator] +# flags: --warn-no-return +from itertools import count, cycle, repeat +def h() -> int: + for _i in count(1): # count is non-exhaustive + if bool(): + return 1 + +def i() -> int: + for _i in repeat(10, 3): + if bool(): + return 1 + if bool(): + break + +def j() -> int: + for _i in cycle((1, 2, 3)): # cycle is non-exhaustive + if bool(): + return 1 + if bool(): + continue +[builtins fixtures/list.pyi] +[out] +main:8: error: Missing return statement + [case testNoReturnExcept] # flags: --warn-no-return def f() -> int: