Skip to content

TYP: Fix missing _core.numeric (re-)exports #29166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 11, 2025

Conversation

jorenham
Copy link
Member

@jorenham jorenham commented Jun 11, 2025

This helps reduce the amount of red squigglies in internal .py code, and brings the stubs closer to those of numtype (which are verified by stubtest, mypy, and basedpyright).

This comment has been minimized.

Copy link

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

xarray (https://github.com/pydata/xarray)
+ xarray/compat/npcompat.py: note: In function "isdtype":
+ xarray/compat/npcompat.py:54: error: All conditional function variants must have identical signatures  [misc]
+ xarray/compat/npcompat.py:54: note: Original:
+ xarray/compat/npcompat.py:54: note:     def isdtype(dtype: dtype[Any] | type, kind: type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None | tuple[type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None, ...]) -> bool
+ xarray/compat/npcompat.py:54: note: Redefinition:
+ xarray/compat/npcompat.py:54: note:     def isdtype(dtype: dtype[Any] | type[Any], kind: type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None | tuple[type[Any] | dtype[Any] | _SupportsDType[dtype[Any]] | tuple[Any, Any] | list[Any] | _DTypeDict | str | None, ...]) -> bool

@jorenham
Copy link
Member Author

That primer diff is caused by a mypy bug, because type and type[Any] are fully compatible, so those xarray signatures are also fully compatible.

@charris charris merged commit 18cbd6d into numpy:main Jun 11, 2025
76 checks passed
@charris
Copy link
Member

charris commented Jun 11, 2025

Thanks Joren.

@jorenham jorenham deleted the typing/_core-fixes branch June 11, 2025 19:36
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