15
15
)
16
16
from pandas ._libs .internals import BlockPlacement
17
17
from pandas ._libs .tslibs import conversion
18
- from pandas ._typing import ArrayLike , DtypeObj , Scalar , Shape
18
+ from pandas ._typing import ArrayLike , Dtype , DtypeObj , Scalar , Shape
19
19
from pandas .util ._validators import validate_bool_kwarg
20
20
21
21
from pandas .core .dtypes .cast import (
@@ -241,7 +241,7 @@ def array_values(self) -> ExtensionArray:
241
241
"""
242
242
return PandasArray (self .values )
243
243
244
- def get_values (self , dtype = None ):
244
+ def get_values (self , dtype : Optional [ Dtype ] = None ):
245
245
"""
246
246
return an internal format, currently just the ndarray
247
247
this is often overridden to handle to_dense like operations
@@ -1669,7 +1669,7 @@ def setitem(self, indexer, value):
1669
1669
self .values [indexer ] = value
1670
1670
return self
1671
1671
1672
- def get_values (self , dtype = None ):
1672
+ def get_values (self , dtype : Optional [ Dtype ] = None ):
1673
1673
# ExtensionArrays must be iterable, so this works.
1674
1674
# TODO(EA2D): reshape not needed with 2D EAs
1675
1675
return np .asarray (self .values ).reshape (self .shape )
@@ -1990,7 +1990,7 @@ class DatetimeLikeBlockMixin(Block):
1990
1990
1991
1991
_can_hold_na = True
1992
1992
1993
- def get_values (self , dtype = None ):
1993
+ def get_values (self , dtype : Optional [ Dtype ] = None ):
1994
1994
"""
1995
1995
return object dtype as boxed values, such as Timestamps/Timedelta
1996
1996
"""
@@ -2168,7 +2168,7 @@ def is_view(self) -> bool:
2168
2168
# check the ndarray values of the DatetimeIndex values
2169
2169
return self .values ._data .base is not None
2170
2170
2171
- def get_values (self , dtype = None ):
2171
+ def get_values (self , dtype : Optional [ Dtype ] = None ):
2172
2172
"""
2173
2173
Returns an ndarray of values.
2174
2174
@@ -2449,7 +2449,7 @@ def replace(
2449
2449
# Constructor Helpers
2450
2450
2451
2451
2452
- def get_block_type (values , dtype = None ):
2452
+ def get_block_type (values , dtype : Optional [ Dtype ] = None ):
2453
2453
"""
2454
2454
Find the appropriate Block subclass to use for the given values and dtype.
2455
2455
@@ -2464,7 +2464,7 @@ def get_block_type(values, dtype=None):
2464
2464
"""
2465
2465
# We use vtype and kind checks because they are much more performant
2466
2466
# than is_foo_dtype
2467
- dtype = dtype or values .dtype
2467
+ dtype = cast ( np . dtype , pandas_dtype ( dtype ) if dtype else values .dtype )
2468
2468
vtype = dtype .type
2469
2469
kind = dtype .kind
2470
2470
@@ -2500,7 +2500,7 @@ def get_block_type(values, dtype=None):
2500
2500
return cls
2501
2501
2502
2502
2503
- def make_block (values , placement , klass = None , ndim = None , dtype = None ):
2503
+ def make_block (values , placement , klass = None , ndim = None , dtype : Optional [ Dtype ] = None ):
2504
2504
# Ensure that we don't allow PandasArray / PandasDtype in internals.
2505
2505
# For now, blocks should be backed by ndarrays when possible.
2506
2506
if isinstance (values , ABCPandasArray ):
0 commit comments