12
12
13
13
from contextlib import contextmanager
14
14
import operator
15
+ from typing import TYPE_CHECKING
15
16
16
17
import numba
17
18
from numba import types
40
41
from pandas .core .internals import SingleBlockManager
41
42
from pandas .core .series import Series
42
43
44
+ if TYPE_CHECKING :
45
+ from pandas ._typing import Self
46
+
43
47
44
48
# Helper function to hack around fact that Index casts numpy string dtype to object
45
49
#
@@ -84,7 +88,7 @@ def key(self):
84
88
def as_array (self ):
85
89
return types .Array (self .dtype , 1 , self .layout )
86
90
87
- def copy (self , dtype = None , ndim : int = 1 , layout = None ):
91
+ def copy (self , dtype = None , ndim : int = 1 , layout = None ) -> Self :
88
92
assert ndim == 1
89
93
if dtype is None :
90
94
dtype = self .dtype
@@ -114,7 +118,7 @@ def key(self):
114
118
def as_array (self ):
115
119
return self .values
116
120
117
- def copy (self , dtype = None , ndim : int = 1 , layout : str = "C" ):
121
+ def copy (self , dtype = None , ndim : int = 1 , layout : str = "C" ) -> Self :
118
122
assert ndim == 1
119
123
assert layout == "C"
120
124
if dtype is None :
@@ -123,7 +127,7 @@ def copy(self, dtype=None, ndim: int = 1, layout: str = "C"):
123
127
124
128
125
129
@typeof_impl .register (Index )
126
- def typeof_index (val , c ):
130
+ def typeof_index (val , c ) -> IndexType :
127
131
"""
128
132
This will assume that only strings are in object dtype
129
133
index.
@@ -136,7 +140,7 @@ def typeof_index(val, c):
136
140
137
141
138
142
@typeof_impl .register (Series )
139
- def typeof_series (val , c ):
143
+ def typeof_series (val , c ) -> SeriesType :
140
144
index = typeof_impl (val .index , c )
141
145
arrty = typeof_impl (val .values , c )
142
146
namety = typeof_impl (val .name , c )
@@ -532,7 +536,7 @@ def key(self):
532
536
533
537
534
538
@typeof_impl .register (_iLocIndexer )
535
- def typeof_iloc (val , c ):
539
+ def typeof_iloc (val , c ) -> IlocType :
536
540
objtype = typeof_impl (val .obj , c )
537
541
return IlocType (objtype )
538
542
0 commit comments