Skip to content

Commit 08a68ca

Browse files
authored
fix: should use Collection[Array] instead list[Array] (#170)
"List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance Consider using "Sequence" instead, which is covariant
1 parent 2ab76bf commit 08a68ca

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

pyarrow-stubs/__lib_pxi/array.pyi

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ else:
1616
from typing_extensions import TypeAlias
1717
from typing import (
1818
Any,
19+
Collection,
1920
Generic,
2021
Iterable,
2122
Iterator,
@@ -1095,7 +1096,7 @@ class Array(_PandasConvertible[pd.Series], Generic[_Scalar_CoT]):
10951096
buffers: list[Buffer],
10961097
null_count: int = -1,
10971098
offset=0,
1098-
children: list[Array[Scalar[_DataTypeT]]] | None = None,
1099+
children: Collection[Array[Scalar[_DataTypeT]]] | None = None,
10991100
) -> Array[Scalar[_DataTypeT]]: ...
11001101
@property
11011102
def null_count(self) -> int: ...
@@ -1403,14 +1404,14 @@ class UnionArray(Array[scalar.UnionScalar]):
14031404
def from_dense(
14041405
types: Int8Array,
14051406
value_offsets: Int32Array,
1406-
children: list[Array],
1407+
children: Collection[Array],
14071408
field_names: list[str] | None = None,
14081409
type_codes: Int8Array | None = None,
14091410
) -> UnionArray: ...
14101411
@staticmethod
14111412
def from_sparse(
14121413
types: Int8Array,
1413-
children: list[Array],
1414+
children: Collection[Array],
14141415
field_names: list[str] | None = None,
14151416
type_codes: Int8Array | None = None,
14161417
) -> UnionArray: ...

pyarrow-stubs/__lib_pxi/table.pyi

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ else:
1515
from typing_extensions import TypeAlias
1616
from typing import (
1717
Any,
18+
Collection,
1819
Generator,
1920
Generic,
2021
Iterable,
@@ -469,7 +470,7 @@ class RecordBatch(_Tabular[Array]):
469470
@classmethod
470471
def from_arrays(
471472
cls,
472-
arrays: list[Array] | list[ChunkedArray],
473+
arrays: Collection[Array] | Collection[ChunkedArray],
473474
names: list[str] | None = None,
474475
schema: Schema | None = None,
475476
metadata: Mapping | None = None,
@@ -550,7 +551,7 @@ class Table(_Tabular[ChunkedArray]):
550551
@classmethod
551552
def from_arrays(
552553
cls,
553-
arrays: list[Array] | list[ChunkedArray],
554+
arrays: Collection[Array] | Collection[ChunkedArray],
554555
names: list[str] | None = None,
555556
schema: Schema | None = None,
556557
metadata: Mapping | None = None,
@@ -601,7 +602,7 @@ class Table(_Tabular[ChunkedArray]):
601602

602603
def record_batch(
603604
data: dict[str, list | Array]
604-
| list[Array]
605+
| Collection[Array]
605606
| pd.DataFrame
606607
| SupportArrowArray
607608
| SupportArrowDeviceArray,
@@ -618,7 +619,7 @@ def table(
618619
) -> Table: ...
619620
@overload
620621
def table(
621-
data: list[Array | ChunkedArray]
622+
data: Collection[Array | ChunkedArray]
622623
| pd.DataFrame
623624
| SupportArrowArray
624625
| SupportArrowStream

0 commit comments

Comments
 (0)