Closed
Description
Seems similar to #17646 but not fixed in https://mypy-play.net/?mypy=master&python=3.12
The linked #17659 is not applicable because I am not using Self.
Sample code:
import functools
import typing as T
from typing_extensions import TypeAlias
FooBarFunc: TypeAlias = T.Callable[..., 'FooBar']
class FooBar:
def __init__(self, arg1: str) -> None:
pass
def transform(t: T.Union[T.Type[FooBar], FooBarFunc]) -> None:
val = functools.partial(t)
Error:
main.py:12: error: "type[FooBar] | Callable[..., FooBar]" not callable [misc]
The codebase where this was discovered: https://github.com/mesonbuild/meson/blob/83f8de5357f31d6448ae033e1e8ed2b22c8c306a/mesonbuild/dependencies/factory.py#L75-L95
mesonbuild/dependencies/factory.py:95:38: error: "type[CMakeDependency] | Callable[..., CMakeDependency]" not callable [misc]
Both sides of the union if cast and used independently, work.