diff --git a/pandas/core/frame.py b/pandas/core/frame.py index c32483aa2a231..1abbe37e67b09 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -48,6 +48,7 @@ from pandas._libs.lib import no_default from pandas._typing import ( AggFuncType, + AnyArrayLike, ArrayLike, Axes, Axis, @@ -1141,7 +1142,17 @@ def __len__(self) -> int: """ return len(self.index) - def dot(self, other): + # pandas/core/frame.py:1146: error: Overloaded function signatures 1 and 2 + # overlap with incompatible return types [misc] + @overload + def dot(self, other: Series) -> Series: # type: ignore[misc] + ... + + @overload + def dot(self, other: Union[DataFrame, Index, ArrayLike]) -> DataFrame: + ... + + def dot(self, other: Union[AnyArrayLike, FrameOrSeriesUnion]) -> FrameOrSeriesUnion: """ Compute the matrix multiplication between the DataFrame and other. @@ -1251,7 +1262,19 @@ def dot(self, other): else: # pragma: no cover raise TypeError(f"unsupported type: {type(other)}") - def __matmul__(self, other): + @overload + def __matmul__(self, other: Series) -> Series: + ... + + @overload + def __matmul__( + self, other: Union[AnyArrayLike, FrameOrSeriesUnion] + ) -> FrameOrSeriesUnion: + ... + + def __matmul__( + self, other: Union[AnyArrayLike, FrameOrSeriesUnion] + ) -> FrameOrSeriesUnion: """ Matrix multiplication using binary `@` operator in Python>=3.5. """