@@ -6997,3 +6997,35 @@ def f(x: Incomplete) -> Incomplete: # no error
69976997
69986998a: Incomplete = 1 # no error
69996999[builtins fixtures/tuple.pyi]
7000+
7001+ [case testOverloadNestedAliasAnyDoesNotTriggerAmbiguity]
7002+ # Explicit Any nested inside a larger type alias should not trigger the
7003+ # overload-ambiguity fallback. This matches numpy/pandas-style aliases such as
7004+ # `ndarray[tuple[Any, ...], dtype[T]]`.
7005+ from typing import Any, Generic, TypeVar, overload
7006+ from typing_extensions import Never, TypeAlias
7007+
7008+ S = TypeVar("S")
7009+ Sh = TypeVar("Sh")
7010+
7011+ class Array(Generic[Sh, S]): pass
7012+
7013+ Shape: TypeAlias = tuple[Any, ...]
7014+ BoolArray: TypeAlias = Array[Shape, bool]
7015+
7016+ class Series(Generic[S]):
7017+ @overload
7018+ def __add__(self: Series[Never], other: object) -> Series[Any]: ... # type: ignore[overload-overlap]
7019+ @overload
7020+ def __add__(self: Series[S], other: Array[Any, S]) -> Series[S]: ...
7021+ @overload
7022+ def __add__(self: Series[S], other: Array[Any, bool]) -> Series[S]: ...
7023+ @overload
7024+ def __add__(self: Series[bool], other: Array[Any, bool]) -> Series[bool]: ...
7025+ @overload
7026+ def __add__(self: Series[str], other: Array[Any, bool]) -> Never: ...
7027+ def __add__(self, other): ...
7028+
7029+ def f(x: Series[Any], y: BoolArray) -> None:
7030+ reveal_type(x + y) # N: Revealed type is "__main__.Series[Any]"
7031+ [builtins fixtures/tuple.pyi]
0 commit comments