You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add type hints / annotations to array_namespace(): array_api_strict as return type? #194
Without type hints, it is very inconvenient because of spelling errors of array_api functions. As array_api_compat seems to be a superset of array_api_strict, I would like to propose to simply set the return type of array_namespace() to array_api_strict, although it might be confusing.
Setting the return type as array_api_strict seems wrong. array_api_strict isn't a type, it's a module, and it isn't even the module that's returned in most cases. The correct return type would be typing.ModuleType, which we can definitely add, although I don't think that alone would make it infer much.
I just want to make sure that, once array-api-typing is complete, get_namespace() will return ArrayNamespace or something, is that right? I hope you could leave this issue open as development of array-api-typing is resumed. (Not sure why you have closed this. I understand that you want to reduce the number of open Issues though.)
once array-api-typing is complete, get_namespace() will return ArrayNamespace or something, is that right?
That sounds right 👍
(Not sure why you have closed this. I understand that you want to reduce the number of open Issues though.)
Yes, sorry, in case it wasn't clear, my rationale for closing was that:
this is not actionable right now
this doesn't track something that we might 'forget' about later. In other words, once the work in array-api-typing is done, addressing this issue will be an obvious next step.
Activity
asmeurer commentedon Nov 6, 2024
I think upstream work to make a protocol out of the array API namespace would be what we'd want here.
data-apis/array-api#685
data-apis/array-api#267
Setting the return type as
array_api_strictseems wrong. array_api_strict isn't a type, it's a module, and it isn't even the module that's returned in most cases. The correct return type would betyping.ModuleType, which we can definitely add, although I don't think that alone would make it infer much.lucascolley commentedon Jan 26, 2025
let's close this one - we would of course like to annotate all of array-api-compat once the necessary tools are available in array-api-typing.
34j commentedon Jun 5, 2025
I just want to make sure that, once array-api-typing is complete, get_namespace() will return ArrayNamespace or something, is that right? I hope you could leave this issue open as development of array-api-typing is resumed. (Not sure why you have closed this. I understand that you want to reduce the number of open Issues though.)
lucascolley commentedon Jun 5, 2025
That sounds right 👍
Yes, sorry, in case it wasn't clear, my rationale for closing was that: