Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 2 additions & 3 deletions pandas-stubs/_libs/tslibs/timestamps.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ from typing import (
import numpy as np
from pandas import (
DatetimeIndex,
Index,
TimedeltaIndex,
)
from pandas.core.series import (
Expand Down Expand Up @@ -257,7 +256,7 @@ class Timestamp(datetime, SupportsIndex):
@overload
def __eq__(self, other: TimestampSeries) -> Series[bool]: ... # type: ignore[overload-overlap]
@overload
def __eq__(self, other: Index) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
def __eq__(self, other: DatetimeIndex) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
@overload
def __eq__(self, other: np_ndarray[ShapeT, np.datetime64]) -> np_ndarray[ShapeT, np.bool]: ... # type: ignore[overload-overlap]
@overload
Expand All @@ -267,7 +266,7 @@ class Timestamp(datetime, SupportsIndex):
@overload
def __ne__(self, other: TimestampSeries) -> Series[bool]: ... # type: ignore[overload-overlap]
@overload
def __ne__(self, other: Index) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
def __ne__(self, other: DatetimeIndex) -> np_1darray[np.bool]: ... # type: ignore[overload-overlap]
@overload
def __ne__(self, other: np_ndarray[ShapeT, np.datetime64]) -> np_ndarray[ShapeT, np.bool]: ... # type: ignore[overload-overlap]
@overload
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
5 changes: 1 addition & 4 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,9 +1322,6 @@ 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])
assert (eq_un1 != ne_un1).all()

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