|
85 | 85 |
|
86 | 86 | from pandas.io.formats import printing |
87 | 87 |
|
88 | | -# See https://github.com/python/typing/issues/684 |
89 | 88 | if TYPE_CHECKING: |
90 | 89 | from collections.abc import ( |
91 | 90 | Callable, |
92 | 91 | Sequence, |
93 | 92 | ) |
94 | | - from enum import Enum |
| 93 | + from types import EllipsisType |
95 | 94 | from typing import ( |
96 | 95 | Protocol, |
97 | 96 | type_check_only, |
98 | 97 | ) |
99 | 98 |
|
100 | | - class ellipsis(Enum): |
101 | | - Ellipsis = "..." |
102 | | - |
103 | | - Ellipsis = ellipsis.Ellipsis |
104 | | - |
105 | 99 | from scipy.sparse import ( |
106 | 100 | csc_array, |
107 | 101 | csc_matrix, |
@@ -134,10 +128,6 @@ def tocsc(self, /) -> csc_array | csc_matrix: ... |
134 | 128 | from pandas import Series |
135 | 129 |
|
136 | 130 |
|
137 | | -else: |
138 | | - ellipsis = type(Ellipsis) |
139 | | - |
140 | | - |
141 | 131 | # ---------------------------------------------------------------------------- |
142 | 132 | # Array |
143 | 133 |
|
@@ -974,31 +964,22 @@ def __getitem__(self, key: ScalarIndexer) -> Any: ... |
974 | 964 | @overload |
975 | 965 | def __getitem__( |
976 | 966 | self, |
977 | | - key: SequenceIndexer | tuple[int | ellipsis, ...], |
| 967 | + key: SequenceIndexer | tuple[int | EllipsisType, ...], |
978 | 968 | ) -> Self: ... |
979 | 969 |
|
980 | 970 | def __getitem__( |
981 | 971 | self, |
982 | | - key: PositionalIndexer | tuple[int | ellipsis, ...], |
| 972 | + key: PositionalIndexer | tuple[int | EllipsisType, ...], |
983 | 973 | ) -> Self | Any: |
984 | 974 | if isinstance(key, tuple): |
985 | 975 | key = unpack_tuple_and_ellipses(key) |
986 | | - if key is Ellipsis: |
| 976 | + if key is ...: |
987 | 977 | raise ValueError("Cannot slice with Ellipsis") |
988 | 978 |
|
989 | 979 | if is_integer(key): |
990 | 980 | return self._get_val_at(key) |
991 | 981 | 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] |
1002 | 983 | elif isinstance(key, slice): |
1003 | 984 | # Avoid densifying when handling contiguous slices |
1004 | 985 | if key.step is None or key.step == 1: |
|
0 commit comments