-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
TYP: compatibility with array API standard's typing #28665
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
Comments
Let's say that np.array([True]) + 1j Type-checkers infer But at runtime, this would result in a This shows that these array-api annotations fundamentally forbid array types from including important static typing information such as its dtype and the shape-type. There has been previous discussion on this, and the other (many) problems that the current array-api "stubs" have. See e.g. data-apis/array-api#863 and data-apis/array-api#857 (comment). That is why we have decided to build a separate typing package for the array-api: https://github.com/data-apis/array-api-typing/. So far, I haven't had the time to work on this. But I expect that I'll be able to work on in in a couple of months. |
Additionally, using a This is also the reason why most of the |
Hi @jorenham, thanks for the details! 😄 I'm aware of https://github.com/data-apis/array-api-typing/, and one of the reasons I started experimenting with custom I understand some of the internals now and that it would not be possible to get hacks to work before |
Describe the issue:
It looks like NumPy does not follow the array API standard's typing, or maybe I am doing something wrong here :(
For instance, the
array.__add__
function should have the following type signature -by
mypy
cannot find one in the overloads. See MWE below.Reproduce the code example:
Error message:
Python and NumPy Versions:
2.2.4
3.13.2 (main, Feb 4 2025, 14:51:09) [Clang 16.0.0 (clang-1600.0.26.6)]
Type-checker version and settings:
mypy 1.15.0 (compiled: yes)
Additional typing packages.
No response
The text was updated successfully, but these errors were encountered: