Skip to content

TYP: fix return type of strings.[r]partition - #31912

Merged
charris merged 1 commit into
numpy:mainfrom
jorenham:typing/strings.partition-tuple
Jul 8, 2026
Merged

charris merged 1 commit into
numpy:mainfrom
jorenham:typing/strings.partition-tuple

Conversation

@jorenham

@jorenham jorenham commented Jul 8, 2026

Copy link
Copy Markdown
Member

Unlike np.char.[r]partition, which returns a (single) array, np.strings.[r]partition returns a 3-tuple or arrays:

>>> r = np.strings.partition(np.array(["a b", "c d"]), " ")
>>> type(r), len(r), type(r[0])
(<class 'tuple'>, 3, <class 'numpy.ndarray'>)

The docstring also confirms this.

This fixes the stubs, that previously return (single) arrays here, to match this runtime behavior.


Fully written by me (a human); bug found by Claude Fable 5 (here's the full (second) audit for those interested).

(more stub fixes incoming, btw)

@jorenham jorenham added 09 - Backport-Candidate PRs tagged should be backported 41 - Static typing component: numpy.strings String dtypes and functions labels Jul 8, 2026
@charris
charris merged commit 52da4e9 into numpy:main Jul 8, 2026
14 checks passed
@charris

charris commented Jul 8, 2026

Copy link
Copy Markdown
Member

Thanks Joren.

@jorenham
jorenham deleted the typing/strings.partition-tuple branch July 8, 2026 12:39
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants