1
1
from __future__ import annotations
2
2
3
3
from builtins import type as type_t
4
+ from collections .abc import Callable
4
5
import decimal
5
6
import numbers
6
7
import sys
23
24
)
24
25
from pandas .core .indexers import check_array_indexer
25
26
26
- from pandas ._typing import TakeIndexer
27
+ from pandas ._typing import (
28
+ TakeIndexer ,
29
+ np_1darray ,
30
+ )
27
31
28
32
from pandas .core .dtypes .base import ExtensionDtype
29
33
from pandas .core .dtypes .common import (
@@ -149,7 +153,7 @@ def __array_ufunc__(
149
153
if result is not NotImplemented :
150
154
return result
151
155
152
- def reconstruct (x ):
156
+ def reconstruct (x ) -> decimal . Decimal | numbers . Number | DecimalArray :
153
157
if isinstance (x , (decimal .Decimal , numbers .Number )):
154
158
return x
155
159
return DecimalArray ._from_sequence (x )
@@ -222,10 +226,10 @@ def isna(self):
222
226
return np .array ([x .is_nan () for x in self ._data ], dtype = bool )
223
227
224
228
@property
225
- def _na_value (self ):
229
+ def _na_value (self ) -> decimal . Decimal :
226
230
return decimal .Decimal ("NaN" )
227
231
228
- def _formatter (self , boxed = False ):
232
+ def _formatter (self , boxed = False ) -> Callable [..., str ] :
229
233
if boxed :
230
234
return "Decimal: {}" .format
231
235
return repr
@@ -234,7 +238,7 @@ def _formatter(self, boxed=False):
234
238
def _concat_same_type (cls , to_concat ):
235
239
return cls (np .concatenate ([x ._data for x in to_concat ]))
236
240
237
- def _reduce (self , name : str , * , skipna : bool = True , ** kwargs : Any ):
241
+ def _reduce (self , name : str , * , skipna : bool = True , ** kwargs : Any ) -> Any :
238
242
if skipna :
239
243
# If we don't have any NAs, we can ignore skipna
240
244
if self .isna ().any ():
@@ -253,9 +257,9 @@ def _reduce(self, name: str, *, skipna: bool = True, **kwargs: Any):
253
257
) from err
254
258
return op (axis = 0 )
255
259
256
- def _cmp_method (self , other , op ):
260
+ def _cmp_method (self , other , op ) -> np_1darray [ np . bool_ ] :
257
261
# For use with OpsMixin
258
- def convert_values (param ):
262
+ def convert_values (param ) -> ExtensionArray | list [ Any ] :
259
263
if isinstance (param , ExtensionArray ) or is_list_like (param ):
260
264
ovalues = param
261
265
else :
0 commit comments