-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongpriority-1-normaltopic-pep-572PEP 572 (walrus operator)PEP 572 (walrus operator)topic-strict-optional
Description
The binder interaction doesn't work properly for assignments in the right-hand side of an and
(after if x and (y := 1):
, the type of y
isn't narrowed to int
).
Test case:
[case testAndRHS]
from typing import Optional
def f(x: Optional[int], y: Optional[int]) -> None:
if x and (y := 1):
reveal_type(y) # N: Revealed type is 'builtins.int'
(Currently it produces Revealed type is 'Union[builtins.int, None]'
instead.)
Followup from #6899
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongpriority-1-normaltopic-pep-572PEP 572 (walrus operator)PEP 572 (walrus operator)topic-strict-optional