Skip to content

Commit ecf10a3

Browse files
committed
refactor: unfinalize HasArrayNamespace
1 parent c3559a8 commit ecf10a3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/array_api_typing/_namespace.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
__all__ = ("HasArrayNamespace",)
22

33
from types import ModuleType
4-
from typing import Protocol, final
4+
from typing import Protocol
55
from typing_extensions import TypeVar
66

77
T = TypeVar("T", bound=object, default=ModuleType) # PEP 696 default
88

99

10-
@final
1110
class HasArrayNamespace(Protocol[T]): # type: ignore[misc] # see python/mypy#17288
1211
"""Protocol for classes that have an `__array_namespace__` method.
1312

tests/test_namespace.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55

66

77
@runtime_checkable
8-
class CheckableHasArrayNamespace(xpt.HasArrayNamespace, Protocol): # type: ignore[misc]
9-
"""Runtime checkable version of HasArrayNamespace."""
8+
class CheckableHasArrayNamespace(xpt.HasArrayNamespace, Protocol):
9+
"""A runtime-checkable version of the HasArrayNamespace protocol."""
10+
11+
# This class is used to ensure that the protocol can be checked at runtime.
12+
# It inherits from xpt.HasArrayNamespace and is marked as runtime_checkable.
1013

1114

1215
class GoodArray:

0 commit comments

Comments
 (0)