Skip to content

Don't silently ignore some partial types #3031

Description

@ddfisher

After #3024, mypy won't complain when inferring the type of a variable as None. Unfortunately, in some circumstances we drop information about the variable that makes this invalid. For example:

T = TypeVar('T')
def f(*x: T) -> Dict[int, T]: pass
x = None
if bool():
    x = f()
reveal_type(x)  # E: Revealed type is 'builtins.None'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions