Skip to content

Can't convert from Tuple of optional to Tuple of non-optional #8622

Open
@kventinel

Description

@kventinel

Code:

from typing import Tuple, Optional

a: Tuple[Optional[int], Optional[int]] = (1, 1)
b: Tuple[int, int]
if a[0] is not None and a[1] is not None:
    b = a

After that has error:

script.py:6: error: Incompatible types in assignment (expression has type "Tuple[Optional[int], Optional[int]]", variable has type "Tuple[int, int]")

Expected no error.
I have: mypy-0.770 and Python 3.7.7

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions