diff --git a/{{cookiecutter.project_distribution_name}}/.github/workflows/ci.yml b/{{cookiecutter.project_distribution_name}}/.github/workflows/ci.yml index 2fcb65d..38119fa 100644 --- a/{{cookiecutter.project_distribution_name}}/.github/workflows/ci.yml +++ b/{{cookiecutter.project_distribution_name}}/.github/workflows/ci.yml @@ -9,7 +9,6 @@ on: env: FORCE_COLOR: 1 - CLICOLOR_FORCE: 1 # https://github.com/astral-sh/ruff/issues/5499 PRE_COMMIT_COLOR: "always" # https://github.com/pre-commit/pre-commit/issues/2918 jobs: diff --git a/{{cookiecutter.project_distribution_name}}/.pre-commit-config.yaml b/{{cookiecutter.project_distribution_name}}/.pre-commit-config.yaml index 1d35cbc..2ec7b86 100644 --- a/{{cookiecutter.project_distribution_name}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_distribution_name}}/.pre-commit-config.yaml @@ -1,13 +1,15 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: 'v0.0.272' + # Ruff version. + rev: 'v0.5.0' hooks: + # Run the linter. - id: ruff - args: [ --fix, --exit-non-zero-on-fix ] -- repo: https://github.com/psf/black - rev: '23.3.0' - hooks: - - id: black + types_or: [ python, pyi, jupyter ] + args: [ --fix ] + # Run the formatter. + - id: ruff-format + types_or: [ python, pyi, jupyter ] - repo: https://github.com/python-poetry/poetry rev: '1.5.1' hooks: diff --git a/{{cookiecutter.project_distribution_name}}/docs/CONTRIBUTING.md b/{{cookiecutter.project_distribution_name}}/docs/CONTRIBUTING.md index d32ed62..e6440ab 100644 --- a/{{cookiecutter.project_distribution_name}}/docs/CONTRIBUTING.md +++ b/{{cookiecutter.project_distribution_name}}/docs/CONTRIBUTING.md @@ -229,7 +229,7 @@ It can be run on demand with `pre-commit run`, and optionally on all files with ### Lint -This repository uses [Ruff](https://beta.ruff.rs/docs) for linting and [black](https://black.readthedocs.io) for formatting. black formatting will be automatically verified and fixed. +This repository uses [Ruff](https://beta.ruff.rs/docs) for linting and formatting. **Tips**: - [Set up your editor](#set-up-your-editor) to see linting errors directly in your editor and automatically fix them on save. diff --git a/{{cookiecutter.project_distribution_name}}/docs/README.md b/{{cookiecutter.project_distribution_name}}/docs/README.md index 934019a..8251fbf 100644 --- a/{{cookiecutter.project_distribution_name}}/docs/README.md +++ b/{{cookiecutter.project_distribution_name}}/docs/README.md @@ -11,7 +11,7 @@ | ![Build][label-build] | [![Nox][badge-actions]][actions] [![semantic-release][badge-semantic-release]][semantic-release] [![PyPI][badge-pypi]][pypi] [![Read the Docs][badge-docs]][docs] | | ![Tests][label-tests] | [![coverage][badge-coverage]][coverage] [![pre-commit][badge-pre-commit]][pre-commit] [![asv][badge-asv]][asv] | | ![Standards][label-standards] | [![SemVer 2.0.0][badge-semver]][semver] [![Conventional Commits][badge-conventional-commits]][conventional-commits] | - | ![Code][label-code] | [![Poetry][badge-poetry]][poetry] [![Code style: black][badge-black]][Black] [![Ruff][badge-ruff]][ruff] [![Checked with mypy][badge-mypy]][mypy] | + | ![Code][label-code] | [![Poetry][badge-poetry]][poetry] [![Ruff][badge-ruff]][ruff] [![Checked with mypy][badge-mypy]][mypy] | | ![Repo][label-repo] | [![GitHub issues][badge-issues]][issues] [![GitHub stars][badge-stars]][stars] [![GitHub license][badge-license]][license] [![All Contributors][badge-all-contributors]][contributors] [![Contributor Covenant][badge-code-of-conduct]][code-of-conduct] | @@ -56,9 +56,7 @@ [badge-poetry]: {{cookiecutter.shields_url}}/endpoint?url=https://python-poetry.org/badge/v0.json&style=flat-square [poetry]: https://python-poetry.org -[badge-black]: {{ cookiecutter.shields_url }}/badge/code%20style-black-black?style=flat-square -[Black]: https://github.com/psf/black -[badge-ruff]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&style=flat-square +[badge-ruff]: {{cookiecutter.shields_url}}/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&style=flat-square [ruff]: https://github.com/astral-sh/ruff [badge-mypy]: {{ cookiecutter.shields_url }}/badge/mypy-checked-2A6DB2?style=flat-square [mypy]: http://mypy-lang.org diff --git a/{{cookiecutter.project_distribution_name}}/docs/reference.md b/{{cookiecutter.project_distribution_name}}/docs/reference.md index e5cad45..de13456 100644 --- a/{{cookiecutter.project_distribution_name}}/docs/reference.md +++ b/{{cookiecutter.project_distribution_name}}/docs/reference.md @@ -2,8 +2,6 @@ - Tools - Formatting - - [Black][black] [config][pyproject_toml] - - [Compatible configs][black_cc] - [Ruff][ruff] [config][pyproject_toml] - Linting - [Ruff][ruff] [config][pyproject_toml] @@ -13,7 +11,6 @@ Hooks - [`ruff`][ruff] - - [`black`][black] - [`poetry`][poetry] - `poetry-check` - `poetry-lock` @@ -88,8 +85,6 @@ [docs_wordlist_txt]: ./wordlist.txt [noxfile_py]: ../noxfile.py -[black]: https://github.com/psf/black -[black_cc]: https://black.readthedocs.io/en/stable/compatible_configs.html [ruff]: https://github.com/astral-sh/ruff [pre-commit]: https://github.com/pre-commit/pre-commit [pre-commit-hooks]: https://github.com/pre-commit/pre-commit-hooks diff --git a/{{cookiecutter.project_distribution_name}}/noxfile.py b/{{cookiecutter.project_distribution_name}}/noxfile.py index fd9caa6..de068c2 100644 --- a/{{cookiecutter.project_distribution_name}}/noxfile.py +++ b/{{cookiecutter.project_distribution_name}}/noxfile.py @@ -1,6 +1,11 @@ """Nox file for automation.""" -from typing import Iterable, Optional +from __future__ import annotations + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from collections.abc import Iterable import nox @@ -13,7 +18,7 @@ def install( *, groups: Iterable[str], root: bool = True, - only: Optional[bool] = None, + only: bool | None = None, extras: bool = False, ) -> None: """Install the dependency groups using Poetry.""" @@ -57,8 +62,8 @@ def lint_files(session: nox.Session) -> None: @nox.session(python=python_versions[-1], venv_params=venv_params) def format_files(session: nox.Session) -> None: """Format files.""" - install(session, groups=["formatting"], root=False) - session.run("black", ".") + install(session, groups=["linting"], root=False) + session.run("ruff", "format") @nox.session(python=python_versions, venv_params=venv_params) diff --git a/{{cookiecutter.project_distribution_name}}/pyproject.toml b/{{cookiecutter.project_distribution_name}}/pyproject.toml index 61d08fc..e208a31 100644 --- a/{{cookiecutter.project_distribution_name}}/pyproject.toml +++ b/{{cookiecutter.project_distribution_name}}/pyproject.toml @@ -51,10 +51,7 @@ pytest = "^7.4.0" pytest-benchmark = "^4.0.0" [tool.poetry.group.linting.dependencies] -ruff = "^0.0.275" - -[tool.poetry.group.formatting.dependencies] -black = "^23.3.0" +ruff = "^0.5.0" [tool.poetry.group.pre-commit.dependencies] pre-commit = "^3.3.3" @@ -70,36 +67,29 @@ python-semantic-release = "^8.0.2" [tool.ruff] # https://beta.ruff.rs/docs/rules line-length = 88 # Default +force-exclude = true +src = ["src"] +target-version = "py38" + +[tool.ruff.lint] select = ["ALL"] ignore = [ "D203", "D213", - "ANN101", - "ANN102", ] unfixable = ["ERA001"] -force-exclude = true -src = ["src"] -target-version = "py38" -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "tests/*" = ["S101"] -[tool.ruff.flake8-builtins] +[tool.ruff.lint.flake8-builtins] builtins-ignorelist = ["id", "type"] -[tool.ruff.pydocstyle] +[tool.ruff.lint.pydocstyle] convention = "google" -[tool.black] -line-length = 88 # Default -include = '\.pyi?$' -extend-exclude = ''' -/( - \.git - | _build -)/ -''' +[tool.ruff.format] +docstring-code-format = true [tool.mypy] files = ["src", "docs", "tests", "noxfile.py"]