Skip to content

Commit af9d5b5

Browse files
committed
type rangeindex
1 parent 750befd commit af9d5b5

File tree

2 files changed

+31
-26
lines changed

2 files changed

+31
-26
lines changed

pandas-stubs/core/indexes/range.pyi

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ from pandas.core.indexes.base import (
1616
from typing_extensions import Self
1717

1818
from pandas._typing import (
19+
Dtype,
1920
HashableT,
2021
MaskType,
2122
np_1darray,
@@ -25,16 +26,17 @@ from pandas._typing import (
2526
class RangeIndex(_IndexSubclassBase[int, np.int64]):
2627
def __new__(
2728
cls,
28-
start: int | RangeIndex | range = ...,
29-
stop: int = ...,
30-
step: int = ...,
31-
dtype=...,
32-
copy: bool = ...,
33-
name: Hashable = ...,
29+
start: int | RangeIndex | range | None = None,
30+
stop: int | None = None,
31+
step: int | None = None,
32+
dtype: Dtype | None = None,
33+
copy: bool = False,
34+
name: Hashable | None = None,
3435
): ...
3536
@classmethod
36-
def from_range(cls, data, name: Hashable = ..., dtype=...) -> Self: ...
37-
def __reduce__(self): ...
37+
def from_range(
38+
cls, data: range, name: Hashable | None = None, dtype: Dtype | None = None
39+
) -> Self: ...
3840
@property
3941
def start(self) -> int: ...
4042
@property
@@ -55,29 +57,14 @@ class RangeIndex(_IndexSubclassBase[int, np.int64]):
5557
@property
5658
def has_duplicates(self) -> bool: ...
5759
def __contains__(self, key: int | np.integer) -> bool: ...
58-
@final
59-
def get_indexer(self, target, method=..., limit=..., tolerance=...): ...
60-
def tolist(self): ...
61-
def min(self, axis=..., skipna: bool = ..., *args: Any, **kwargs: Any): ...
62-
def max(self, axis=..., skipna: bool = ..., *args: Any, **kwargs: Any): ...
63-
def argsort(self, *args: Any, **kwargs: Any): ...
6460
def factorize(
6561
self, sort: bool = False, use_na_sentinel: bool = True
6662
) -> tuple[np_1darray[np.intp], RangeIndex]: ...
67-
def equals(self, other): ...
68-
@final
69-
def join(
70-
self,
71-
other,
72-
*,
73-
how: str = ...,
74-
level=...,
75-
return_indexers: bool = ...,
76-
sort: bool = ...,
77-
): ...
7863
@property
7964
def size(self) -> int: ...
80-
def __floordiv__(self, other): ...
65+
def __floordiv__(
66+
self, other: float | Sequence[float] | Index[int] | Index[float]
67+
) -> Index[int]: ...
8168
def all(self, *args: Any, **kwargs: Any) -> bool: ...
8269
def any(self, *args: Any, **kwargs: Any) -> bool: ...
8370
@final

tests/indexes/test_rangeindex.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from __future__ import annotations
2+
3+
import pandas as pd
4+
from typing_extensions import (
5+
assert_type,
6+
)
7+
8+
from tests import (
9+
check,
10+
)
11+
12+
13+
def test_rangeindex_floordiv() -> None:
14+
ri = pd.RangeIndex(3)
15+
check(
16+
assert_type(ri // 2, "pd.Index[int]"),
17+
pd.Index,
18+
)

0 commit comments

Comments
 (0)