Skip to content

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

Closed

Description

@JelleZijlstra

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

Activity

  1. ilevkivskyi commented on Aug 12, 2019

    @ilevkivskyi
    Member

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

  2. JelleZijlstra commented on Aug 12, 2019

    @JelleZijlstra
    MemberAuthor

    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.

  3. added a commit that references this issue on Jan 8, 2020
    33fc8a3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions