Repository navigation
Conversation
Squashed history of the pyarrow-stubs-pr3-core-data-sans-generic branch: the internal type system stubs, the stubs of the core data structures (arrays, tables, tensors, builders, memory, devices, config and types), the type annotation tests in pyarrow-stubs-tests, stubtest, and the pinned type checking environment with the python-stubs pre-commit hooks. Co-authored-by: AlenkaF <[email protected]> Co-authored-by: Tadeja Kadunc <[email protected]> Co-authored-by: Dan Redding <[email protected]> Co-authored-by: Joris Van den Bossche <[email protected]>
Replace the scalar.pyi placeholder with annotations for Scalar, its subclasses, NA and pyarrow.scalar(), following the conventions of the other stubs: plain classes instead of generics, the class hierarchy of the runtime (e.g. StringScalar is a BinaryScalar, the extension scalars are ExtensionScalars, ListScalar is a Sequence and StructScalar a Mapping), and concrete return types for as_py() and the value properties. Array and ChunkedArray now return real Scalar types from indexing, iteration, sum() and index(), so a ChunkedArray is no longer accepted as the mask of pyarrow.array(). Their __getitem__ gets two overloads, so that an index returns a Scalar and a slice an array, instead of a union of both. Add annotation tests for the scalars.
rok
requested review from
AlenkaF,
assignUser,
jonkeane,
kou and
raulcd
as code owners
November 13, 2026 13:43
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
Closes: #55590
What changes are included in this PR?
Adds type annotation stubs for the scalar module:
Scalar, its subclasses,NAandpyarrow.scalar(). Indexing anArrayorChunkedArraynow returns aScalarfor an index and an array for a slice. Includes annotation tests for scalars.Are these changes tested?
Yes, by the type annotation tests in
pyarrow-stubs-testsand by CI.Are there any user-facing changes?
Scalars will be type annotated.
Was AI used for this PR?
PR code and description written by:
Reviewed before submission by: