Skip to content

[Python][Annotations] Consider improving stubs for chunked inputs and string/bytes key mappings #55782

In progress

Description

@tadeja

Describe the enhancement requested

Follow-up to #55264, under umbrella #32609. Type annotations stubs should match existing runtime behaviors:

  1. Array.take(), Array.filter() and Array.fill_null() return a ChunkedArray when given chunked indices, a chunked mask or a chunked fill value. The stubs currently declare Self.
  2. RecordBatch.take() raises ArrowNotImplementedError for chunked indices, but its stub accepts them. Table.take() supports chunked indices and should keep accepting them.
  3. metadata= (on pa.table(), pa.record_batch(), from_pydict(), from_pylist()) and the fields argument of pa.schema() / pa.struct() reject variables typed as dict[str, ...] or dict[bytes, ...], because Mapping[str | bytes, ...] is invariant in its key type (_MetadataMapping from types.pyi could be reused). Runtime accepts them.

Update type annotation stubs and their regression tests. No runtime code change needed.

Component(s)

Python

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions