@@ -139,10 +139,9 @@ def _safe_cast(cls, values: np.ndarray, dtype: np.dtype, copy: bool) -> np.ndarr
139139 raise AbstractMethodError (cls )
140140
141141
142- def _coerce_to_data_and_mask (
143- values , dtype , copy : bool , dtype_cls : type [NumericDtype ], default_dtype : np .dtype
144- ):
142+ def _coerce_to_data_and_mask (values , dtype , copy : bool , dtype_cls : type [NumericDtype ]):
145143 checker = dtype_cls ._checker
144+ default_dtype = dtype_cls ._default_np_dtype
146145
147146 mask = None
148147 inferred_type = None
@@ -163,7 +162,7 @@ def _coerce_to_data_and_mask(
163162 if copy :
164163 values = values .copy ()
165164 mask = mask .copy ()
166- return values , mask , dtype , inferred_type
165+ return values , mask
167166
168167 original = values
169168 if not copy :
@@ -174,6 +173,7 @@ def _coerce_to_data_and_mask(
174173 if values .dtype == object or is_string_dtype (values .dtype ):
175174 inferred_type = lib .infer_dtype (values , skipna = True )
176175 if inferred_type == "boolean" and dtype is None :
176+ # object dtype array of bools
177177 name = dtype_cls .__name__ .strip ("_" )
178178 raise TypeError (f"{ values .dtype } cannot be converted to { name } " )
179179
@@ -252,7 +252,7 @@ def _coerce_to_data_and_mask(
252252 values = values .astype (dtype , copy = copy )
253253 else :
254254 values = dtype_cls ._safe_cast (values , dtype , copy = False )
255- return values , mask , dtype , inferred_type
255+ return values , mask
256256
257257
258258class NumericArray (BaseMaskedArray ):
@@ -296,10 +296,7 @@ def _coerce_to_array(
296296 cls , value , * , dtype : DtypeObj , copy : bool = False
297297 ) -> tuple [np .ndarray , np .ndarray ]:
298298 dtype_cls = cls ._dtype_cls
299- default_dtype = dtype_cls ._default_np_dtype
300- values , mask , _ , _ = _coerce_to_data_and_mask (
301- value , dtype , copy , dtype_cls , default_dtype
302- )
299+ values , mask = _coerce_to_data_and_mask (value , dtype , copy , dtype_cls )
303300 return values , mask
304301
305302 @classmethod
0 commit comments