File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -618,6 +618,9 @@ def accept_loop(
618618 self .options .enabled_error_codes .add (codes .REDUNDANT_EXPR )
619619 if warn_unreachable or warn_redundant :
620620 with self .binder .frame_context (can_skip = True , break_frame = 2 , continue_frame = 1 ):
621+ if on_enter_body is not None :
622+ on_enter_body ()
623+
621624 self .accept (body )
622625
623626 # If exit_condition is set, assume it must be False on exit from the loop:
Original file line number Diff line number Diff line change @@ -3895,7 +3895,17 @@ foo = [
38953895reveal_type(foo) # N: Revealed type is "builtins.list[Tuple[builtins.int, typing.Sequence[builtins.str]]]"
38963896[builtins fixtures/tuple.pyi]
38973897
3898- [case testForLoopIndexVaribaleNarrowing]
3898+ [case testForLoopIndexVaribaleNarrowing1]
3899+ # flags: --local-partial-types
3900+ from typing import Union
3901+ x: Union[int, str]
3902+ x = "abc"
3903+ for x in list[int]():
3904+ reveal_type(x) # N: Revealed type is "builtins.int"
3905+ reveal_type(x) # N: Revealed type is "Union[builtins.int, builtins.str]"
3906+
3907+ [case testForLoopIndexVaribaleNarrowing2]
3908+ # flags: --enable-error-code=redundant-expr
38993909from typing import Union
39003910x: Union[int, str]
39013911x = "abc"
You can’t perform that action at this time.
0 commit comments