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'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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