pandas-dev / pandas-stubs

Public type stubs for pandas
BSD 3-Clause "New" or "Revised" License
236 stars 130 forks source link

@ multiplication of Series is not inferred to a type (but Unknown) #1041

Closed loicdiridollou closed 1 week ago

loicdiridollou commented 1 week ago

Describe the bug When multiplying two series with the @ operator, no type is inferred and the resulting type Unknown will be assigned.

To Reproduce

from typing import reveal_type

import pandas as pd

s1 = pd.Series([0, 1, 2, 3])
s2 = pd.Series([-1, 2, -3, 4])
sc2 = s1 @ s2
reveal_type(sc2) ■ Type of "sc2" is "Unknown"

I believe it should return a Scalar at minimum, in some cases Series but it seems like the type hinting of @ is not in the stubs.

Please complete the following information:

loicdiridollou commented 1 week ago

Issue is actually that __matmul__ method is not typehinted in pandas-stubs/core/series.pyi: https://github.com/pandas-dev/pandas-stubs/blob/779aab6dd43eb7f17ffde0f5f28efbd88804a143/pandas-stubs/core/series.pyi#L801