Skip to content

Commit a3ae1be

Browse files
committed
use Dtype in maybe_cast_to_integer_array
1 parent 2faf8c0 commit a3ae1be

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

pandas/core/dtypes/cast.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,8 @@ def maybe_cast_result_dtype(dtype: DtypeObj, how: str) -> DtypeObj:
342342
return dtype
343343

344344

345-
# TODO: annotate obj, return type
346-
# both ArrayLike but not necessarily the same => need a Union (xref GH36100)
347345
def maybe_cast_to_extension_array(
348-
cls: Type["ExtensionArray"], obj, dtype: Optional[ExtensionDtype] = None
346+
cls: Type["ExtensionArray"], obj: ArrayLike, dtype: Optional[ExtensionDtype] = None
349347
) -> ArrayLike:
350348
"""
351349
Call to `_from_sequence` that returns the object unchanged on Exception.
@@ -489,7 +487,7 @@ def maybe_casted_values(
489487

490488
# if we have the codes, extract the values with a mask
491489
if codes is not None:
492-
mask = codes == -1
490+
mask: np.ndarray = codes == -1
493491

494492
# we can have situations where the whole mask is -1,
495493
# meaning there is nothing found in codes, so make all nan's
@@ -1742,7 +1740,7 @@ def construct_1d_ndarray_preserving_na(
17421740
return subarr
17431741

17441742

1745-
def maybe_cast_to_integer_array(arr, dtype: Union[str, np.dtype], copy: bool = False):
1743+
def maybe_cast_to_integer_array(arr, dtype: Dtype, copy: bool = False):
17461744
"""
17471745
Takes any dtype and returns the casted version, raising for when data is
17481746
incompatible with integer/unsigned integer dtypes.

0 commit comments

Comments
 (0)