Skip to content

Commit 3c9cf09

Browse files
committed
Reformat code style
1 parent 2ae56c2 commit 3c9cf09

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
@@ -311,13 +311,15 @@ def __init__(self, values: pa.Array | pa.ChunkedArray) -> None:
311311

312312
@classmethod
313313
def _from_scalars(cls, scalars, dtype: DtypeObj) -> Self:
314+
inferred_dtype = lib.infer_dtype(scalars, skipna=True)
314315
try:
315316
pa_array = cls._from_sequence(scalars, dtype=dtype)
316-
except pa.ArrowNotImplementedError:
317+
except pa.ArrowNotImplementedError as err:
317318
# _from_scalars should only raise ValueError or TypeError.
318-
raise ValueError
319+
raise ValueError from err
319320

320-
if lib.infer_dtype(scalars, skipna=True) != lib.infer_dtype(pa_array, skipna=True):
321+
same_dtype = lib.infer_dtype(pa_array, skipna=True) == inferred_dtype
322+
if not same_dtype:
321323
raise ValueError
322324
return pa_array
323325

0 commit comments

Comments
 (0)