@@ -346,15 +346,32 @@ fn1: Union[Callable[[int], int], Callable[[int], int]]
346346reveal_type(functools.partial(fn1, 2)()) # N: Revealed type is "builtins.int"
347347
348348fn2: Union[Callable[[int], int], Callable[[int], str]]
349- reveal_type(functools.partial(fn2, 2)()) # N: Revealed type is "builtins.object "
349+ reveal_type(functools.partial(fn2, 2)()) # N: Revealed type is "Union[ builtins.int, builtins.str] "
350350
351351fn3: Union[Callable[[int], int], str]
352352reveal_type(functools.partial(fn3, 2)()) # E: "str" not callable \
353- # E: "Union[Callable[[int], int], str]" not callable \
354353 # N: Revealed type is "builtins.int" \
355354 # E: Argument 1 to "partial" has incompatible type "Union[Callable[[int], int], str]"; expected "Callable[..., int]"
356355[builtins fixtures/tuple.pyi]
357356
357+ [case testFunctoolsPartialUnionOfTypeAndCallable]
358+ import functools
359+ from typing import Callable, Union, Type
360+ from typing_extensions import TypeAlias
361+
362+ class FooBar:
363+ def __init__(self, arg1: str) -> None:
364+ pass
365+
366+ def f1(t: Union[Type[FooBar], Callable[..., 'FooBar']]) -> None:
367+ val = functools.partial(t)
368+
369+ FooBarFunc: TypeAlias = Callable[..., 'FooBar']
370+
371+ def f2(t: Union[Type[FooBar], FooBarFunc]) -> None:
372+ val = functools.partial(t)
373+ [builtins fixtures/tuple.pyi]
374+
358375[case testFunctoolsPartialExplicitType]
359376from functools import partial
360377from typing import Type, TypeVar, Callable
0 commit comments