Skip to content

gh-520: Removed unnecassary types from S1 #522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions pandas-stubs/_libs/interval.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ from pandas import (
Timedelta,
Timestamp,
)
from pandas.core.series import (
TimedeltaSeries,
TimestampSeries,
)

from pandas._typing import (
IntervalClosedType,
Expand Down Expand Up @@ -170,23 +174,25 @@ class Interval(IntervalMixin, Generic[_OrderableT]):
@overload
def __gt__(
self,
other: Series[int] | Series[float] | Series[Timestamp] | Series[Timedelta],
other: Series[int] | Series[float] | TimestampSeries | TimedeltaSeries,
) -> Series[bool]: ...
@overload
def __lt__(self, other: Interval[_OrderableT]) -> bool: ...
@overload
def __lt__(self: IntervalT, other: IntervalIndex[IntervalT]) -> np_ndarray_bool: ...
@overload
def __lt__(
self, other: Series[int] | Series[float] | Series[Timestamp] | Series[Timedelta]
self,
other: Series[int] | Series[float] | TimestampSeries | TimedeltaSeries,
) -> Series[bool]: ...
@overload
def __ge__(self, other: Interval[_OrderableT]) -> bool: ...
@overload
def __ge__(self: IntervalT, other: IntervalIndex[IntervalT]) -> np_ndarray_bool: ...
@overload
def __ge__(
self, other: Series[int] | Series[float] | Series[Timestamp] | Series[Timedelta]
self,
other: Series[int] | Series[float] | TimestampSeries | TimedeltaSeries,
) -> Series[bool]: ...
@overload
def __le__(self, other: Interval[_OrderableT]) -> bool: ...
Expand Down
12 changes: 6 additions & 6 deletions pandas-stubs/_libs/tslibs/period.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -101,41 +101,41 @@ class Period(PeriodMixin):
@overload
def __eq__(self, other: PeriodIndex) -> npt.NDArray[np.bool_]: ... # type: ignore[misc]
@overload
def __eq__(self, other: PeriodSeries | Series[Period]) -> Series[bool]: ... # type: ignore[misc]
def __eq__(self, other: PeriodSeries) -> Series[bool]: ... # type: ignore[misc]
@overload
def __eq__(self, other: object) -> Literal[False]: ...
@overload
def __ge__(self, other: Period) -> bool: ...
@overload
def __ge__(self, other: PeriodIndex) -> npt.NDArray[np.bool_]: ...
@overload
def __ge__(self, other: PeriodSeries | Series[Period]) -> Series[bool]: ...
def __ge__(self, other: PeriodSeries) -> Series[bool]: ...
@overload
def __gt__(self, other: Period) -> bool: ...
@overload
def __gt__(self, other: PeriodIndex) -> npt.NDArray[np.bool_]: ...
@overload
def __gt__(self, other: PeriodSeries | Series[Period]) -> Series[bool]: ...
def __gt__(self, other: PeriodSeries) -> Series[bool]: ...
@overload
def __le__(self, other: Period) -> bool: ...
@overload
def __le__(self, other: PeriodIndex) -> npt.NDArray[np.bool_]: ...
@overload
def __le__(self, other: PeriodSeries | Series[Period]) -> Series[bool]: ...
def __le__(self, other: PeriodSeries) -> Series[bool]: ...
@overload
def __lt__(self, other: Period) -> bool: ...
@overload
def __lt__(self, other: PeriodIndex) -> npt.NDArray[np.bool_]: ...
@overload
def __lt__(self, other: PeriodSeries | Series[Period]) -> Series[bool]: ...
def __lt__(self, other: PeriodSeries) -> Series[bool]: ...
# ignore[misc] here because we know all other comparisons
# are False, so we use Literal[False]
@overload
def __ne__(self, other: Period) -> bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
@overload
def __ne__(self, other: PeriodIndex) -> npt.NDArray[np.bool_]: ... # type: ignore[misc]
@overload
def __ne__(self, other: PeriodSeries | Series[Period]) -> Series[bool]: ... # type: ignore[misc]
def __ne__(self, other: PeriodSeries) -> Series[bool]: ... # type: ignore[misc]
@overload
def __ne__(self, other: object) -> Literal[True]: ...
# Ignored due to indecipherable error from mypy:
Expand Down
17 changes: 6 additions & 11 deletions pandas-stubs/_libs/tslibs/timedeltas.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,11 @@ class Timedelta(timedelta):
def __add__(self, other: pd.TimedeltaIndex) -> pd.TimedeltaIndex: ...
@overload
def __add__(
self, other: TimedeltaSeries | Series[pd.Timedelta]
self,
other: TimedeltaSeries,
) -> TimedeltaSeries: ...
@overload
def __add__(
self, other: Series[Timestamp] | TimestampSeries
) -> TimestampSeries: ...
def __add__(self, other: TimestampSeries) -> TimestampSeries: ...
@overload
def __radd__(self, other: np.datetime64) -> Timestamp: ...
@overload
Expand Down Expand Up @@ -277,9 +276,7 @@ class Timedelta(timedelta):
@overload
def __floordiv__(self, other: Series[float]) -> TimedeltaSeries: ...
@overload
def __floordiv__(
self, other: Series[Timedelta] | TimedeltaSeries
) -> Series[int]: ...
def __floordiv__(self, other: TimedeltaSeries) -> Series[int]: ...
@overload
def __floordiv__(self, other: NaTType | None) -> float: ...
@overload
Expand All @@ -300,9 +297,7 @@ class Timedelta(timedelta):
self, other: npt.NDArray[np.integer] | npt.NDArray[np.floating]
) -> npt.NDArray[np.timedelta64]: ...
@overload
def __truediv__(
self, other: Series[Timedelta] | TimedeltaSeries
) -> Series[float]: ...
def __truediv__(self, other: TimedeltaSeries) -> Series[float]: ...
@overload
def __truediv__(self, other: Series[int]) -> TimedeltaSeries: ...
@overload
Expand Down Expand Up @@ -347,7 +342,7 @@ class Timedelta(timedelta):
) -> npt.NDArray[np.timedelta64]: ...
@overload
def __mod__(
self, other: Series[int] | Series[float] | Series[Timedelta] | TimedeltaSeries
self, other: Series[int] | Series[float] | TimedeltaSeries
) -> TimedeltaSeries: ...
def __divmod__(self, other: timedelta) -> tuple[int, Timedelta]: ...
# Mypy complains Forward operator "<inequality op>" is not callable, so ignore misc
Expand Down
16 changes: 7 additions & 9 deletions pandas-stubs/_libs/tslibs/timestamps.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -159,25 +159,25 @@ class Timestamp(datetime):
@overload
def __le__(self, other: Index | npt.NDArray[np.datetime64]) -> np_ndarray_bool: ...
@overload
def __le__(self, other: TimestampSeries | Series[Timestamp]) -> Series[bool]: ...
def __le__(self, other: TimestampSeries) -> Series[bool]: ...
@overload # type: ignore[override]
def __lt__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[misc]
@overload
def __lt__(self, other: Index | npt.NDArray[np.datetime64]) -> np_ndarray_bool: ...
@overload
def __lt__(self, other: TimestampSeries | Series[Timestamp]) -> Series[bool]: ...
def __lt__(self, other: TimestampSeries) -> Series[bool]: ...
@overload # type: ignore[override]
def __ge__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[misc]
@overload
def __ge__(self, other: Index | npt.NDArray[np.datetime64]) -> np_ndarray_bool: ...
@overload
def __ge__(self, other: TimestampSeries | Series[Timestamp]) -> Series[bool]: ...
def __ge__(self, other: TimestampSeries) -> Series[bool]: ...
@overload # type: ignore[override]
def __gt__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[misc]
@overload
def __gt__(self, other: Index | npt.NDArray[np.datetime64]) -> np_ndarray_bool: ...
@overload
def __gt__(self, other: TimestampSeries | Series[Timestamp]) -> Series[bool]: ...
def __gt__(self, other: TimestampSeries) -> Series[bool]: ...
# error: Signature of "__add__" incompatible with supertype "date"/"datetime"
@overload # type: ignore[override]
def __add__(
Expand All @@ -188,9 +188,7 @@ class Timestamp(datetime):
self: _DatetimeT, other: timedelta | np.timedelta64 | Tick
) -> _DatetimeT: ...
@overload
def __add__(
self, other: TimedeltaSeries | Series[Timedelta]
) -> TimestampSeries: ...
def __add__(self, other: TimedeltaSeries) -> TimestampSeries: ...
@overload
def __add__(self, other: TimedeltaIndex) -> DatetimeIndex: ...
@overload
Expand Down Expand Up @@ -219,15 +217,15 @@ class Timestamp(datetime):
@overload
def __eq__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
@overload
def __eq__(self, other: TimestampSeries | Series[Timestamp]) -> Series[bool]: ... # type: ignore[misc]
def __eq__(self, other: TimestampSeries | Series[np.datetime64]) -> Series[bool]: ... # type: ignore[misc]
@overload
def __eq__(self, other: npt.NDArray[np.datetime64] | Index) -> np_ndarray_bool: ... # type: ignore[misc]
@overload
def __eq__(self, other: object) -> Literal[False]: ...
@overload
def __ne__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
@overload
def __ne__(self, other: TimestampSeries | Series[Timestamp]) -> Series[bool]: ... # type: ignore[misc]
def __ne__(self, other: TimestampSeries | Series[np.datetime64]) -> Series[bool]: ... # type: ignore[misc]
@overload
def __ne__(self, other: npt.NDArray[np.datetime64] | Index) -> np_ndarray_bool: ... # type: ignore[misc]
@overload
Expand Down
2 changes: 0 additions & 2 deletions pandas-stubs/_typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,7 @@ S1 = TypeVar(
str,
bytes,
datetime.date,
datetime.datetime,
datetime.time,
datetime.timedelta,
bool,
int,
float,
Expand Down
2 changes: 0 additions & 2 deletions pandas-stubs/core/indexes/interval.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,12 @@ _EdgesFloat: TypeAlias = Union[
_EdgesTimestamp: TypeAlias = Union[
Sequence[DatetimeLike],
npt.NDArray[np.datetime64],
pd.Series[pd.Timestamp],
TimestampSeries,
pd.DatetimeIndex,
]
_EdgesTimedelta: TypeAlias = Union[
Sequence[pd.Timedelta],
npt.NDArray[np.timedelta64],
pd.Series[pd.Timedelta],
TimedeltaSeries,
pd.TimedeltaIndex,
]
Expand Down
4 changes: 1 addition & 3 deletions tests/test_scalars.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,9 +1256,7 @@ def test_timestamp_cmp() -> None:
c_dt_datetime = dt.datetime(year=2000, month=1, day=1)
c_datetimeindex = pd.DatetimeIndex(["2000-1-1"])
c_np_ndarray_dt64 = np_dt64_arr
# Typing provided since there is no way to get a Series[Timestamp],
# which is a different type from a TimestampSeries
c_series_dt64: pd.Series[pd.Timestamp] = pd.Series(
c_series_dt64: pd.Series[np.datetime64] = pd.Series(
[1, 2, 3], dtype="datetime64[ns]"
)
c_series_timestamp = pd.Series(pd.DatetimeIndex(["2000-1-1"]))
Expand Down