|
35 | 35 | # typing.Self and "|" union syntax don't exist in Python 3.9
|
36 | 36 | from __future__ import annotations
|
37 | 37 |
|
38 |
| -from collections.abc import Generator, Iterable, Iterator, Sequence |
39 |
| -from typing import Any, Callable, cast |
| 38 | +from collections.abc import Callable, Generator, Iterable, Iterator, Sequence |
| 39 | +from typing import Any, cast |
40 | 40 |
|
41 | 41 | import numpy as np
|
42 | 42 | import pandas as pd
|
@@ -551,7 +551,7 @@ def format_series(series):
|
551 | 551 | return series.apply(repr)
|
552 | 552 |
|
553 | 553 | def format_row(row):
|
554 |
| - return ", ".join(f"{name}: {value}" for name, value in zip(row.index, row)) |
| 554 | + return ", ".join(f"{name}: {value}" for name, value in zip(row.index, row, strict=True)) |
555 | 555 |
|
556 | 556 | # Format series to strings
|
557 | 557 | df = df.apply(format_series, axis=0)
|
@@ -665,7 +665,7 @@ def _box_pa_array(cls, value, *, pa_type: pa.DataType | None) -> pa.Array | pa.C
|
665 | 665 | """Convert a value to a PyArrow array with the specified type."""
|
666 | 666 | if isinstance(value, cls):
|
667 | 667 | pa_array = value.struct_array
|
668 |
| - elif isinstance(value, (pa.Array, pa.ChunkedArray)): |
| 668 | + elif isinstance(value, pa.Array | pa.ChunkedArray): |
669 | 669 | pa_array = value
|
670 | 670 | else:
|
671 | 671 | try:
|
@@ -700,7 +700,7 @@ def _from_arrow_like(cls, arraylike, dtype: NestedDtype | None = None) -> Self:
|
700 | 700 | if dtype is None or dtype == arraylike.dtype:
|
701 | 701 | return arraylike
|
702 | 702 | array = arraylike.list_array
|
703 |
| - elif isinstance(arraylike, (pa.Array, pa.ChunkedArray)): |
| 703 | + elif isinstance(arraylike, pa.Array | pa.ChunkedArray): |
704 | 704 | array = arraylike
|
705 | 705 | else:
|
706 | 706 | array = pa.array(arraylike)
|
@@ -1112,7 +1112,7 @@ def fill_field_lists(self, field: str, value: ArrayLike, *, keep_dtype: bool = F
|
1112 | 1112 | )
|
1113 | 1113 | if np.size(value) != len(self):
|
1114 | 1114 | raise ValueError("The length of the input array must be equal to the length of the series")
|
1115 |
| - if isinstance(value, (pa.ChunkedArray, pa.Array)): |
| 1115 | + if isinstance(value, pa.ChunkedArray | pa.Array): |
1116 | 1116 | value = pa.compute.take(value, self.get_list_index())
|
1117 | 1117 | else:
|
1118 | 1118 | value = np.repeat(value, self.list_lengths)
|
|
0 commit comments