Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ jobs:
run: >-
uv run --frozen pytest
--cov --cov-report=xml --cov-report=term --durations=20
src docs tests

- name: Upload coverage report
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24
Expand All @@ -82,15 +81,14 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install the project
run: uv sync --locked --group test --resolution lowest-direct
run: uv sync --group test --resolution lowest-direct

- name: Test package
run: >-
uv run --frozen pytest
--cov --cov-report=xml --cov-report=term --durations=20
src docs tests

- name: Upload coverage report
uses: codecov/codecov-action@v18283e04ce6e62d37312384ff67231eb8fd56d24
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24
with:
token: ${{ secrets.CODECOV_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ venv/

# Mac files
.DS_Store

# Coverage
.coverage
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ version_tuple = {version_tuple!r}
]
log_cli_level = "INFO"
minversion = "8.3"
testpaths = ["README.md", "src/", "docs", "tests/"]
testpaths = ["README.md", "src/", "tests/"]
norecursedirs = ["docs/_build"]
xfail_strict = true

Expand Down
9 changes: 4 additions & 5 deletions src/array_api_typing/_namespace.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
__all__ = ("HasArrayNamespace",)

from types import ModuleType
from typing import Protocol, final
from typing import Protocol
from typing_extensions import TypeVar

T = TypeVar("T", bound=object, default=ModuleType) # PEP 696 default
T_co = TypeVar("T_co", covariant=True, bound=object, default=ModuleType)


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

Example:
Expand All @@ -26,4 +25,4 @@ class HasArrayNamespace(Protocol[T]): # type: ignore[misc] # see python/mypy#1

"""

def __array_namespace__(self, /, *, api_version: str | None = None) -> T: ... # noqa: PLW3201
def __array_namespace__(self, /, *, api_version: str | None = None) -> T_co: ... # noqa: PLW3201
Empty file added tests/__init__.py
Empty file.
7 changes: 5 additions & 2 deletions tests/test_namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@


@runtime_checkable
class CheckableHasArrayNamespace(xpt.HasArrayNamespace, Protocol): # type: ignore[misc]
"""Runtime checkable version of HasArrayNamespace."""
class CheckableHasArrayNamespace(xpt.HasArrayNamespace, Protocol):
"""A runtime-checkable version of the HasArrayNamespace protocol."""

# This class is used to ensure that the protocol can be checked at runtime.
# It inherits from xpt.HasArrayNamespace and is marked as runtime_checkable.


class GoodArray:
Expand Down
Loading