Possibly even bug, maybe related to #6600 ?
from collections.abc import Callable
from typing import TypeVar
T = TypeVar("T")
def foo(obj: T | Callable[..., T]) -> None:
match obj:
case Callable() as func:
func()
I guess the issue is that if T is callable, then its signature might be incompatible? But for completely unknown T, I'd assume that func should be inferred as the widest possible type Callable[..., Any].
Possibly even bug, maybe related to #6600 ?
I guess the issue is that if
Tis callable, then its signature might be incompatible? But for completely unknownT, I'd assume thatfuncshould be inferred as the widest possible typeCallable[..., Any].