File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 4141
4242PyArrowArray = Union [pa .Array , pa .ChunkedArray ]
4343# Type alias for array batches exchanged with Python scalar UDFs.
44+ #
45+ # We need two related but different annotations here:
46+ # - `PyArrowArray` is the concrete union type (pa.Array | pa.ChunkedArray)
47+ # that is convenient for user-facing callables and casts. Use this when
48+ # annotating or checking values that may be either an Array or
49+ # a ChunkedArray.
50+ # - `PyArrowArrayT` is a constrained `TypeVar` over the two concrete
51+ # array flavors. Keeping a generic TypeVar allows helpers like
52+ # `_wrap_extension_value` and `_wrap_udf_function` to remain generic
53+ # and preserve the specific array "flavor" (Array vs ChunkedArray)
54+ # flowing through them, rather than collapsing everything to the
55+ # wide union. This improves type-checking and keeps return types
56+ # precise in the wrapper logic.
4457PyArrowArrayT = TypeVar ("PyArrowArrayT" , pa .Array , pa .ChunkedArray )
4558
4659
You can’t perform that action at this time.
0 commit comments