Skip to content

Commit 7ef593c

Browse files
authored
fix: minor touchups based on stricter mypy settings (#1060)
* fix: minor touchups based on stricter mypy settings * refactor: address review comments
1 parent dc10f1a commit 7ef593c

4 files changed

Lines changed: 13 additions & 11 deletions

File tree

.pre-commit-config.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ repos:
3131
hooks:
3232
- id: pycln
3333
args: [--all]
34-
additional_dependencies: [click<8.1] # temporary workaround until typer updates
34+
stages: [manual]
3535

3636
- repo: https://github.com/PyCQA/isort
3737
rev: 5.10.1
@@ -54,7 +54,7 @@ repos:
5454
- id: mypy
5555
name: mypy 3.6 on cibuildwheel/
5656
exclude: ^(bin|cibuildwheel/resources|docs)/.*py$
57-
args: ["--python-version=3.6", "--show-error-codes"]
57+
args: ["--python-version=3.6"]
5858
additional_dependencies: &mypy-dependencies
5959
- nox
6060
- packaging>=21.0
@@ -72,11 +72,11 @@ repos:
7272
- id: mypy
7373
name: mypy 3.7+ on bin/
7474
files: ^((bin|docs)/.*py)$
75-
args: ["--python-version=3.7", "--show-error-codes"]
75+
args: ["--python-version=3.7"]
7676
additional_dependencies: *mypy-dependencies
7777
- id: mypy
7878
name: mypy 3.10
79-
args: ["--python-version=3.10", "--show-error-codes"]
79+
args: ["--python-version=3.10"]
8080
additional_dependencies: *mypy-dependencies
8181

8282
- repo: https://github.com/asottile/yesqa
@@ -98,8 +98,6 @@ repos:
9898
hooks:
9999
- id: python-check-blanket-noqa
100100
stages: [manual]
101-
- id: python-check-blanket-type-ignore
102-
stages: [manual]
103101
- id: python-no-log-warn
104102
- id: python-no-eval
105103
- id: python-use-type-annotations

cibuildwheel/options.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def architectures(self) -> Set[Architecture]:
9696
return self.globals.architectures
9797

9898

99-
Setting = Union[Dict[str, str], List[str], str]
99+
Setting = Union[Dict[str, str], List[str], str, int]
100100

101101

102102
class Override(NamedTuple):
@@ -482,21 +482,20 @@ def build_options(self, identifier: Optional[str]) -> BuildOptions:
482482

483483
if not config_value:
484484
# default to manylinux2014
485-
image = pinned_images.get("manylinux2014")
485+
image = pinned_images["manylinux2014"]
486486
elif config_value in pinned_images:
487487
image = pinned_images[config_value]
488488
else:
489489
image = config_value
490490

491-
assert image is not None
492491
manylinux_images[build_platform] = image
493492

494493
for build_platform in MUSLLINUX_ARCHS:
495494
pinned_images = all_pinned_docker_images[build_platform]
496495

497496
config_value = self.reader.get(f"musllinux-{build_platform}-image")
498497

499-
if config_value is None:
498+
if not config_value:
500499
image = pinned_images["musllinux_1_1"]
501500
elif config_value in pinned_images:
502501
image = pinned_images[config_value]

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ files = [
3838
"noxfile.py",
3939
]
4040
warn_unused_configs = true
41+
show_error_codes = true
42+
4143
warn_redundant_casts = true
4244
no_implicit_reexport = true
4345
strict_equality = true
@@ -49,6 +51,9 @@ disallow_any_generics = true
4951
warn_return_any = true
5052
no_implicit_optional = true
5153

54+
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
55+
warn_unreachable = true
56+
5257
[[tool.mypy.overrides]]
5358
module = "cibuildwheel.*"
5459
disallow_untyped_defs = true

unit_test/wheel_print_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_no_printout_on_error(tmp_path, capsys):
2626
tmp_path.joinpath("example.1").touch()
2727
raise RuntimeError()
2828

29-
captured = capsys.readouterr()
29+
captured = capsys.readouterr() # type: ignore[unreachable]
3030
assert captured.err == ""
3131

3232
assert "example.0" not in captured.out

0 commit comments

Comments
 (0)