Skip to content

GH-49194: [Python][Annotations] Compute module - #49201

Draft
rok wants to merge 2 commits into
apache:mainfrom
rok:pyarrow-stubs-pr4-compute
Draft

rok wants to merge 2 commits into
apache:mainfrom
rok:pyarrow-stubs-pr4-compute

Conversation

@rok

@rok rok commented Feb 9, 2026 •

Copy link
Copy Markdown
Member

Rationale for this change

Closes: #49194

What changes are included in this PR?

Adds type annotation stubs for compute, _compute, _compute_docstring, and _acero modules. Includes source fixes in compute.py and acero.py, and type-ignore annotations in related tests.

Are these changes tested?

Yes, by CI.

Are there any user-facing changes?

Compute module functions will be type annotated.

@github-actions

github-actions Bot commented Feb 9, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #49194 has been automatically assigned in GitHub to PR creator.



filter = array_filter
take = array_take

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: redefine take rather than alias to exclude Expression

rok added a commit to rok/arrow that referenced this pull request Nov 13, 2026
Add type annotation stubs for compute, _compute, _compute_docstring,
and _acero modules.

These are the stubs of apacheGH-49201 as they were, at their original paths.
The type checker accommodations that apacheGH-49201 made in compute.py,
acero.py and the PyArrow tests are left out, as the type checkers no
longer run on pyarrow/ (see apacheGH-55264).
rok added a commit to rok/arrow that referenced this pull request Nov 13, 2026
Add type annotation stubs for compute, _compute, _compute_docstring,
and _acero modules.

These are the stubs of apacheGH-49201 as they were, at their original paths.
The type checker accommodations that apacheGH-49201 made in compute.py,
acero.py and the PyArrow tests are left out, as the type checkers no
longer run on pyarrow/ (see apacheGH-55264).
rok added a commit to rok/arrow that referenced this pull request Nov 13, 2026
Add type annotation stubs for compute, _compute, _compute_docstring,
and _acero modules.

These are the stubs of apacheGH-49201 as they were, at their original paths.
The type checker accommodations that apacheGH-49201 made in compute.py,
acero.py and the PyArrow tests are left out, as the type checkers no
longer run on pyarrow/ (see apacheGH-55264).
@rok
rok force-pushed the pyarrow-stubs-pr4-compute branch from d3f0fb7 to a78bedf Compare November 13, 2026 13:06
…al types

Squash of apache#55264 (bc94a18) on top of
main. The compute stubs in the next commit build on it; this commit goes
away once that pull request is merged.
@rok
rok force-pushed the pyarrow-stubs-pr4-compute branch from a78bedf to 29a6b0b Compare November 13, 2026 13:13
Annotate pyarrow.compute, pyarrow._compute, pyarrow._acero and
pyarrow._compute_docstrings, following the approach of apacheGH-55264: plain
classes and unions instead of generics, in the flat pyarrow-stubs/
layout.

- Array arguments accept any Array or ChunkedArray, since pa.array()
  and most of the API return plain Array instances. The return types
  name the kind of array where the function determines it. The scalar
  classes are placeholders (Any) until scalar.pyi is annotated.
- The signatures match the runtime, as checked by stubtest.
- pyarrow.compute and pyarrow._compute are type checked instead of
  being treated as Any.
- Add type annotation tests for the compute and Acero stubs.
@rok
rok force-pushed the pyarrow-stubs-pr4-compute branch from 29a6b0b to fb3204a Compare November 13, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Python][Annotations] Compute module

2 participants