Skip to content

Commit 26fa853

Browse files
authored
TYP: DataFrame.(dot, __matmul__) (#38765)
1 parent 13328ec commit 26fa853

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

pandas/core/frame.py

+25-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
from pandas._libs.lib import no_default
4949
from pandas._typing import (
5050
AggFuncType,
51+
AnyArrayLike,
5152
ArrayLike,
5253
Axes,
5354
Axis,
@@ -1141,7 +1142,17 @@ def __len__(self) -> int:
11411142
"""
11421143
return len(self.index)
11431144

1144-
def dot(self, other):
1145+
# pandas/core/frame.py:1146: error: Overloaded function signatures 1 and 2
1146+
# overlap with incompatible return types [misc]
1147+
@overload
1148+
def dot(self, other: Series) -> Series: # type: ignore[misc]
1149+
...
1150+
1151+
@overload
1152+
def dot(self, other: Union[DataFrame, Index, ArrayLike]) -> DataFrame:
1153+
...
1154+
1155+
def dot(self, other: Union[AnyArrayLike, FrameOrSeriesUnion]) -> FrameOrSeriesUnion:
11451156
"""
11461157
Compute the matrix multiplication between the DataFrame and other.
11471158
@@ -1251,7 +1262,19 @@ def dot(self, other):
12511262
else: # pragma: no cover
12521263
raise TypeError(f"unsupported type: {type(other)}")
12531264

1254-
def __matmul__(self, other):
1265+
@overload
1266+
def __matmul__(self, other: Series) -> Series:
1267+
...
1268+
1269+
@overload
1270+
def __matmul__(
1271+
self, other: Union[AnyArrayLike, FrameOrSeriesUnion]
1272+
) -> FrameOrSeriesUnion:
1273+
...
1274+
1275+
def __matmul__(
1276+
self, other: Union[AnyArrayLike, FrameOrSeriesUnion]
1277+
) -> FrameOrSeriesUnion:
12551278
"""
12561279
Matrix multiplication using binary `@` operator in Python>=3.5.
12571280
"""

0 commit comments

Comments
 (0)