@@ -123,9 +123,8 @@ def maybe_convert_platform(
123
123
arr = values
124
124
125
125
if arr .dtype == object :
126
- # error: Argument 1 to "maybe_convert_objects" has incompatible type
127
- # "Union[ExtensionArray, ndarray]"; expected "ndarray"
128
- arr = lib .maybe_convert_objects (arr ) # type: ignore[arg-type]
126
+ arr = cast (np .ndarray , arr )
127
+ arr = lib .maybe_convert_objects (arr )
129
128
130
129
return arr
131
130
@@ -1249,13 +1248,12 @@ def astype_array(values: ArrayLike, dtype: DtypeObj, copy: bool = False) -> Arra
1249
1248
return values .copy ()
1250
1249
return values
1251
1250
1252
- if isinstance (values , ABCExtensionArray ):
1251
+ if not isinstance (values , np .ndarray ):
1252
+ # i.e. ExtensionArray
1253
1253
values = values .astype (dtype , copy = copy )
1254
1254
1255
1255
else :
1256
- # error: Argument 1 to "astype_nansafe" has incompatible type "ExtensionArray";
1257
- # expected "ndarray"
1258
- values = astype_nansafe (values , dtype , copy = copy ) # type: ignore[arg-type]
1256
+ values = astype_nansafe (values , dtype , copy = copy )
1259
1257
1260
1258
# in pandas we don't store numpy str dtypes, so convert to object
1261
1259
if isinstance (dtype , np .dtype ) and issubclass (values .dtype .type , str ):
@@ -1975,7 +1973,7 @@ def construct_1d_object_array_from_listlike(values: Sized) -> np.ndarray:
1975
1973
1976
1974
1977
1975
def construct_1d_ndarray_preserving_na (
1978
- values : Sequence , dtype : DtypeObj | None = None , copy : bool = False
1976
+ values : Sequence , dtype : np . dtype | None = None , copy : bool = False
1979
1977
) -> np .ndarray :
1980
1978
"""
1981
1979
Construct a new ndarray, coercing `values` to `dtype`, preserving NA.
@@ -2020,17 +2018,9 @@ def construct_1d_ndarray_preserving_na(
2020
2018
and isinstance (values , np .ndarray )
2021
2019
and values .dtype .kind == "f"
2022
2020
):
2023
- # Argument 2 to "astype_float_to_int_nansafe" has incompatible
2024
- # type "Union[dtype[Any], ExtensionDtype]"; expected "dtype[Any]"
2025
- return astype_float_to_int_nansafe (
2026
- values , dtype , copy = copy # type: ignore[arg-type]
2027
- )
2021
+ return astype_float_to_int_nansafe (values , dtype , copy = copy )
2028
2022
else :
2029
- # error: Argument "dtype" to "array" has incompatible type
2030
- # "Union[dtype[Any], ExtensionDtype, None]"; expected "Union[dtype[Any],
2031
- # None, type, _SupportsDType, str, Union[Tuple[Any, int], Tuple[Any,
2032
- # Union[int, Sequence[int]]], List[Any], _DTypeDict, Tuple[Any, Any]]]"
2033
- subarr = np .array (values , dtype = dtype , copy = copy ) # type: ignore[arg-type]
2023
+ subarr = np .array (values , dtype = dtype , copy = copy )
2034
2024
2035
2025
return subarr
2036
2026
0 commit comments