Skip to content

Commit 025a750

Browse files
committed
pyright
1 parent e01258e commit 025a750

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

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