diff --git a/pyproject.toml b/pyproject.toml index f4d5342f0..c3414f1bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -256,12 +256,12 @@ ignore = ["W002"] # Triggers on __init__.py's [tool.ruff] +show-fixes = true exclude = ["src/scikit_build_core/_vendor/*"] [tool.ruff.lint] select = ["ALL"] ignore = [ - "A", # Okay to shadow builtins "ANN401", # Disallow Any "C90", # Complexity "COM", # Trailing commas teach the formatter @@ -274,7 +274,6 @@ ignore = [ "PLR09", # Too many ... "PLR2004", # Magic value used in comparison "PT013", # It's correct to import classes for typing! - "RUF009", # Too easy to get a false positive (function call in dataclass defaults) "S101", # Use of assert detected "S404", # subprocess module is possibly insecure "S603", # subprocess untrusted input @@ -284,12 +283,16 @@ ignore = [ "TID252", # Relative imports are fine ] typing-modules = ["scikit_build_core._compat.typing"] +isort.known-local-folder = ["pathutils"] +flake8-bugbear.extend-immutable-calls = [ + "packaging.version.Version", + "packaging.specifiers.SpecifierSet", +] +flake8-builtins.ignorelist = ["copyright", "license", "__doc__"] [tool.ruff.format] docstring-code-format = true -[tool.ruff.lint.isort] -known-local-folder = ["pathutils"] [tool.ruff.lint.flake8-tidy-imports.banned-api] "typing.Callable".msg = "Use collections.abc.Callable instead." diff --git a/src/scikit_build_core/file_api/model/toolchains.py b/src/scikit_build_core/file_api/model/toolchains.py index 75b0732cc..a26072ea4 100644 --- a/src/scikit_build_core/file_api/model/toolchains.py +++ b/src/scikit_build_core/file_api/model/toolchains.py @@ -38,5 +38,5 @@ class Toolchain: @dataclasses.dataclass(frozen=True) class Toolchains: kind: str = "toolchains" - version: APIVersion = APIVersion(1, 0) + version: APIVersion = APIVersion(1, 0) # noqa: RUF009 toolchains: List[Toolchain] = dataclasses.field(default_factory=list) diff --git a/src/scikit_build_core/resources/_editable_redirect.py b/src/scikit_build_core/resources/_editable_redirect.py index 677f37ac8..cffdaf999 100644 --- a/src/scikit_build_core/resources/_editable_redirect.py +++ b/src/scikit_build_core/resources/_editable_redirect.py @@ -87,7 +87,7 @@ def __init__( verbose: bool, build_options: list[str], install_options: list[str], - dir: str, + dir: str, # noqa: A002 install_dir: str, ) -> None: self.known_source_files = known_source_files diff --git a/tests/test_dynamic_metadata_unit.py b/tests/test_dynamic_metadata_unit.py index 2b45bfd0b..ee97e0936 100644 --- a/tests/test_dynamic_metadata_unit.py +++ b/tests/test_dynamic_metadata_unit.py @@ -72,7 +72,7 @@ def test_regex() -> None: @pytest.mark.parametrize( - ("field", "input", "output"), + ("field", "input_", "output"), [ pytest.param("version", "{sub}", "42", id="str"), pytest.param("classifiers", ["a", "{sub}"], ["a", "42"], id="list-str"), @@ -100,6 +100,6 @@ def test_regex() -> None: ), ], ) -def test_actions(field: str, input: Any, output: Any) -> None: - result = _process_dynamic_metadata(field, lambda x: x.format(sub=42), input) +def test_actions(field: str, input_: Any, output: Any) -> None: + result = _process_dynamic_metadata(field, lambda x: x.format(sub=42), input_) assert output == result diff --git a/tests/test_file_processor.py b/tests/test_file_processor.py index 48701c6a2..f29757e75 100644 --- a/tests/test_file_processor.py +++ b/tests/test_file_processor.py @@ -76,17 +76,17 @@ def test_on_each_with_symlink(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) - gitignore = Path(".gitignore") gitignore.write_text("/hidden_dir") # Create a directory with a symlink to a file in the same directory - dir = Path("dir") - dir.mkdir() - file1 = dir / "file" + pkg_dir = Path("pkg") + pkg_dir.mkdir() + file1 = pkg_dir / "file" file1.write_text("content") - file2 = dir / "link" + file2 = pkg_dir / "link" file2.symlink_to("file") hidden_dir = Path("hidden_dir") hidden_dir.mkdir() hidden_file = hidden_dir / "file2" hidden_file.write_text("content2") - exposed_symlink = dir / "exposed_symlink" + exposed_symlink = pkg_dir / "exposed_symlink" exposed_symlink.symlink_to("../hidden_dir") local_ignored_file = Path("local_ignored_file.txt") diff --git a/tests/test_pyproject_pep517.py b/tests/test_pyproject_pep517.py index 4d9325800..c7b730c90 100644 --- a/tests/test_pyproject_pep517.py +++ b/tests/test_pyproject_pep517.py @@ -89,8 +89,8 @@ def test_pep517_sdist_hash(monkeypatch, package_simple_pyproject_ext, tmp_path: dist = tmp_path / "dist" out = build_sdist(str(dist)) sdist = dist / out - hash = compute_uncompressed_hash(sdist) - assert hash == package_simple_pyproject_ext.sdist_hash + sdist_hash = compute_uncompressed_hash(sdist) + assert sdist_hash == package_simple_pyproject_ext.sdist_hash mode = sdist.stat().st_mode assert mode == 33188 with gzip.open(sdist, "rb") as f: @@ -160,8 +160,8 @@ def each_unignored_file_ordered(*args, **kwargs): out = build_sdist(str(dist), {"sdist.reproducible": "true"}) sdist = dist / out - hash = compute_uncompressed_hash(sdist) - assert hash == package_simple_pyproject_ext.sdist_dated_hash + sdist_hash = compute_uncompressed_hash(sdist) + assert sdist_hash == package_simple_pyproject_ext.sdist_dated_hash @pytest.mark.compile diff --git a/tests/test_pyproject_pep518.py b/tests/test_pyproject_pep518.py index 831087cc1..91d551fe8 100644 --- a/tests/test_pyproject_pep518.py +++ b/tests/test_pyproject_pep518.py @@ -45,8 +45,8 @@ def test_pep518_sdist(isolated, package_simple_pyproject_ext, tmp_path: Path): assert sdist.name == "cmake_example-0.0.1.tar.gz" if not sys.platform.startswith(("win", "cygwin")): - hash = compute_uncompressed_hash(sdist) - assert hash == package_simple_pyproject_ext.sdist_hash + sdist_hash = compute_uncompressed_hash(sdist) + assert sdist_hash == package_simple_pyproject_ext.sdist_hash with tarfile.open(sdist) as f: file_names = set(f.getnames()) diff --git a/tests/test_settings_overrides.py b/tests/test_settings_overrides.py index 098414a52..326ef036b 100644 --- a/tests/test_settings_overrides.py +++ b/tests/test_settings_overrides.py @@ -446,14 +446,14 @@ def test_skbuild_env_negative_bool( @pytest.mark.parametrize("foo", ["true", "false"]) @pytest.mark.parametrize("bar", ["true", "false"]) -@pytest.mark.parametrize("any", [True, False]) +@pytest.mark.parametrize("use_any", [True, False]) def test_skbuild_env_bool_all_any( - foo: str, bar: str, any: bool, tmp_path: Path, monkeypatch: pytest.MonkeyPatch + foo: str, bar: str, use_any: bool, tmp_path: Path, monkeypatch: pytest.MonkeyPatch ): monkeypatch.setenv("FOO", foo) monkeypatch.setenv("BAR", bar) - any_str = ".any" if any else "" + any_str = ".any" if use_any else "" pyproject_toml = tmp_path / "pyproject.toml" pyproject_toml.write_text( dedent( @@ -470,7 +470,9 @@ def test_skbuild_env_bool_all_any( settings_reader = SettingsReader.from_file(pyproject_toml) settings = settings_reader.settings - if (foo == "true" and bar == "true") or (any and (foo == "true" or bar == "true")): + if (foo == "true" and bar == "true") or ( + use_any and (foo == "true" or bar == "true") + ): assert settings.sdist.cmake else: assert not settings.sdist.cmake