Skip to content

Commit 4554352

Browse files
committed
Reformat code style
1 parent 05470fc commit 4554352

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pandas/core/arrays/arrow/array.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,15 @@ def __init__(self, values: pa.Array | pa.ChunkedArray) -> None:
316316

317317
@classmethod
318318
def _from_scalars(cls, scalars, dtype: DtypeObj) -> Self:
319+
inferred_dtype = lib.infer_dtype(scalars, skipna=True)
319320
try:
320321
pa_array = cls._from_sequence(scalars, dtype=dtype)
321-
except pa.ArrowNotImplementedError:
322+
except pa.ArrowNotImplementedError as err:
322323
# _from_scalars should only raise ValueError or TypeError.
323-
raise ValueError
324+
raise ValueError from err
324325

325-
if lib.infer_dtype(scalars, skipna=True) != lib.infer_dtype(pa_array, skipna=True):
326+
same_dtype = lib.infer_dtype(pa_array, skipna=True) == inferred_dtype
327+
if not same_dtype:
326328
raise ValueError
327329
return pa_array
328330

0 commit comments

Comments
 (0)