Skip to content

Commit be5272c

Browse files
committed
pyright
1 parent 4d4ab98 commit be5272c

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

@@ -62,16 +61,16 @@ class RangeIndex(_IndexSubclassBase[int, np.int64]):
6261
) -> tuple[np_1darray[np.intp], RangeIndex]: ...
6362
@property
6463
def size(self) -> int: ...
65-
# Base class returns `Self`, but for `RangeIndex` that's not true.
66-
def __floordiv__( # type: ignore[override]
67-
self, other: float | Sequence[float] | Index[int] | Index[float]
68-
) -> Index[int]: ...
6964
def all(self, *args: Any, **kwargs: Any) -> bool: ...
7065
def any(self, *args: Any, **kwargs: Any) -> bool: ...
71-
@final
66+
@overload
67+
def union( # type: ignore[override]
68+
self, other: Sequence[int] | Index[int] | Self, sort: bool | None = None
69+
) -> Index[int] | Self: ...
70+
@overload
7271
def union( # type: ignore[override]
73-
self, other: list[HashableT] | Index, sort: bool | None = None
74-
) -> Index | Index[int] | RangeIndex: ...
72+
self, other: Sequence[HashableT] | Index, sort: bool | None = None
73+
) -> Index: ...
7574
@overload # type: ignore[override]
7675
# pyrefly: ignore # bad-override
7776
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

@@ -268,23 +267,21 @@ def test_range_index_union() -> None:
268267
check(
269268
assert_type(
270269
pd.RangeIndex(0, 10).union(pd.RangeIndex(10, 20)),
271-
Union[pd.Index, "pd.Index[int]", pd.RangeIndex],
270+
"pd.Index[int] | pd.RangeIndex",
272271
),
273272
pd.RangeIndex,
274273
)
275274
check(
276275
assert_type(
277-
pd.RangeIndex(0, 10).union([11, 12, 13]),
278-
Union[pd.Index, "pd.Index[int]", pd.RangeIndex],
276+
pd.RangeIndex(0, 10).union([11, 12, 13]), "pd.Index[int] | pd.RangeIndex"
279277
),
280278
pd.Index,
279+
int,
281280
)
282281
check(
283-
assert_type(
284-
pd.RangeIndex(0, 10).union(["a", "b", "c"]),
285-
Union[pd.Index, "pd.Index[int]", pd.RangeIndex],
286-
),
282+
assert_type(pd.RangeIndex(0, 10).union(["a", "b", "c"]), pd.Index),
287283
pd.Index,
284+
str,
288285
)
289286

290287

0 commit comments

Comments
 (0)