Skip to content

int | float ?= float inconsistency in Callable's return value ignores overlapping overloads #13775

Closed
@twoertwein

Description

@twoertwein

Bug Report

from typing import overload, Union, Callable, Any

Scalar = Union[int, float, complex]  # shows the error
# Scalar = complex  # hides the error

class A: ...
class B: ...

@overload
def apply(self, func: Callable[[A], Scalar]) -> B: ...

# error: Overloaded function signatures 1 and 2 overlap with incompatible return types  [misc]
@overload
def apply(self, func: Callable[[Any], float]) -> A: ...

Expected Behavior

In both cases the overloads should be overlapping.

Your Environment

  • Mypy version used: 0.971 and 0.981
  • Python version used: 3.10

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