Skip to content
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
4 changes: 2 additions & 2 deletions pandas-stubs/_libs/tslibs/period.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Period(PeriodMixin):
@overload
def __eq__(self, other: Period) -> bool: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
@overload
def __eq__(self, other: PeriodIndex) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
def __eq__(self, other: Index) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
@overload
def __eq__(self, other: PeriodSeries) -> Series[bool]: ... # type: ignore[overload-overlap]
@overload
Expand Down Expand Up @@ -154,7 +154,7 @@ class Period(PeriodMixin):
@overload
def __ne__(self, other: Period) -> bool: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
@overload
def __ne__(self, other: PeriodIndex) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
def __ne__(self, other: Index) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
@overload
def __ne__(self, other: PeriodSeries) -> Series[bool]: ... # type: ignore[overload-overlap]
@overload
Expand Down
4 changes: 2 additions & 2 deletions pandas-stubs/_libs/tslibs/timedeltas.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class Timedelta(timedelta):
@overload
def __eq__(self, other: TimedeltaSeries | Series[pd.Timedelta]) -> Series[bool]: ... # type: ignore[overload-overlap]
@overload
def __eq__(self, other: TimedeltaIndex) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
def __eq__(self, other: Index) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
@overload
def __eq__( # type: ignore[overload-overlap]
self, other: np_ndarray[ShapeT, np.timedelta64]
Expand All @@ -324,7 +324,7 @@ class Timedelta(timedelta):
@overload
def __ne__(self, other: TimedeltaSeries | Series[pd.Timedelta]) -> Series[bool]: ... # type: ignore[overload-overlap]
@overload
def __ne__(self, other: TimedeltaIndex) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
def __ne__(self, other: Index) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
@overload
def __ne__( # type: ignore[overload-overlap]
self, other: np_ndarray[ShapeT, np.timedelta64]
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/_libs/tslibs/timestamps.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ from typing import (
import numpy as np
from pandas import (
DatetimeIndex,
Index,
TimedeltaIndex,
)
from pandas.core.indexes.base import Index
from pandas.core.series import (
Series,
TimedeltaSeries,
Expand Down
9 changes: 2 additions & 7 deletions pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ from pandas.core.arraylike import OpsMixin
from pandas.core.generic import NDFrame
from pandas.core.groupby.generic import DataFrameGroupBy
from pandas.core.indexers import BaseIndexer
from pandas.core.indexes.base import (
Index,
UnknownIndex,
)
from pandas.core.indexes.base import Index
from pandas.core.indexes.category import CategoricalIndex
from pandas.core.indexes.datetimes import DatetimeIndex
from pandas.core.indexes.interval import IntervalIndex
Expand Down Expand Up @@ -1761,9 +1758,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
@property
def iloc(self) -> _iLocIndexerFrame[Self]: ...
@property
# mypy complains if we use Index[Any] instead of UnknownIndex here, even though
# the latter is aliased to the former ¯\_(ツ)_/¯.
def index(self) -> UnknownIndex: ...
def index(self) -> Index: ...
@index.setter
def index(self, idx: Index) -> None: ...
@property
Expand Down
3 changes: 0 additions & 3 deletions pandas-stubs/core/indexes/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ from typing import (
ClassVar,
Generic,
Literal,
TypeAlias,
final,
overload,
type_check_only,
Expand Down Expand Up @@ -508,8 +507,6 @@ class Index(IndexOpsMixin[S1]):
) -> Self: ...
def infer_objects(self, copy: bool = True) -> Self: ...

UnknownIndex: TypeAlias = Index[Any]

@type_check_only
class _IndexSubclassBase(Index[S1], Generic[S1, GenericT_co]):
@overload
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
self, repeats: int | list[int], axis: AxisIndex | None = 0
) -> Series[S1]: ...
@property
def index(self) -> Index | MultiIndex: ...
def index(self) -> Index: ...
@index.setter
def index(self, idx: Index) -> None: ...
@overload
Expand Down
7 changes: 4 additions & 3 deletions tests/test_scalars.py
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ def test_timestamp_cmp_series() -> None:
def test_timestamp_cmp_index() -> None:
ts = pd.Timestamp(year=2000, month=3, day=24, hour=12, minute=27)
dt_idx = pd.DatetimeIndex(["2000-1-1"])
# DatetimeIndex, but the type checker thinks it is UnknownIndex.
# DatetimeIndex, but the type checker thinks it is Index[Any].
un_idx = pd.DataFrame({"a": [1]}, index=dt_idx).index

# >, <=
Expand Down Expand Up @@ -1322,8 +1322,9 @@ def test_timestamp_cmp_index() -> None:
eq_dt1 = check(assert_type(ts == dt_idx, np_1darray[np.bool]), np_1darray[np.bool])
ne_dt1 = check(assert_type(ts != dt_idx, np_1darray[np.bool]), np_1darray[np.bool])
assert (eq_dt1 != ne_dt1).all()
eq_un1 = check(assert_type(ts == un_idx, np_1darray[np.bool]), np_1darray[np.bool])
ne_un1 = check(assert_type(ts != un_idx, np_1darray[np.bool]), np_1darray[np.bool])
# there is a mypy bug where ts.__eq__(Index) gets revealed as Any and not np_1darray
eq_un1 = check(assert_type(ts == un_idx, np_1darray[np.bool]), np_1darray[np.bool]) # type: ignore[assert-type]
ne_un1 = check(assert_type(ts != un_idx, np_1darray[np.bool]), np_1darray[np.bool]) # type: ignore[assert-type]
assert (eq_un1 != ne_un1).all()

# ==, != (ts on the rhs, use == and != of lhs)
Expand Down
Loading