Skip to content

Commit

Permalink
Add test cases for #14209
Browse files Browse the repository at this point in the history
  • Loading branch information
NMertsch committed Aug 29, 2024
1 parent fe15ee6 commit c493513
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test-data/unit/check-possibly-undefined.test
Original file line number Diff line number Diff line change
Expand Up @@ -1043,3 +1043,40 @@ def foo(x: Union[int, str]) -> None:
assert_never(x)
f # OK
[builtins fixtures/tuple.pyi]

[case testForLoopBreakElseDefinition]
# flags: --enable-error-code possibly-undefined
# Regression test for https://github.com/python/mypy/issues/14209
for i in [1, 2, 3]:
if i:
b = i
break
else:
b = 1

b # OK

[case testForLoopBreakElseException]
# flags: --enable-error-code possibly-undefined
# Regression test for https://github.com/python/mypy/issues/14209
for i in [1, 2, 3]:
if i:
b = i
break
else:
raise BaseException()

b # OK
[builtins fixtures/exception.pyi]

[case testForLoopBreakElseEmpty]
# flags: --enable-error-code possibly-undefined
# Regression test for https://github.com/python/mypy/issues/14209
for i in [1, 2, 3]:
b = i
if i:
break
else:
b = 1

b # OK

0 comments on commit c493513

Please sign in to comment.