Skip to content

Commit 204c20a

Browse files
nstarmanjorenham
andauthored
test: fix CI and unfinalize HasArrayNamespace (#29)
Co-authored-by: Joren Hammudoglu <[email protected]>
1 parent 59e8f61 commit 204c20a

File tree

7 files changed

+24
-21
lines changed

7 files changed

+24
-21
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ jobs:
5757
run: >-
5858
uv run --frozen pytest
5959
--cov --cov-report=xml --cov-report=term --durations=20
60-
src docs tests
6160
6261
- name: Upload coverage report
6362
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24
@@ -82,15 +81,14 @@ jobs:
8281
with:
8382
python-version: ${{ matrix.python-version }}
8483
- name: Install the project
85-
run: uv sync --locked --group test --resolution lowest-direct
84+
run: uv sync --group test --resolution lowest-direct
8685

8786
- name: Test package
8887
run: >-
8988
uv run --frozen pytest
9089
--cov --cov-report=xml --cov-report=term --durations=20
91-
src docs tests
9290
9391
- name: Upload coverage report
94-
uses: codecov/codecov-action@v18283e04ce6e62d37312384ff67231eb8fd56d24
92+
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24
9593
with:
9694
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ venv/
2525

2626
# Mac files
2727
.DS_Store
28+
29+
# Coverage
30+
.coverage

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
]
4747
test = [
4848
"numpy>=1.25",
49-
"pytest>=8.3.3",
50-
"pytest-cov>=3",
49+
"pytest==8.3.3",
50+
"pytest-cov>=6",
5151
"pytest-github-actions-annotate-failures>=0.3.0",
5252
"sybil>=8.0.0",
5353
]
@@ -115,7 +115,7 @@ version_tuple = {version_tuple!r}
115115
]
116116
log_cli_level = "INFO"
117117
minversion = "8.3"
118-
testpaths = ["README.md", "src/", "docs", "tests/"]
118+
testpaths = ["README.md", "src/", "tests/"]
119119
norecursedirs = ["docs/_build"]
120120
xfail_strict = true
121121

src/array_api_typing/_namespace.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
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

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

99

10-
@final
11-
class HasArrayNamespace(Protocol[T]): # type: ignore[misc] # see python/mypy#17288
10+
class HasArrayNamespace(Protocol[T_co]):
1211
"""Protocol for classes that have an `__array_namespace__` method.
1312
1413
Example:
@@ -26,4 +25,4 @@ class HasArrayNamespace(Protocol[T]): # type: ignore[misc] # see python/mypy#1
2625
2726
"""
2827

29-
def __array_namespace__(self, /, *, api_version: str | None = None) -> T: ... # noqa: PLW3201
28+
def __array_namespace__(self, /, *, api_version: str | None = None) -> T_co: ... # noqa: PLW3201

tests/__init__.py

Whitespace-only changes.

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:

uv.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)