Skip to content

Unexpected Error Output For Return Type Hint Of Tuple Of Optionals With numbers.Real #10018

@coder0xff

Description

@coder0xff

Bug Report

The following code produces an unexpected error

def foo() -> Tuple[Optional[int], Optional[Real]]:
    x: int = 5
    return (x, x)  # Incompatible return value type (got "Tuple[int, int]", expected "Tuple[Optional[int], Optional[Real]]")

To Reproduce

Run mypy on the above

Expected Behavior

No error

Actual Behavior

The following error is produced
Incompatible return value type (got "Tuple[int, int]", expected "Tuple[Optional[int], Optional[Real]]")

Your Environment

  • Mypy version used: 0.800
  • Python version used: 3.8
  • Operating system and version: Ubuntu 18.04.5 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong
    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