diff --git a/bin/make_dependency_update_pr.py b/bin/make_dependency_update_pr.py index 62fb6f4af..54796641a 100755 --- a/bin/make_dependency_update_pr.py +++ b/bin/make_dependency_update_pr.py @@ -3,17 +3,17 @@ from __future__ import annotations import os +import subprocess import sys import textwrap import time from pathlib import Path -from subprocess import run import click -def shell(cmd, *, check: bool, **kwargs): - return run([cmd], shell=True, check=check, **kwargs) +def shell(cmd: str, *, check: bool, **kwargs: object) -> subprocess.CompletedProcess[str]: + return subprocess.run([cmd], shell=True, check=check, **kwargs) # type: ignore[call-overload, no-any-return] def git_repo_has_changes() -> bool: @@ -59,7 +59,7 @@ def main() -> None: PR generated by `{os.path.basename(__file__)}`. """ ) - run( + subprocess.run( [ "gh", "pr", diff --git a/bin/projects.py b/bin/projects.py index 3b39c3da4..09c5dc7f4 100755 --- a/bin/projects.py +++ b/bin/projects.py @@ -172,7 +172,9 @@ def get_projects( return sorted((Project(item, github) for item in config), reverse=online) -def render_projects(projects: Sequence[Project], *, dest_path: Path, include_info: bool = True): +def render_projects( + projects: Sequence[Project], *, dest_path: Path, include_info: bool = True +) -> str: io = StringIO() print = functools.partial(builtins.print, file=io) @@ -203,7 +205,7 @@ def insert_projects_table( projects: Sequence[Project], input_filename: str, include_info: bool = True, -): +) -> None: text = file.read_text() projects_table = render_projects(projects, include_info=include_info, dest_path=file) diff --git a/bin/update_virtualenv.py b/bin/update_virtualenv.py index fc69cf63d..b458c3f89 100755 --- a/bin/update_virtualenv.py +++ b/bin/update_virtualenv.py @@ -36,7 +36,7 @@ class VersionTuple: version_string: str -def git_ls_remote_versions(url) -> list[VersionTuple]: +def git_ls_remote_versions(url: str) -> list[VersionTuple]: versions: list[VersionTuple] = [] tags = subprocess.run( ["git", "ls-remote", "--tags", url], check=True, text=True, capture_output=True diff --git a/pyproject.toml b/pyproject.toml index 9a9f3ecce..2dd8588f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -115,7 +115,6 @@ warn_unused_configs = true strict = true disallow_untyped_defs = false -disallow_incomplete_defs = false enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] warn_unreachable = false @@ -123,7 +122,6 @@ warn_unreachable = false [[tool.mypy.overrides]] module = "cibuildwheel.*" disallow_untyped_defs = true -disallow_incomplete_defs = true [[tool.mypy.overrides]] module = [ diff --git a/test/conftest.py b/test/conftest.py index e86c199d4..a42a3ce9a 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -11,7 +11,7 @@ from .utils import EMULATED_ARCHS, platform -def pytest_addoption(parser) -> None: +def pytest_addoption(parser: pytest.Parser) -> None: parser.addoption( "--run-emulation", action="store", diff --git a/test/test_testing.py b/test/test_testing.py index b415fd403..a31dae514 100644 --- a/test/test_testing.py +++ b/test/test_testing.py @@ -155,7 +155,7 @@ def test_failing_test(tmp_path): @pytest.mark.parametrize("test_runner", ["pytest", "unittest"]) def test_bare_pytest_invocation( tmp_path: Path, capfd: pytest.CaptureFixture[str], test_runner: str -): +) -> None: """Check that if a user runs pytest in the the test cwd, it raises a helpful error""" project_dir = tmp_path / "project" output_dir = tmp_path / "output" diff --git a/unit_test/linux_build_steps_test.py b/unit_test/linux_build_steps_test.py index ecf546ebd..ee608d0c7 100644 --- a/unit_test/linux_build_steps_test.py +++ b/unit_test/linux_build_steps_test.py @@ -4,12 +4,14 @@ from pathlib import Path from pprint import pprint +import pytest + import cibuildwheel.linux from cibuildwheel.oci_container import OCIContainerEngineConfig from cibuildwheel.options import CommandLineArguments, Options -def test_linux_container_split(tmp_path: Path, monkeypatch): +def test_linux_container_split(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: """ Tests splitting linux builds by container image, container engine, and before_all """ diff --git a/unit_test/oci_container_test.py b/unit_test/oci_container_test.py index f43a3641c..11d991d11 100644 --- a/unit_test/oci_container_test.py +++ b/unit_test/oci_container_test.py @@ -239,7 +239,7 @@ def test_binary_output(container_engine): assert output == binary_data_string -def test_file_operation(tmp_path: Path, container_engine): +def test_file_operation(tmp_path: Path, container_engine: OCIContainerEngineConfig) -> None: with OCIContainer( engine=container_engine, image=DEFAULT_IMAGE, oci_platform=DEFAULT_OCI_PLATFORM ) as container: @@ -259,7 +259,7 @@ def test_file_operation(tmp_path: Path, container_engine): assert test_binary_data == bytes(output, encoding="utf8", errors="surrogateescape") -def test_dir_operations(tmp_path: Path, container_engine): +def test_dir_operations(tmp_path: Path, container_engine: OCIContainerEngineConfig) -> None: with OCIContainer( engine=container_engine, image=DEFAULT_IMAGE, oci_platform=DEFAULT_OCI_PLATFORM ) as container: @@ -301,7 +301,7 @@ def test_dir_operations(tmp_path: Path, container_engine): assert test_binary_data == (new_test_dir / "test.dat").read_bytes() -def test_environment_executor(container_engine): +def test_environment_executor(container_engine: OCIContainerEngineConfig) -> None: with OCIContainer( engine=container_engine, image=DEFAULT_IMAGE, oci_platform=DEFAULT_OCI_PLATFORM ) as container: @@ -309,7 +309,9 @@ def test_environment_executor(container_engine): assert assignment.evaluated_value({}, container.environment_executor) == "42" -def test_podman_vfs(tmp_path: Path, monkeypatch, container_engine): +def test_podman_vfs( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch, container_engine: OCIContainerEngineConfig +) -> None: if container_engine.name != "podman": pytest.skip("only runs with podman") if sys.platform.startswith("darwin"): @@ -391,7 +393,7 @@ def test_podman_vfs(tmp_path: Path, monkeypatch, container_engine): subprocess.run(["podman", "unshare", "rm", "-rf", vfs_path], check=True) -def test_create_args_volume(tmp_path: Path, container_engine): +def test_create_args_volume(tmp_path: Path, container_engine: OCIContainerEngineConfig) -> None: if container_engine.name != "docker": pytest.skip("only runs with docker") @@ -513,7 +515,12 @@ def test_enforce_32_bit(container_engine): ("{name}; disable_host_mount: true", False), ], ) -def test_disable_host_mount(tmp_path: Path, container_engine, config, should_have_host_mount): +def test_disable_host_mount( + tmp_path: Path, + container_engine: OCIContainerEngineConfig, + config: str, + should_have_host_mount: bool, +) -> None: if detect_ci_provider() in {CIProvider.circle_ci, CIProvider.gitlab}: pytest.skip("Skipping test because docker on this platform does not support host mounts") if sys.platform.startswith("darwin"): @@ -536,7 +543,9 @@ def test_disable_host_mount(tmp_path: Path, container_engine, config, should_hav @pytest.mark.parametrize("platform", list(OCIPlatform)) -def test_local_image(container_engine, platform, tmp_path: Path): +def test_local_image( + container_engine: OCIContainerEngineConfig, platform: OCIPlatform, tmp_path: Path +) -> None: if ( detect_ci_provider() in {CIProvider.travis_ci} and pm in {"s390x", "ppc64le"} diff --git a/unit_test/options_test.py b/unit_test/options_test.py index c19c6619f..061396552 100644 --- a/unit_test/options_test.py +++ b/unit_test/options_test.py @@ -178,7 +178,7 @@ def test_toml_environment_evil(tmp_path, env_var_value): (r'TEST_VAR="before\\$after"', "before$after"), ], ) -def test_toml_environment_quoting(tmp_path: Path, toml_assignment, result_value): +def test_toml_environment_quoting(tmp_path: Path, toml_assignment: str, result_value: str) -> None: args = CommandLineArguments.defaults() args.package_dir = tmp_path @@ -255,8 +255,12 @@ def test_toml_environment_quoting(tmp_path: Path, toml_assignment, result_value) ], ) def test_container_engine_option( - tmp_path: Path, toml_assignment, result_name, result_create_args, result_disable_host_mount -): + tmp_path: Path, + toml_assignment: str, + result_name: str, + result_create_args: tuple[str, ...], + result_disable_host_mount: bool, +) -> None: args = CommandLineArguments.defaults() args.package_dir = tmp_path @@ -326,7 +330,9 @@ def test_environment_pass_references(): ), ], ) -def test_build_frontend_option(tmp_path: Path, toml_assignment, result_name, result_args): +def test_build_frontend_option( + tmp_path: Path, toml_assignment: str, result_name: str, result_args: list[str] +) -> None: args = CommandLineArguments.defaults() args.package_dir = tmp_path @@ -350,7 +356,7 @@ def test_build_frontend_option(tmp_path: Path, toml_assignment, result_name, res assert parsed_build_frontend is None -def test_override_inherit_environment(tmp_path: Path): +def test_override_inherit_environment(tmp_path: Path) -> None: args = CommandLineArguments.defaults() args.package_dir = tmp_path @@ -385,7 +391,7 @@ def test_override_inherit_environment(tmp_path: Path): } -def test_override_inherit_environment_with_references(tmp_path: Path): +def test_override_inherit_environment_with_references(tmp_path: Path) -> None: args = CommandLineArguments.defaults() args.package_dir = tmp_path @@ -434,7 +440,7 @@ def test_override_inherit_environment_with_references(tmp_path: Path): ) def test_free_threaded_support( tmp_path: Path, toml_assignment: str, env: dict[str, str], expected_result: bool -): +) -> None: args = CommandLineArguments.defaults() args.package_dir = tmp_path diff --git a/unit_test/utils_test.py b/unit_test/utils_test.py index b433800a5..e3b87be86 100644 --- a/unit_test/utils_test.py +++ b/unit_test/utils_test.py @@ -76,7 +76,7 @@ def test_prepare_command(): ("foo-0.1-py38-none-win_amd64.whl", "pp310-win_amd64"), ], ) -def test_find_compatible_wheel_found(wheel: str, identifier: str): +def test_find_compatible_wheel_found(wheel: str, identifier: str) -> None: wheel_ = PurePath(wheel) found = find_compatible_wheel([wheel_], identifier) assert found is wheel_ @@ -96,7 +96,7 @@ def test_find_compatible_wheel_found(wheel: str, identifier: str): ("foo-0.1-cp38-cp38-win_amd64.whl", "cp310-win_amd64"), ], ) -def test_find_compatible_wheel_not_found(wheel: str, identifier: str): +def test_find_compatible_wheel_not_found(wheel: str, identifier: str) -> None: assert find_compatible_wheel([PurePath(wheel)], identifier) is None diff --git a/unit_test/validate_schema_test.py b/unit_test/validate_schema_test.py index 698353990..bb102bb25 100644 --- a/unit_test/validate_schema_test.py +++ b/unit_test/validate_schema_test.py @@ -45,7 +45,7 @@ def test_validate_container_engine(): @pytest.mark.parametrize("platform", ["macos", "windows"]) -def test_validate_bad_container_engine(platform: str): +def test_validate_bad_container_engine(platform: str) -> None: """ container-engine is not a valid option for macos or windows """