Describe the Bug
pyrefly 0.50.1 says that an overloaded function is incompatible with a Callable that takes a union of the overload argument types and returns (a union of) the overload return types, resulting in bad-assignment or bad-argument-type errors being reported depending on context.
Minimum reproducible example:
from typing import *
@overload
def foo(x: int) -> str: ...
@overload
def foo(x: str) -> str: ...
def foo(x: int | str) -> str:
return str(x)
bar: Callable[[int | str], str] = foo
# `Overload[
# (x: int) -> str
# (x: str) -> str
# ]` is not assignable to `(int | str) -> str` [bad-assignment]
Sandbox Link
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEALqcROgOZ0Q3G6UN0AqADroRAAVwA3GJSi5UmEZhhg6YXLgAU%2BRJ3QMAlHQC0APjpwGlXYVsjxUmXIVKVajdt2XKRsxas2dqJYbupaOnr8AD7%2BPibm3ogidCl0lDAMAK6U6LHaBvbo2KjWdADCqFBQqNiwANp1rNGxALoANK10ALzuuCIgbSBk6WBQpIQMtFAUAMR0AAqkI2MWGDgEdADGuOiQbNmoDBA7hCJzAMowMHQAFgwMxHCIAPTPwypjhLxszzDoz5hcJs4M9trsIPtKIdjv93JQ6KhJKhoDVYFsdnsDkcdnRcMRseg4Kd0GQGDcdsZpJQ4DDunQhCAAMyEACMACYGf0AL6DVCbI7SABi0BgFDQWDwRDIIC5QA
(Only applicable for extension issues) IDE Information
No response
Describe the Bug
pyrefly 0.50.1 says that an overloaded function is incompatible with a Callable that takes a union of the overload argument types and returns (a union of) the overload return types, resulting in
bad-assignmentorbad-argument-typeerrors being reported depending on context.Minimum reproducible example:
Sandbox Link
https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeS4ATrgLYAEALqcROgOZ0Q3G6UN0AqADroRAAVwA3GJSi5UmEZhhg6YXLgAU%2BRJ3QMAlHQC0APjpwGlXYVsjxUmXIVKVajdt2XKRsxas2dqJYbupaOnr8AD7%2BPibm3ogidCl0lDAMAK6U6LHaBvbo2KjWdADCqFBQqNiwANp1rNGxALoANK10ALzuuCIgbSBk6WBQpIQMtFAUAMR0AAqkI2MWGDgEdADGuOiQbNmoDBA7hCJzAMowMHQAFgwMxHCIAPTPwypjhLxszzDoz5hcJs4M9trsIPtKIdjv93JQ6KhJKhoDVYFsdnsDkcdnRcMRseg4Kd0GQGDcdsZpJQ4DDunQhCAAMyEACMACYGf0AL6DVCbI7SABi0BgFDQWDwRDIIC5QA
(Only applicable for extension issues) IDE Information
No response