Skip to content

Support type information from conditional expressions #806

@mrwright

Description

@mrwright

In code like the following:

from typing import *

x = {1: 2} # type: Union[Dict[int, int], str]
x.get(1, 1) if isinstance(x, dict) else 0

we should be able to figure out that x must be A Dict, but instead we get the error

dict.py:4: error: Some element of union has no attribute "get"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions