From 0aac8c2221db66ab320af2da9bb1639425912dce Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Sat, 12 Jun 2021 14:02:06 -0400 Subject: [PATCH] chore: stricter mypy checking --- bin/projects.py | 2 +- bin/update_pythons.py | 6 ++--- pyproject.toml | 36 +++++++++++++----------------- test/test_projects/__init__.py | 6 +++-- unit_test/build_ids_test.py | 4 ++-- unit_test/docker_container_test.py | 1 + 6 files changed, 27 insertions(+), 28 deletions(-) diff --git a/bin/projects.py b/bin/projects.py index 21461e8d..ad7f27a5 100755 --- a/bin/projects.py +++ b/bin/projects.py @@ -62,7 +62,7 @@ class Project: print(f"Broken: {self.stars_repo}") raise - self.num_stars = repo.stargazers_count + self.num_stars: int = repo.stargazers_count self.pushed_at = repo.pushed_at if not self.notes: notes = repo.description diff --git a/bin/update_pythons.py b/bin/update_pythons.py index c21b0823..4eacb195 100755 --- a/bin/update_pythons.py +++ b/bin/update_pythons.py @@ -122,7 +122,7 @@ class PyPyVersions: self.arch = arch_str def get_arch_file(self, release: dict[str, Any]) -> str: - urls = [ + urls: list[str] = [ rf["download_url"] for rf in release["files"] if "" in rf["platform"] == f"win{self.arch}" @@ -131,7 +131,7 @@ class PyPyVersions: def update_version_windows(self, spec: Specifier) -> ConfigWinCP: releases = [r for r in self.releases if spec.contains(r["python_version"])] - releases = sorted(releases, key=lambda r: r["pypy_version"]) + releases = sorted(releases, key=lambda r: r["pypy_version"]) # type: ignore releases = [r for r in releases if self.get_arch_file(r)] if not releases: @@ -156,7 +156,7 @@ class PyPyVersions: raise RuntimeError("Other archs not supported yet on macOS") releases = [r for r in self.releases if spec.contains(r["python_version"])] - releases = sorted(releases, key=lambda r: r["pypy_version"]) + releases = sorted(releases, key=lambda r: r["pypy_version"]) # type: ignore if not releases: raise RuntimeError(f"PyPy macOS {self.arch} not found for {spec}!") diff --git a/pyproject.toml b/pyproject.toml index f51ad0ee..91d17547 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,7 @@ multi_line_output = 3 [tool.pytest.ini_options] +minversion = 6.0 junit_family = "xunit2" testpaths = [ "test", @@ -26,7 +27,6 @@ testpaths = [ [tool.mypy] -minversion = 6.0 python_version = 3.7 files = [ "cibuildwheel/*.py", @@ -36,33 +36,29 @@ files = [ ] warn_unused_configs = true warn_redundant_casts = true - -# Don't require typed functions for tests -[[tool.mypy.overrides]] -module = ["test", "unit_test"] -check_untyped_defs = true - -[[tool.mypy.overrides]] -module = "cibuildwheel" -disallow_any_generics = true -disallow_subclassing_any = true -disallow_untyped_calls = true -disallow_untyped_defs = true -disallow_incomplete_defs = true -check_untyped_defs = true -disallow_untyped_decorators = true -no_implicit_optional = true -warn_unused_ignores = true -warn_return_any = 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 + +[[tool.mypy.overrides]] +module = "cibuildwheel.*" +disallow_untyped_defs = true +disallow_untyped_calls = true +disallow_incomplete_defs = true +disallow_untyped_decorators = true [[tool.mypy.overrides]] module = [ "setuptools", "pytest", # ignored in pre-commit to speed up check "bashlex", - "toml.encoder", # missing from stub package + "toml.encoder", # encoder missing from stub package "bracex", "importlib_resources", "nox", diff --git a/test/test_projects/__init__.py b/test/test_projects/__init__.py index 48d7dbec..d6bed818 100644 --- a/test/test_projects/__init__.py +++ b/test/test_projects/__init__.py @@ -1,2 +1,4 @@ -from .base import TestProject # noqa -from .c import new_c_project # noqa +from .base import TestProject +from .c import new_c_project + +__all__ = ("TestProject", "new_c_project") diff --git a/unit_test/build_ids_test.py b/unit_test/build_ids_test.py index b0d4188a..6aa100e3 100644 --- a/unit_test/build_ids_test.py +++ b/unit_test/build_ids_test.py @@ -11,7 +11,7 @@ def test_compare_configs(): dict_txt = toml.loads(txt) - new_txt = toml.dumps(dict_txt, encoder=InlineArrayDictEncoder()) + new_txt = toml.dumps(dict_txt, encoder=InlineArrayDictEncoder()) # type: ignore print(new_txt) assert new_txt == txt @@ -35,6 +35,6 @@ python_configurations = [ ] """ - output = toml.dumps(example, encoder=InlineArrayDictEncoder()) + output = toml.dumps(example, encoder=InlineArrayDictEncoder()) # type: ignore print(output) assert output == result diff --git a/unit_test/docker_container_test.py b/unit_test/docker_container_test.py index 79046e72..2b49eda0 100644 --- a/unit_test/docker_container_test.py +++ b/unit_test/docker_container_test.py @@ -63,6 +63,7 @@ def test_container_removed(): stdout=subprocess.PIPE, universal_newlines=True, ).stdout + assert container.name is not None assert container.name in docker_containers_listing old_container_name = container.name