diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2af19ac42..7cbb2a370 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,6 +21,13 @@ repos: - id: trailing-whitespace exclude: "^tests" + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.2 + hooks: + - id: ruff-format + - id: ruff + args: ["--fix", "--show-fixes"] + - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.10.0 hooks: @@ -28,11 +35,6 @@ repos: - id: rst-directive-colons - id: rst-inline-touching-normal - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.10.0 - hooks: - - id: black-jupyter - - repo: https://github.com/asottile/blacken-docs rev: 1.16.0 hooks: @@ -53,12 +55,6 @@ repos: args: [--prose-wrap=always] exclude: "^tests|src/scikit_build_core/resources/scikit-build.schema.json" - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.1 - hooks: - - id: ruff - args: ["--fix", "--show-fixes"] - - repo: https://github.com/pre-commit/mirrors-mypy rev: v1.6.1 hooks: diff --git a/README.md b/README.md index 86301782f..a1c9dc21c 100644 --- a/README.md +++ b/README.md @@ -309,8 +309,6 @@ Support for this work was provided by NSF cooperative agreement [OAC-2209877][]. [actions-badge]: https://github.com/scikit-build/scikit-build-core/workflows/CI/badge.svg [actions-link]: https://github.com/scikit-build/scikit-build-core/actions -[black-badge]: https://img.shields.io/badge/code%20style-black-000000.svg -[black-link]: https://github.com/psf/black [conda-badge]: https://img.shields.io/conda/vn/conda-forge/scikit-build-core [conda-link]: https://github.com/conda-forge/scikit-build-core-feedstock [github-discussions-badge]: https://img.shields.io/static/v1?label=Discussions&message=Ask&color=blue&logo=github diff --git a/noxfile.py b/noxfile.py index bb5bb1603..9d79c5990 100644 --- a/noxfile.py +++ b/noxfile.py @@ -77,10 +77,12 @@ def generate_schema(session: nox.Session) -> None: (Re)generate src/scikit_build_core/resources/scikit-build.schema.json from model. """ session.install("-e.") - schema = session.run( + schema_txt = session.run( "python", "-m", "scikit_build_core.settings.skbuild_schema", silent=True ) - DIR.joinpath("src/scikit_build_core/resources/scikit-build.schema.json").write_text(schema) # type: ignore[arg-type] + assert isinstance(schema_txt, str) + schema_file = DIR / "src/scikit_build_core/resources/scikit-build.schema.json" + schema_file.write_text(schema_txt) @nox.session diff --git a/pyproject.toml b/pyproject.toml index ebd2b2d2a..1f970cb82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -201,8 +201,12 @@ report.exclude_lines = [ [tool.check-wheel-contents] ignore = ["W002"] # Triggers on __init__.py's - [tool.ruff] +typing-modules = ["scikit_build_core._compat.typing"] +src = ["src"] +exclude = [] + +[tool.ruff.lint] select = [ "E", "F", "W", # flake8 "B", # flake8-bugbear @@ -231,6 +235,7 @@ select = [ "FLY", # flynt "TRY", # tryceratops "FBT", # flake8-boolean-trap + "PYI", # flake8-pyi ] extend-ignore = [ "PLR", # Design rules for pylint @@ -238,13 +243,11 @@ extend-ignore = [ "E501", # Line too long "PT004", # Incorrect, just usefixtures instead. "RUF009", # Too easy to get a false positive + "PYI025", # Wants Set to be renamed AbstractSet ] -typing-modules = ["scikit_build_core._compat.typing"] -src = ["src"] unfixable = ["T20", "F841"] -exclude = [] -[tool.ruff.flake8-tidy-imports.banned-api] +[tool.ruff.lint.flake8-tidy-imports.banned-api] "typing.Callable".msg = "Use collections.abc.Callable instead." "typing.Iterator".msg = "Use collections.abc.Iterator instead." "typing.Mapping".msg = "Use collections.abc.Mapping instead." @@ -268,7 +271,7 @@ exclude = [] "importlib_resources".msg = "Use scikit_build_core._compat.importlib.resources instead." -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "tests/**" = ["T20"] "noxfile.py" = ["T20", "TID251"] "src/scikit_build_core/resources/*.py" = ["PTH", "ARG002", "FBT", "TID251"] diff --git a/src/scikit_build_core/_version.pyi b/src/scikit_build_core/_version.pyi index 23e6eab08..d05fd88a8 100644 --- a/src/scikit_build_core/_version.pyi +++ b/src/scikit_build_core/_version.pyi @@ -1,5 +1,3 @@ -from __future__ import annotations - version: str version_tuple: tuple[int, int, int, str, str] | tuple[int, int, int] diff --git a/src/scikit_build_core/settings/documentation.py b/src/scikit_build_core/settings/documentation.py index 42b30c97d..b978903dd 100644 --- a/src/scikit_build_core/settings/documentation.py +++ b/src/scikit_build_core/settings/documentation.py @@ -40,7 +40,9 @@ def pull_docs(dc: type[object]) -> dict[str, str]: assert isinstance(obody, ast.ClassDef) body = obody.body return { - assign.target.id: textwrap.dedent(_get_value(expr.value)).strip().replace("\n", " ") # type: ignore[union-attr] + assign.target.id: textwrap.dedent(_get_value(expr.value)) # type: ignore[union-attr] + .strip() + .replace("\n", " ") for assign, expr in zip(body[:-1], body[1:]) if isinstance(assign, ast.AnnAssign) and isinstance(expr, ast.Expr) } diff --git a/src/scikit_build_core/settings/sources.py b/src/scikit_build_core/settings/sources.py index cdeca8f4f..19e9856a4 100644 --- a/src/scikit_build_core/settings/sources.py +++ b/src/scikit_build_core/settings/sources.py @@ -203,7 +203,9 @@ def has_item(self, *fields: str, is_dict: bool) -> bool: # noqa: ARG002 return bool(self.env.get(name, "")) def get_item( - self, *fields: str, is_dict: bool # noqa: ARG002 + self, + *fields: str, + is_dict: bool, # noqa: ARG002 ) -> str | dict[str, str]: name = self._get_name(*fields) if name in self.env: @@ -243,7 +245,8 @@ def convert(cls, item: str, target: type[Any]) -> object: raise TypeError(msg) def unrecognized_options( - self, options: object # noqa: ARG002 + self, + options: object, # noqa: ARG002 ) -> Generator[str, None, None]: yield from () diff --git a/src/scikit_build_core/setuptools/build_cmake.py b/src/scikit_build_core/setuptools/build_cmake.py index 9fe9c8bd7..a663f6458 100644 --- a/src/scikit_build_core/setuptools/build_cmake.py +++ b/src/scikit_build_core/setuptools/build_cmake.py @@ -35,9 +35,7 @@ def _validate_settings() -> None: 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.py_api, "wheel.py_api is not supported in setuptools mode, use bdist_wheel options instead" class BuildCMake(setuptools.Command):