array-api
array-api copied to clipboard
Type hints for other projects
I see that you are using type hints internally to check the spec. However, I am not sure if there are plans to export type hint annotations for being used in projects consuming and/or implementing this spec.
I am currently working in a project that uses Mypy to catch typing errors. I wanted to change it so that it does not assume NumPy arrays, but uses the interfaces and semantics defined in the array API standard. However, I am worried that doing so leaves me without a way to statically check via Mypy that my typing is correct. Is there currently any way to do it?
+1. https://github.com/data-apis/array-api/pull/589 will make the existing type hints more practical by having our array class be a Protocol
, and then we can think about packaging the type hints as a standalone package, or alongside stubs (https://github.com/data-apis/array-api/pull/472).
See also:
- https://github.com/data-apis/array-api/issues/584
- https://github.com/data-apis/array-api/issues/411
- https://github.com/data-apis/consortium-feedback/discussions/8
I also noticed that, although it would be very useful to make the Array
protocol generic w.r.t. shape and dtype, that could not be meaningfully used without Python support for higher kinded types, and there is not even a PEP for that yet: https://github.com/python/typing/issues/548.