Open
Description
I'm not sure if Suggestions are welcome.has_namespace
is the best name for this typeguard, so
Example implementation that builds #17:
# _namespace.py
from typing_extensions import TypeIs
# --snip--
def has_namespace(obj: object, /) -> TypeIs[HasNamespace[Any]]:
return hasattr(obj, "__array_namespace__")
Activity
[-]`def has_namespace(obj: ?, /) -> TypeIs[HasNamespace]`[/-][+]`def has_namespace(obj) -> TypeIs[HasNamespace]`[/+]nstarman commentedon Jun 8, 2025
Given https://data-apis.org/array-api-compat/helper-functions.html#array_api_compat.array_namespace and that there's the
linalg
namespace, how about the more verbosehas_array_namespace
.[-]`def has_namespace(obj) -> TypeIs[HasNamespace]`[/-][+]`def has_array_namespace(obj) -> TypeIs[HasNamespace]`[/+]