Skip to content

Commit 86280bf

Browse files
committed
chore(types): No partial types in tests
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 0ca1803 commit 86280bf

11 files changed

+46
-29
lines changed

bin/make_dependency_update_pr.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
from __future__ import annotations
44

55
import os
6+
import subprocess
67
import sys
78
import textwrap
89
import time
910
from pathlib import Path
10-
from subprocess import run
1111

1212
import click
1313

1414

15-
def shell(cmd, *, check: bool, **kwargs):
16-
return run([cmd], shell=True, check=check, **kwargs)
15+
def shell(cmd: str, *, check: bool, **kwargs: object) -> subprocess.CompletedProcess[str]:
16+
return subprocess.run([cmd], shell=True, check=check, **kwargs) # type: ignore[call-overload, no-any-return]
1717

1818

1919
def git_repo_has_changes() -> bool:
@@ -59,7 +59,7 @@ def main() -> None:
5959
PR generated by `{os.path.basename(__file__)}`.
6060
"""
6161
)
62-
run(
62+
subprocess.run(
6363
[
6464
"gh",
6565
"pr",

bin/projects.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ def get_projects(
172172
return sorted((Project(item, github) for item in config), reverse=online)
173173

174174

175-
def render_projects(projects: Sequence[Project], *, dest_path: Path, include_info: bool = True):
175+
def render_projects(
176+
projects: Sequence[Project], *, dest_path: Path, include_info: bool = True
177+
) -> str:
176178
io = StringIO()
177179
print = functools.partial(builtins.print, file=io)
178180

@@ -203,7 +205,7 @@ def insert_projects_table(
203205
projects: Sequence[Project],
204206
input_filename: str,
205207
include_info: bool = True,
206-
):
208+
) -> None:
207209
text = file.read_text()
208210
projects_table = render_projects(projects, include_info=include_info, dest_path=file)
209211

bin/update_virtualenv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class VersionTuple:
3636
version_string: str
3737

3838

39-
def git_ls_remote_versions(url) -> list[VersionTuple]:
39+
def git_ls_remote_versions(url: str) -> list[VersionTuple]:
4040
versions: list[VersionTuple] = []
4141
tags = subprocess.run(
4242
["git", "ls-remote", "--tags", url], check=True, text=True, capture_output=True

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,13 @@ warn_unused_configs = true
115115

116116
strict = true
117117
disallow_untyped_defs = false
118-
disallow_incomplete_defs = false
119118

120119
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
121120
warn_unreachable = false
122121

123122
[[tool.mypy.overrides]]
124123
module = "cibuildwheel.*"
125124
disallow_untyped_defs = true
126-
disallow_incomplete_defs = true
127125

128126
[[tool.mypy.overrides]]
129127
module = [

test/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .utils import EMULATED_ARCHS, platform
1212

1313

14-
def pytest_addoption(parser) -> None:
14+
def pytest_addoption(parser: pytest.Parser) -> None:
1515
parser.addoption(
1616
"--run-emulation",
1717
action="store",

test/test_testing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def test_failing_test(tmp_path):
155155
@pytest.mark.parametrize("test_runner", ["pytest", "unittest"])
156156
def test_bare_pytest_invocation(
157157
tmp_path: Path, capfd: pytest.CaptureFixture[str], test_runner: str
158-
):
158+
) -> None:
159159
"""Check that if a user runs pytest in the the test cwd, it raises a helpful error"""
160160
project_dir = tmp_path / "project"
161161
output_dir = tmp_path / "output"

unit_test/linux_build_steps_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
from pathlib import Path
55
from pprint import pprint
66

7+
import pytest
8+
79
import cibuildwheel.linux
810
from cibuildwheel.oci_container import OCIContainerEngineConfig
911
from cibuildwheel.options import CommandLineArguments, Options
1012

1113

12-
def test_linux_container_split(tmp_path: Path, monkeypatch):
14+
def test_linux_container_split(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
1315
"""
1416
Tests splitting linux builds by container image, container engine, and before_all
1517
"""

unit_test/oci_container_test.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def test_binary_output(container_engine):
239239
assert output == binary_data_string
240240

241241

242-
def test_file_operation(tmp_path: Path, container_engine):
242+
def test_file_operation(tmp_path: Path, container_engine: OCIContainerEngineConfig) -> None:
243243
with OCIContainer(
244244
engine=container_engine, image=DEFAULT_IMAGE, oci_platform=DEFAULT_OCI_PLATFORM
245245
) as container:
@@ -259,7 +259,7 @@ def test_file_operation(tmp_path: Path, container_engine):
259259
assert test_binary_data == bytes(output, encoding="utf8", errors="surrogateescape")
260260

261261

262-
def test_dir_operations(tmp_path: Path, container_engine):
262+
def test_dir_operations(tmp_path: Path, container_engine: OCIContainerEngineConfig) -> None:
263263
with OCIContainer(
264264
engine=container_engine, image=DEFAULT_IMAGE, oci_platform=DEFAULT_OCI_PLATFORM
265265
) as container:
@@ -301,15 +301,17 @@ def test_dir_operations(tmp_path: Path, container_engine):
301301
assert test_binary_data == (new_test_dir / "test.dat").read_bytes()
302302

303303

304-
def test_environment_executor(container_engine):
304+
def test_environment_executor(container_engine: OCIContainerEngineConfig) -> None:
305305
with OCIContainer(
306306
engine=container_engine, image=DEFAULT_IMAGE, oci_platform=DEFAULT_OCI_PLATFORM
307307
) as container:
308308
assignment = EnvironmentAssignmentBash("TEST=$(echo 42)")
309309
assert assignment.evaluated_value({}, container.environment_executor) == "42"
310310

311311

312-
def test_podman_vfs(tmp_path: Path, monkeypatch, container_engine):
312+
def test_podman_vfs(
313+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, container_engine: OCIContainerEngineConfig
314+
) -> None:
313315
if container_engine.name != "podman":
314316
pytest.skip("only runs with podman")
315317
if sys.platform.startswith("darwin"):
@@ -391,7 +393,7 @@ def test_podman_vfs(tmp_path: Path, monkeypatch, container_engine):
391393
subprocess.run(["podman", "unshare", "rm", "-rf", vfs_path], check=True)
392394

393395

394-
def test_create_args_volume(tmp_path: Path, container_engine):
396+
def test_create_args_volume(tmp_path: Path, container_engine: OCIContainerEngineConfig) -> None:
395397
if container_engine.name != "docker":
396398
pytest.skip("only runs with docker")
397399

@@ -513,7 +515,12 @@ def test_enforce_32_bit(container_engine):
513515
("{name}; disable_host_mount: true", False),
514516
],
515517
)
516-
def test_disable_host_mount(tmp_path: Path, container_engine, config, should_have_host_mount):
518+
def test_disable_host_mount(
519+
tmp_path: Path,
520+
container_engine: OCIContainerEngineConfig,
521+
config: str,
522+
should_have_host_mount: bool,
523+
) -> None:
517524
if detect_ci_provider() in {CIProvider.circle_ci, CIProvider.gitlab}:
518525
pytest.skip("Skipping test because docker on this platform does not support host mounts")
519526
if sys.platform.startswith("darwin"):
@@ -536,7 +543,9 @@ def test_disable_host_mount(tmp_path: Path, container_engine, config, should_hav
536543

537544

538545
@pytest.mark.parametrize("platform", list(OCIPlatform))
539-
def test_local_image(container_engine, platform, tmp_path: Path):
546+
def test_local_image(
547+
container_engine: OCIContainerEngineConfig, platform: OCIPlatform, tmp_path: Path
548+
) -> None:
540549
if (
541550
detect_ci_provider() in {CIProvider.travis_ci}
542551
and pm in {"s390x", "ppc64le"}

unit_test/options_test.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def test_toml_environment_evil(tmp_path, env_var_value):
178178
(r'TEST_VAR="before\\$after"', "before$after"),
179179
],
180180
)
181-
def test_toml_environment_quoting(tmp_path: Path, toml_assignment, result_value):
181+
def test_toml_environment_quoting(tmp_path: Path, toml_assignment: str, result_value: str) -> None:
182182
args = CommandLineArguments.defaults()
183183
args.package_dir = tmp_path
184184

@@ -255,8 +255,12 @@ def test_toml_environment_quoting(tmp_path: Path, toml_assignment, result_value)
255255
],
256256
)
257257
def test_container_engine_option(
258-
tmp_path: Path, toml_assignment, result_name, result_create_args, result_disable_host_mount
259-
):
258+
tmp_path: Path,
259+
toml_assignment: str,
260+
result_name: str,
261+
result_create_args: tuple[str, ...],
262+
result_disable_host_mount: bool,
263+
) -> None:
260264
args = CommandLineArguments.defaults()
261265
args.package_dir = tmp_path
262266

@@ -326,7 +330,9 @@ def test_environment_pass_references():
326330
),
327331
],
328332
)
329-
def test_build_frontend_option(tmp_path: Path, toml_assignment, result_name, result_args):
333+
def test_build_frontend_option(
334+
tmp_path: Path, toml_assignment: str, result_name: str, result_args: list[str]
335+
) -> None:
330336
args = CommandLineArguments.defaults()
331337
args.package_dir = tmp_path
332338

@@ -350,7 +356,7 @@ def test_build_frontend_option(tmp_path: Path, toml_assignment, result_name, res
350356
assert parsed_build_frontend is None
351357

352358

353-
def test_override_inherit_environment(tmp_path: Path):
359+
def test_override_inherit_environment(tmp_path: Path) -> None:
354360
args = CommandLineArguments.defaults()
355361
args.package_dir = tmp_path
356362

@@ -385,7 +391,7 @@ def test_override_inherit_environment(tmp_path: Path):
385391
}
386392

387393

388-
def test_override_inherit_environment_with_references(tmp_path: Path):
394+
def test_override_inherit_environment_with_references(tmp_path: Path) -> None:
389395
args = CommandLineArguments.defaults()
390396
args.package_dir = tmp_path
391397

@@ -434,7 +440,7 @@ def test_override_inherit_environment_with_references(tmp_path: Path):
434440
)
435441
def test_free_threaded_support(
436442
tmp_path: Path, toml_assignment: str, env: dict[str, str], expected_result: bool
437-
):
443+
) -> None:
438444
args = CommandLineArguments.defaults()
439445
args.package_dir = tmp_path
440446

unit_test/utils_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_prepare_command():
7676
("foo-0.1-py38-none-win_amd64.whl", "pp310-win_amd64"),
7777
],
7878
)
79-
def test_find_compatible_wheel_found(wheel: str, identifier: str):
79+
def test_find_compatible_wheel_found(wheel: str, identifier: str) -> None:
8080
wheel_ = PurePath(wheel)
8181
found = find_compatible_wheel([wheel_], identifier)
8282
assert found is wheel_
@@ -96,7 +96,7 @@ def test_find_compatible_wheel_found(wheel: str, identifier: str):
9696
("foo-0.1-cp38-cp38-win_amd64.whl", "cp310-win_amd64"),
9797
],
9898
)
99-
def test_find_compatible_wheel_not_found(wheel: str, identifier: str):
99+
def test_find_compatible_wheel_not_found(wheel: str, identifier: str) -> None:
100100
assert find_compatible_wheel([PurePath(wheel)], identifier) is None
101101

102102

0 commit comments

Comments
 (0)