jorenham / optype

Opinionated typing package for precise type hints in Python
BSD 3-Clause "New" or "Revised" License
10 stars 0 forks source link

Array-API interfaces #25

Open jorenham opened 5 months ago

jorenham commented 5 months ago

https://data-apis.org/array-api/latest/API_specification/array_object.html

This won't require (optional) runtime dependencies

jorenham commented 2 months ago

There are some "stubs" within the array-api repo already: https://github.com/data-apis/array-api/tree/2023.12/src/array_api_stubs

But they have one tiny issue; they don't make any sense at all, and are completely useless in their current state. Sadly, it appears to me as if it'd be faster to rewrite them from scratch, then to attempt to fix it.

For example; the use of typing.TypeVar is almost always incorrect. It looks as if the authors believe that a TypeVar can be used as some sort of global placeholder for to-be-defined types 🤷🏻.


update

This comment seems to confirm my hunch:

"""
Types for type annotations used in the array API standard.

The type variables should be replaced with the actual types for a given
library, e.g., for NumPy TypeVar('array') would be replaced with ndarray.
"""

from https://github.com/data-apis/array-api/blob/fbc9ddec2f0366df069901a1d99580b5791f8772/src/array_api_stubs/_2023_12/_types.py#L1C1-L6C4