Skip to content

TYP: fromfunction shape-typing - #32686

Open
jorenham wants to merge 1 commit into
numpy:mainfrom
jorenham:typing/fromfunction/shape-typing
Open

jorenham wants to merge 1 commit into
numpy:mainfrom
jorenham:typing/fromfunction/shape-typing

Conversation

@jorenham

@jorenham jorenham commented Sep 17, 2026

Copy link
Copy Markdown
Member

np.fromfunction now requires the function signature to match the shape rank type. This makes it a lot less type-unsafe, at the cost of this now also rejecting technically-valid shape sequence types that aren't tuple[int, ...] or list[int], which I think is a fair restriction. So let's hope that mypy_primer won't get angry :P. But it's a surprisingly unpopular function (according to my shape-typing / popularity gist), so I don't expect this to cause a lot of issues.


Pair programmed with AI (and me; a real human!)

@jorenham jorenham added this to the 2.6.0 Release milestone Sep 17, 2026
@jorenham
jorenham force-pushed the typing/fromfunction/shape-typing branch from 5654309 to 50121b3 Compare September 17, 2026 21:39
@jorenham
jorenham force-pushed the typing/fromfunction/shape-typing branch from 50121b3 to 825ac55 Compare September 17, 2026 21:42
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.

1 participant