Skip to content

TYP: trapezoid shape-typing - #32685

Merged
charris merged 1 commit into
numpy:mainfrom
jorenham:typing/trapezoid/shape-typing
Sep 21, 2026
Merged

charris merged 1 commit into
numpy:mainfrom
jorenham:typing/trapezoid/shape-typing

Conversation

@jorenham

Copy link
Copy Markdown
Member

np.trapezoid now returns exact shape-types for the (broadcasted) combinations of y and x.


Pair programmed with AI.

@jorenham jorenham added this to the 2.6.0 Release milestone Sep 17, 2026
@github-actions

Copy link
Copy Markdown

Diff from mypy_primer, showing the effect of this PR on type check results on a corpus of open source code:

colour (https://github.com/colour-science/colour)
- colour/utilities/array.py:1311: error: Argument "x" to "trapezoid" has incompatible type "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None"; expected "ndarray[tuple[int], dtype[float64 | integer[Any] | numpy.bool[builtins.bool]]] | Sequence[float] | None"  [arg-type]
+ colour/utilities/array.py:1311: error: Argument "x" to "trapezoid" has incompatible type "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | None"; expected "_SupportsArray[dtype[numpy.bool[builtins.bool] | integer[Any] | floating[Any]]] | _NestedSequence[_SupportsArray[dtype[numpy.bool[builtins.bool] | integer[Any] | floating[Any]]]] | float | _NestedSequence[float] | None"  [arg-type]

@charris
charris merged commit a24fa39 into numpy:main Sep 21, 2026
16 checks passed
@charris

charris commented Sep 21, 2026

Copy link
Copy Markdown
Member

Thanks Joren.

@jorenham
jorenham deleted the typing/trapezoid/shape-typing branch September 21, 2026 15:51
Riaz1729 pushed a commit to Riaz1729/numpy that referenced this pull request Sep 23, 2026
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.

2 participants