From 445078d3cd72227f158e873f162e5ccf4b460f95 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 10 Jan 2025 15:21:10 -0500 Subject: [PATCH] chore: update to Ruff 0.9 Signed-off-by: Henry Schreiner --- .pre-commit-config.yaml | 8 ++++---- src/scikit_build_core/build/_wheelfile.py | 12 ++++++------ src/scikit_build_core/build/generate.py | 6 +++--- src/scikit_build_core/setuptools/build_cmake.py | 16 +++++++++------- src/scikit_build_core/setuptools/wrapper.py | 6 +++--- tests/test_builder.py | 2 +- 6 files changed, 26 insertions(+), 24 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c1e6d849..70c4fa48 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: exclude: "^tests" - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.6 + rev: v0.9.1 hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -130,12 +130,12 @@ repos: additional_dependencies: [cogapp] - repo: https://github.com/henryiii/validate-pyproject-schema-store - rev: 2024.11.25 + rev: 2025.01.10 hooks: - id: validate-pyproject - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.30.0 + rev: 0.31.0 hooks: - id: check-dependabot - id: check-github-workflows @@ -144,7 +144,7 @@ repos: files: \.schema\.json - repo: https://github.com/citation-file-format/cffconvert - rev: 054bda51dbe278b3e86f27c890e3f3ac877d616c + rev: b6045d78aac9e02b039703b030588d54d53262ac hooks: - id: validate-cff diff --git a/src/scikit_build_core/build/_wheelfile.py b/src/scikit_build_core/build/_wheelfile.py index 3b3740be..84fd46af 100644 --- a/src/scikit_build_core/build/_wheelfile.py +++ b/src/scikit_build_core/build/_wheelfile.py @@ -216,9 +216,9 @@ def writestr(self, zinfo_or_arcname: str | ZipInfo, data: bytes) -> None: ) zinfo.compress_type = zipfile.ZIP_DEFLATED zinfo.external_attr = (0o664 | stat.S_IFREG) << 16 - assert ( - "\\" not in zinfo.filename - ), f"\\ not supported in zip; got {zinfo.filename!r}" + assert "\\" not in zinfo.filename, ( + f"\\ not supported in zip; got {zinfo.filename!r}" + ) self._zipfile.writestr(zinfo, data) def __enter__(self) -> Self: @@ -236,9 +236,9 @@ def __exit__(self, *args: object) -> None: data = io.StringIO() writer = csv.writer(data, delimiter=",", quotechar='"', lineterminator="\n") for member in self._zipfile.infolist(): - assert ( - "\\" not in member.filename - ), f"Invalid zip contents: {member.filename}" + assert "\\" not in member.filename, ( + f"Invalid zip contents: {member.filename}" + ) with self._zipfile.open(member) as f: member_data = f.read() sha = _b64encode(hashlib.sha256(member_data).digest()).decode("ascii") diff --git a/src/scikit_build_core/build/generate.py b/src/scikit_build_core/build/generate.py index 03547f39..4d2e6c67 100644 --- a/src/scikit_build_core/build/generate.py +++ b/src/scikit_build_core/build/generate.py @@ -21,9 +21,9 @@ def generate_file_contents(gen: GenerateSettings, metadata: StandardMetadata) -> metadata. Metadata is available inside the template. """ - assert ( - gen.template_path or gen.template - ), f"One of template or template-path must be set for {gen.path}" + assert gen.template_path or gen.template, ( + f"One of template or template-path must be set for {gen.path}" + ) if gen.template_path: template = gen.template_path.read_text(encoding="utf-8") diff --git a/src/scikit_build_core/setuptools/build_cmake.py b/src/scikit_build_core/setuptools/build_cmake.py index 8f784b08..0bf75d91 100644 --- a/src/scikit_build_core/setuptools/build_cmake.py +++ b/src/scikit_build_core/setuptools/build_cmake.py @@ -34,13 +34,15 @@ def __dir__() -> list[str]: def _validate_settings(settings: ScikitBuildSettings) -> None: - assert ( - not settings.wheel.expand_macos_universal_tags - ), "wheel.expand_macos_universal_tags is not supported in setuptools mode" - assert ( - settings.logging.level == "WARNING" - ), "Logging is not adjustable in setuptools mode yet" - assert not settings.wheel.py_api, "wheel.py_api is not supported in setuptools mode, use bdist_wheel options instead" + assert not settings.wheel.expand_macos_universal_tags, ( + "wheel.expand_macos_universal_tags is not supported in setuptools mode" + ) + assert settings.logging.level == "WARNING", ( + "Logging is not adjustable in setuptools mode yet" + ) + assert not settings.wheel.py_api, ( + "wheel.py_api is not supported in setuptools mode, use bdist_wheel options instead" + ) class BuildCMake(setuptools.Command): diff --git a/src/scikit_build_core/setuptools/wrapper.py b/src/scikit_build_core/setuptools/wrapper.py index 0c0bd0d1..cec4df10 100644 --- a/src/scikit_build_core/setuptools/wrapper.py +++ b/src/scikit_build_core/setuptools/wrapper.py @@ -29,9 +29,9 @@ def setup( ) -> setuptools.Distribution: assert not cmake_install_dir, "cmake_install_dir not supported yet" assert not cmake_with_sdist, "cmake_with_sdist not supported yet" - assert ( - cmake_process_manifest_hook is None - ), "cmake_process_manifest_hook not supported yet" + assert cmake_process_manifest_hook is None, ( + "cmake_process_manifest_hook not supported yet" + ) assert cmake_install_target == "install", "cmake_install_target not supported yet" if cmake_languages is not None: diff --git a/tests/test_builder.py b/tests/test_builder.py index 890d906d..49e02748 100644 --- a/tests/test_builder.py +++ b/tests/test_builder.py @@ -172,7 +172,7 @@ def test_wheel_tag(monkeypatch, minver, archs, answer): assert plat == answer -@pytest.mark.parametrize("archs", ["x86_64" "arm64" "universal2"]) +@pytest.mark.parametrize("archs", ["x86_64", "arm64", "universal2"]) def test_wheel_build_tag(monkeypatch, archs): get_config_var = sysconfig.get_config_var monkeypatch.setattr(