Skip to content

Commit cae28f2

Browse files
authored
TYP: Remove custom ellipsis class (#62737)
1 parent e211883 commit cae28f2

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

pandas/core/arrays/sparse/array.py

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,17 @@
8585

8686
from pandas.io.formats import printing
8787

88-
# See https://github.com/python/typing/issues/684
8988
if TYPE_CHECKING:
9089
from collections.abc import (
9190
Callable,
9291
Sequence,
9392
)
94-
from enum import Enum
93+
from types import EllipsisType
9594
from typing import (
9695
Protocol,
9796
type_check_only,
9897
)
9998

100-
class ellipsis(Enum):
101-
Ellipsis = "..."
102-
103-
Ellipsis = ellipsis.Ellipsis
104-
10599
from scipy.sparse import (
106100
csc_array,
107101
csc_matrix,
@@ -134,10 +128,6 @@ def tocsc(self, /) -> csc_array | csc_matrix: ...
134128
from pandas import Series
135129

136130

137-
else:
138-
ellipsis = type(Ellipsis)
139-
140-
141131
# ----------------------------------------------------------------------------
142132
# Array
143133

@@ -974,31 +964,22 @@ def __getitem__(self, key: ScalarIndexer) -> Any: ...
974964
@overload
975965
def __getitem__(
976966
self,
977-
key: SequenceIndexer | tuple[int | ellipsis, ...],
967+
key: SequenceIndexer | tuple[int | EllipsisType, ...],
978968
) -> Self: ...
979969

980970
def __getitem__(
981971
self,
982-
key: PositionalIndexer | tuple[int | ellipsis, ...],
972+
key: PositionalIndexer | tuple[int | EllipsisType, ...],
983973
) -> Self | Any:
984974
if isinstance(key, tuple):
985975
key = unpack_tuple_and_ellipses(key)
986-
if key is Ellipsis:
976+
if key is ...:
987977
raise ValueError("Cannot slice with Ellipsis")
988978

989979
if is_integer(key):
990980
return self._get_val_at(key)
991981
elif isinstance(key, tuple):
992-
# error: Invalid index type "Tuple[Union[int, ellipsis], ...]"
993-
# for "ndarray[Any, Any]"; expected type
994-
# "Union[SupportsIndex, _SupportsArray[dtype[Union[bool_,
995-
# integer[Any]]]], _NestedSequence[_SupportsArray[dtype[
996-
# Union[bool_, integer[Any]]]]], _NestedSequence[Union[
997-
# bool, int]], Tuple[Union[SupportsIndex, _SupportsArray[
998-
# dtype[Union[bool_, integer[Any]]]], _NestedSequence[
999-
# _SupportsArray[dtype[Union[bool_, integer[Any]]]]],
1000-
# _NestedSequence[Union[bool, int]]], ...]]"
1001-
data_slice = self.to_dense()[key] # type: ignore[index]
982+
data_slice = self.to_dense()[key]
1002983
elif isinstance(key, slice):
1003984
# Avoid densifying when handling contiguous slices
1004985
if key.step is None or key.step == 1:

0 commit comments

Comments
 (0)