diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 81085fac..7e95ca2f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,14 +18,14 @@ repos: exclude: ^cibuildwheel/resources/android/android.patch$ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: c59bba8fb259db0fec2bbb77ad8ba51ea7341b56 # frozen: v0.15.20 + rev: 39d9ac5938dadb73df0564a45f163e25ff9fa6e2 # frozen: v0.16.1 hooks: - id: ruff-check args: ["--fix"] - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: d2823d321df3af8f878f7ee3414dc94d037145b9 # frozen: v2.1.0 + rev: 41e691678310dfd3833f7ab4e180ddb014310356 # frozen: v2.3.0 hooks: - id: mypy name: mypy 3.11 on cibuildwheel/ @@ -85,7 +85,7 @@ repos: exclude: "^cibuildwheel/resources/" - repo: https://github.com/codespell-project/codespell - rev: 2ccb47ff45ad361a21071a7eedda4c37e6ae8c5a # frozen: v2.4.2 + rev: 57b21406f092110c18776e39b0bda50d37c945c8 # frozen: v2.4.3 hooks: - id: codespell args: ["-w"] diff --git a/bin/inspect_all_known_projects.py b/bin/inspect_all_known_projects.py index f328c09f..d0ebec92 100755 --- a/bin/inspect_all_known_projects.py +++ b/bin/inspect_all_known_projects.py @@ -49,7 +49,7 @@ def parse(contents: str) -> str | None: analyzer = Analyzer() analyzer.visit(tree) return analyzer.requires_python or "" - except Exception: + except Exception: # noqa: BLE001 return None diff --git a/cibuildwheel/extra.py b/cibuildwheel/extra.py index 9b1abcb1..7dfbe594 100644 --- a/cibuildwheel/extra.py +++ b/cibuildwheel/extra.py @@ -83,7 +83,7 @@ def github_api_request(path: str, *, max_retries: int = 3) -> dict[str, Any]: if retry_count == max_retries - 1: print(f"GitHub API request failed (Network error: {e}). Check network connection.") - raise e + raise # Should never be reached but to keep the type checker happy msg = "Unexpected execution path in github_api_request" diff --git a/cibuildwheel/projectfiles.py b/cibuildwheel/projectfiles.py index ecc6a213..c45d7fa4 100644 --- a/cibuildwheel/projectfiles.py +++ b/cibuildwheel/projectfiles.py @@ -68,7 +68,7 @@ def setup_py_python_requires(content: str) -> str | None: analyzer = Analyzer() analyzer.visit(tree) return analyzer.requires_python or None - except Exception: # pylint: disable=broad-except + except Exception: # noqa: BLE001 return None diff --git a/cibuildwheel/util/file.py b/cibuildwheel/util/file.py index 951fdf3f..a21c290f 100644 --- a/cibuildwheel/util/file.py +++ b/cibuildwheel/util/file.py @@ -53,7 +53,7 @@ def remove_on_error(path: Path) -> Generator[None, None, None]: shutil.rmtree(path) elif path.exists() or path.is_symlink(): path.unlink() - except BaseException as cleanup_exception: + except BaseException as cleanup_exception: # noqa: BLE001 msg = f"Failed to remove {path}. Please remove it manually." raise BaseExceptionGroup(msg, [original_exception, cleanup_exception]) from None raise diff --git a/pyproject.toml b/pyproject.toml index 1d22cc47..69e771db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -166,6 +166,7 @@ messages_control.disable = [ "wrong-import-position", "unused-argument", # Handled by Ruff "import-outside-toplevel", # Handled by Ruff + "broad-exception-caught", # Handled by Ruff "broad-exception-raised", # Could be improved eventually "consider-using-in", # MyPy can't narrow "in" ] @@ -217,6 +218,7 @@ ignore = [ "PT007", # Lists of tuples in Pytest "PYI025", # Set as AbstractSet "PTH123", # open -> Path.open + "TRY002", # Create your own exception ] flake8-unused-arguments.ignore-variadic-names = true flake8-tidy-imports.ban-relative-imports = "all" @@ -234,7 +236,7 @@ future-annotations = true [tool.ruff.lint.per-file-ignores] "unit_test/*" = ["PLC1901", "TID252"] -"test/*" = ["TID252"] +"test/*" = ["TID252", "N999"] "bin/*" = ["TID251"] "cibuildwheel/resources/install_certifi.py" = ["PTH"]