Skip to content

Resolve issues with ambiguity in typed Series #5

Closed
@Dr-Irv

Description

@Dr-Irv

pyright and mypy have issues in dealing with overloads on generics that are ambiguous, as pointed out by numpy. See the following:

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:

  1. Give up on using generic Series.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions