Skip to content

Commit ab164e2

Browse files
committed
pyright
1 parent d1968aa commit ab164e2

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

pandas-stubs/core/indexes/range.pyi

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ from collections.abc import (
44
)
55
from typing import (
66
Any,
7-
final,
87
overload,
98
)
109

@@ -66,16 +65,16 @@ class RangeIndex(_IndexSubclassBase[int, np.int64]):
6665
) -> tuple[np_1darray[np.intp], RangeIndex]: ...
6766
@property
6867
def size(self) -> int: ...
69-
# Base class returns `Self`, but for `RangeIndex` that's not true.
70-
def __floordiv__( # type: ignore[override]
71-
self, other: float | Sequence[float] | Index[int] | Index[float]
72-
) -> Index[int]: ...
7368
def all(self, *args: Any, **kwargs: Any) -> bool: ...
7469
def any(self, *args: Any, **kwargs: Any) -> bool: ...
75-
@final
70+
@overload
71+
def union( # type: ignore[override]
72+
self, other: Sequence[int] | Index[int] | Self, sort: bool | None = None
73+
) -> Index[int] | Self: ...
74+
@overload
7675
def union( # type: ignore[override]
77-
self, other: list[HashableT] | Index, sort: bool | None = None
78-
) -> Index | Index[int] | RangeIndex: ...
76+
self, other: Sequence[HashableT] | Index, sort: bool | None = None
77+
) -> Index: ...
7978
@overload # type: ignore[override]
8079
# pyrefly: ignore # bad-override
8180
def __getitem__(

tests/indexes/test_indexes.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from typing import (
66
TYPE_CHECKING,
77
Any,
8-
Union,
98
cast,
109
)
1110

@@ -269,23 +268,21 @@ def test_range_index_union() -> None:
269268
check(
270269
assert_type(
271270
pd.RangeIndex(0, 10).union(pd.RangeIndex(10, 20)),
272-
Union[pd.Index, "pd.Index[int]", pd.RangeIndex],
271+
"pd.Index[int] | pd.RangeIndex",
273272
),
274273
pd.RangeIndex,
275274
)
276275
check(
277276
assert_type(
278-
pd.RangeIndex(0, 10).union([11, 12, 13]),
279-
Union[pd.Index, "pd.Index[int]", pd.RangeIndex],
277+
pd.RangeIndex(0, 10).union([11, 12, 13]), "pd.Index[int] | pd.RangeIndex"
280278
),
281279
pd.Index,
280+
int,
282281
)
283282
check(
284-
assert_type(
285-
pd.RangeIndex(0, 10).union(["a", "b", "c"]),
286-
Union[pd.Index, "pd.Index[int]", pd.RangeIndex],
287-
),
283+
assert_type(pd.RangeIndex(0, 10).union(["a", "b", "c"]), pd.Index),
288284
pd.Index,
285+
str,
289286
)
290287

291288

0 commit comments

Comments
 (0)