1212
1313from contextlib import contextmanager
1414import operator
15+ from typing import TYPE_CHECKING
1516
1617import numba
1718from numba import types
4041from pandas .core .internals import SingleBlockManager
4142from pandas .core .series import Series
4243
44+ if TYPE_CHECKING :
45+ from pandas ._typing import Self
46+
4347
4448# Helper function to hack around fact that Index casts numpy string dtype to object
4549#
@@ -84,7 +88,7 @@ def key(self):
8488 def as_array (self ):
8589 return types .Array (self .dtype , 1 , self .layout )
8690
87- def copy (self , dtype = None , ndim : int = 1 , layout = None ):
91+ def copy (self , dtype = None , ndim : int = 1 , layout = None ) -> Self :
8892 assert ndim == 1
8993 if dtype is None :
9094 dtype = self .dtype
@@ -114,7 +118,7 @@ def key(self):
114118 def as_array (self ):
115119 return self .values
116120
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 :
118122 assert ndim == 1
119123 assert layout == "C"
120124 if dtype is None :
@@ -123,7 +127,7 @@ def copy(self, dtype=None, ndim: int = 1, layout: str = "C"):
123127
124128
125129@typeof_impl .register (Index )
126- def typeof_index (val , c ):
130+ def typeof_index (val , c ) -> IndexType :
127131 """
128132 This will assume that only strings are in object dtype
129133 index.
@@ -136,7 +140,7 @@ def typeof_index(val, c):
136140
137141
138142@typeof_impl .register (Series )
139- def typeof_series (val , c ):
143+ def typeof_series (val , c ) -> SeriesType :
140144 index = typeof_impl (val .index , c )
141145 arrty = typeof_impl (val .values , c )
142146 namety = typeof_impl (val .name , c )
@@ -532,7 +536,7 @@ def key(self):
532536
533537
534538@typeof_impl .register (_iLocIndexer )
535- def typeof_iloc (val , c ):
539+ def typeof_iloc (val , c ) -> IlocType :
536540 objtype = typeof_impl (val .obj , c )
537541 return IlocType (objtype )
538542
0 commit comments