From 38f09255f56cd0326300262637c1c4bd4ad1069d Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Tue, 22 Mar 2022 17:54:18 -0400 Subject: [PATCH] fix: minor touchups based on stricter mypy settings --- .pre-commit-config.yaml | 11 +++++------ cibuildwheel/options.py | 4 ++-- pyproject.toml | 5 +++++ unit_test/wheel_print_test.py | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 115336688..eb74c6b53 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,8 @@ repos: rev: v1.2.5 hooks: - id: pycln - args: [--config=pyproject.toml] + args: [--all] + stages: [manual] - repo: https://github.com/PyCQA/isort rev: 5.10.1 @@ -53,7 +54,7 @@ repos: - id: mypy name: mypy 3.6 on cibuildwheel/ exclude: ^(bin|cibuildwheel/resources|docs)/.*py$ - args: ["--python-version=3.6", "--show-error-codes"] + args: ["--python-version=3.6"] additional_dependencies: &mypy-dependencies - nox - packaging>=21.0 @@ -71,11 +72,11 @@ repos: - id: mypy name: mypy 3.7+ on bin/ files: ^((bin|docs)/.*py)$ - args: ["--python-version=3.7", "--show-error-codes"] + args: ["--python-version=3.7"] additional_dependencies: *mypy-dependencies - id: mypy name: mypy 3.10 - args: ["--python-version=3.10", "--show-error-codes"] + args: ["--python-version=3.10"] additional_dependencies: *mypy-dependencies - repo: https://github.com/asottile/yesqa @@ -97,8 +98,6 @@ repos: hooks: - id: python-check-blanket-noqa stages: [manual] - - id: python-check-blanket-type-ignore - stages: [manual] - id: python-no-log-warn - id: python-no-eval - id: python-use-type-annotations diff --git a/cibuildwheel/options.py b/cibuildwheel/options.py index 75ee7f6be..630bf9c0f 100644 --- a/cibuildwheel/options.py +++ b/cibuildwheel/options.py @@ -96,7 +96,7 @@ def architectures(self) -> Set[Architecture]: return self.globals.architectures -Setting = Union[Dict[str, str], List[str], str] +Setting = Union[Dict[str, str], List[str], str, int] class Override(NamedTuple): @@ -496,7 +496,7 @@ def build_options(self, identifier: Optional[str]) -> BuildOptions: config_value = self.reader.get(f"musllinux-{build_platform}-image") - if config_value is None: + if not config_value: image = pinned_images["musllinux_1_1"] elif config_value in pinned_images: image = pinned_images[config_value] diff --git a/pyproject.toml b/pyproject.toml index 7b24f16b6..0cdaa1b98 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,8 @@ files = [ "noxfile.py", ] warn_unused_configs = true +show_error_codes = true + warn_redundant_casts = true no_implicit_reexport = true strict_equality = true @@ -49,6 +51,9 @@ disallow_any_generics = true warn_return_any = true no_implicit_optional = true +enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] +warn_unreachable = true + [[tool.mypy.overrides]] module = "cibuildwheel.*" disallow_untyped_defs = true diff --git a/unit_test/wheel_print_test.py b/unit_test/wheel_print_test.py index 3fcadeb29..020600604 100644 --- a/unit_test/wheel_print_test.py +++ b/unit_test/wheel_print_test.py @@ -26,7 +26,7 @@ def test_no_printout_on_error(tmp_path, capsys): tmp_path.joinpath("example.1").touch() raise RuntimeError() - captured = capsys.readouterr() + captured = capsys.readouterr() # type: ignore[unreachable] assert captured.err == "" assert "example.0" not in captured.out