You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PEP 572: Assignments not narrowed in right-hand side of and #7313
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.)
Activity
ilevkivskyi commentedon Aug 12, 2019
@JelleZijlstra Just to clarify, will you have time/desire to work on the follow-up issues?
JelleZijlstra commentedon Aug 12, 2019
Don't count on it; I don't have a lot of time right now. If I start work on one of them I'll assign it to myself.
Narrow types for walrus assignment in if statements (#8258)