Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 572: Assignments not narrowed in right-hand side of and #7313

Closed
JelleZijlstra opened this issue Aug 10, 2019 · 2 comments · Fixed by #8258
Closed

PEP 572: Assignments not narrowed in right-hand side of and #7313

JelleZijlstra opened this issue Aug 10, 2019 · 2 comments · Fixed by #8258
Labels
bug mypy got something wrong priority-1-normal topic-pep-572 PEP 572 (walrus operator) topic-strict-optional

Comments

@JelleZijlstra
Copy link
Member

JelleZijlstra commented Aug 10, 2019

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

@JelleZijlstra JelleZijlstra added the topic-pep-572 PEP 572 (walrus operator) label Aug 10, 2019
@ilevkivskyi
Copy link
Member

@JelleZijlstra Just to clarify, will you have time/desire to work on the follow-up issues?

@JelleZijlstra
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong priority-1-normal topic-pep-572 PEP 572 (walrus operator) topic-strict-optional
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants