Skip to content

[red-knot] Support narrowing for assignment expressions #14866

@sharkdp

Description

@sharkdp

Narrowing should also be supported if the target is inside an assignment expression. For example:

def f() -> int | None: ...

if (x := f()) is not None:
    reveal_type(x)  # should be `int`

Metadata

Metadata

Assignees

No one assigned

    Labels

    tyMulti-file analysis & type inference

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions