Closed
Description
The following code:
from collections.abc import Callable, Sequence
from functools import partial, reduce
from typing import cast, Any
CA = Callable[[Any], Any]
CB = Callable[[Callable[..., Any], Any], Any]
def f(s: Sequence[CA | CB]) -> CA:
return cast(CA, reduce(lambda a, b: partial(b, a), s))
produces the following output:
test.py: note: In function "f":
test.py:9:41: error: "Callable[[Any], Any] | Callable[[Callable[..., Any], Any], Any]" not callable [misc]
return cast(CA, reduce(lambda a, b: partial(b, a), s))
^
This looks like a false positive to me.
$ mypy --version
mypy 1.11.1 (compiled: yes)
$ python --version
Python 3.12.3
$ lsb_release -d
No LSB modules are available.
Description: Ubuntu 24.04 LTS