Skip to content

Commit

Permalink
chore: improve mypy
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii committed Oct 21, 2024
1 parent 4e93d91 commit 1faa32e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ repos:
- nox
- packaging
- pygithub
- pytest
- rich
- tomli
- tomli_w
Expand All @@ -40,6 +41,7 @@ repos:
- types-jinja2
- types-pyyaml
- types-requests
- types-setuptools
- uv
- validate-pyproject
- id: mypy
Expand Down
2 changes: 1 addition & 1 deletion docs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def define_env(env: Any) -> None:
"Hook function for mkdocs-macros"

@env.macro
@env.macro # type: ignore[misc]
def subprocess_run(*args: str) -> str:
"Run a subprocess and return the stdout"
env = os.environ.copy()
Expand Down
18 changes: 5 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,13 @@ files = [
]
warn_unused_configs = true

warn_redundant_casts = true
no_implicit_reexport = true
strict_equality = true
warn_unused_ignores = true
check_untyped_defs = true

disallow_subclassing_any = true
disallow_any_generics = true
warn_return_any = true
no_implicit_optional = true
strict = true
disallow_untyped_defs = false
disallow_untyped_calls = false
disallow_incomplete_defs = false

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

[[tool.mypy.overrides]]
module = "cibuildwheel.*"
Expand All @@ -136,10 +130,8 @@ disallow_untyped_decorators = true

[[tool.mypy.overrides]]
module = [
"setuptools",
"setuptools._distutils", # needed even if only directly import setuptools._distutils.util
"setuptools._distutils.util",
"pytest", # ignored in pre-commit to speed up check
"bashlex",
"bashlex.*",
"importlib_resources",
Expand Down
8 changes: 4 additions & 4 deletions test/test_custom_repair_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ def test(tmp_path, capfd):
basic_project.generate(project_dir)

num_builds = len(utils.cibuildwheel_get_build_identifiers(project_dir))
if num_builds > 1:
expectation = pytest.raises(subprocess.CalledProcessError)
else:
expectation = does_not_raise()
expectation = (
pytest.raises(subprocess.CalledProcessError) if num_builds > 1 else does_not_raise()
)

with expectation as exc_info:
result = utils.cibuildwheel_run(
Expand All @@ -48,6 +47,7 @@ def test(tmp_path, capfd):

captured = capfd.readouterr()
if num_builds > 1:
assert exc_info is not None
assert "Build failed because a wheel named" in captured.err
assert exc_info.value.returncode == 6
else:
Expand Down
2 changes: 1 addition & 1 deletion unit_test/wheel_print_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_no_printout_on_error(tmp_path, capsys):
tmp_path.joinpath("example.1").touch()
raise RuntimeError()

captured = capsys.readouterr() # type: ignore[unreachable]
captured = capsys.readouterr()
assert captured.err == ""

assert "example.0" not in captured.out
Expand Down

0 comments on commit 1faa32e

Please sign in to comment.