tests: fully type the test suite (#2794)

* tests: fully type the test suite

* chore: require more typing

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Henry Schreiner
2026-04-01 15:23:02 +01:00
committed by GitHub
co-authored by pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
parent 643b30c796
commit 097806b6b1
58 changed files with 627 additions and 339 deletions
+8 -8
View File
@@ -3,7 +3,7 @@ import subprocess
import sys
import typing
from contextlib import contextmanager
from pathlib import PurePosixPath
from pathlib import Path, PurePosixPath
from unittest import mock
import pytest
@@ -18,19 +18,19 @@ ALL_IDS = DEFAULT_IDS | {"cp313t", "pp38", "pp39", "pp310", "pp311", "gp311_242"
@pytest.fixture
def mock_build_container(monkeypatch):
def fail_on_call(*args, **kwargs):
def mock_build_container(monkeypatch: pytest.MonkeyPatch) -> None:
def fail_on_call(*args: object, **kwargs: object) -> None:
msg = "This should never be called"
raise RuntimeError(msg)
def ignore_call(*args, **kwargs):
def ignore_call(*args: object, **kwargs: object) -> None:
pass
@contextmanager
def nullcontext(enter_result=None):
def nullcontext(enter_result: object = None) -> typing.Generator[object, None, None]:
yield enter_result
def ignore_context_call(*args, **kwargs):
def ignore_context_call(*args: object, **kwargs: object) -> typing.ContextManager[object]:
return nullcontext(kwargs)
monkeypatch.setenv("CIBW_PLATFORM", "linux")
@@ -49,7 +49,7 @@ def mock_build_container(monkeypatch):
@pytest.mark.usefixtures("mock_build_container", "fake_package_dir")
def test_build_default_launches(monkeypatch):
def test_build_default_launches(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(sys, "argv", [*sys.argv, "--platform=linux"])
monkeypatch.setenv("CIBW_ARCHS", "auto64 auto32")
monkeypatch.delenv("CIBW_ENABLE", raising=False)
@@ -95,7 +95,7 @@ def test_build_default_launches(monkeypatch):
@pytest.mark.usefixtures("mock_build_container")
def test_build_with_override_launches(monkeypatch, tmp_path):
def test_build_with_override_launches(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
pkg_dir = tmp_path / "cibw_package"
pkg_dir.mkdir()