Skip to content

TYP: fix Pyright error for piecewise with all-scalar funclist - #31878

Merged
charris merged 1 commit into
numpy:mainfrom
jorenham:typing/piecewise-pyright
Jul 6, 2026
Merged

charris merged 1 commit into
numpy:mainfrom
jorenham:typing/piecewise-pyright

Conversation

@jorenham

@jorenham jorenham commented Jul 6, 2026

Copy link
Copy Markdown
Member

Pyright rejected valid np.piecewise calls like np.piecewise(x, [x < 0, x >= 0], [-1.0, 1.0]). I'm not sure whether this is because pyright is overly strict, or because mypy and pyrefly are not strict enough.
But either way, I added an overload to ensure that pyright will no longer falsely reject calls with all-scalar funclist.


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

@jorenham jorenham added 09 - Backport-Candidate PRs tagged should be backported 41 - Static typing labels Jul 6, 2026
@charris
charris merged commit faf6fac into numpy:main Jul 6, 2026
14 checks passed
@charris

charris commented Jul 6, 2026

Copy link
Copy Markdown
Member

Thanks Joren.

@jorenham
jorenham deleted the typing/piecewise-pyright branch July 6, 2026 17:08
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Jul 6, 2026
MaanasArora pushed a commit to MaanasArora/numpy that referenced this pull request Jul 7, 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