You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue comes in to play with respect to subtraction. For pandas, we'd like an untyped Series to remain untyped, but subtraction of two Series[Timestamp] to yield Series[Timedelta] . This doesn't seem possible. Right now, the current stubs return Series[Timestamp] when subtracting two untyped series, but do return Series[Timedelta] when subtracting two Series[Timestamp]. Discovered this by using the new assert_type() feature.
In the current stubs from MS copied here, we use Series[bool], Series[Timestamp], Series[Timedelta], Series[float] and Series[int] as arguments and/or return types of different methods, which sharpens up some of the type checks.
Possible solutions:
Give up on using generic Series.
For typing purposes, create BoolSeries, TimestampSeries, TimedeltaSeries, FloatSeries and IntSeries that are typing subclasses of Series that can help with series that have types and those that don't.
Need to experiment with (2), and if it can't work, just remove all the generic stuff.
The text was updated successfully, but these errors were encountered:
pyright
andmypy
have issues in dealing with overloads on generics that are ambiguous, as pointed out bynumpy
. See the following:NDArray[Any]
methods ignore overload ambiguity numpy/numpy#20099self
-annotated methods python/mypy#11347Issue comes in to play with respect to subtraction. For pandas, we'd like an untyped
Series
to remain untyped, but subtraction of twoSeries[Timestamp]
to yieldSeries[Timedelta]
. This doesn't seem possible. Right now, the current stubs returnSeries[Timestamp]
when subtracting two untyped series, but do returnSeries[Timedelta]
when subtracting twoSeries[Timestamp]
. Discovered this by using the newassert_type()
feature.In the current stubs from MS copied here, we use
Series[bool]
,Series[Timestamp]
,Series[Timedelta]
,Series[float]
andSeries[int]
as arguments and/or return types of different methods, which sharpens up some of the type checks.Possible solutions:
BoolSeries
,TimestampSeries
,TimedeltaSeries
,FloatSeries
andIntSeries
that are typing subclasses ofSeries
that can help with series that have types and those that don't.Need to experiment with (2), and if it can't work, just remove all the generic stuff.
The text was updated successfully, but these errors were encountered: