From e26858b2212f4aa6ead9cc7668115f7eea40bdff Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Sat, 12 Oct 2024 15:04:27 +0200 Subject: [PATCH] Switch formatters --- .github/CONTRIBUTING.md | 3 ++- .pre-commit-config.yaml | 6 +----- pyproject.toml | 10 ++++------ tests/test_legacy.py | 3 +-- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 89d7568..246efd5 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -132,7 +132,8 @@ But it's way more comfortable to run it locally and *git* catching avoidable err """ ``` - If you add or change public APIs, tag the docstring using `.. versionadded:: 16.0.0 WHAT` or `.. versionchanged:: 16.2.0 WHAT`. -- We use [*isort*](https://github.com/PyCQA/isort) to sort our imports, and we use [*Black*](https://github.com/psf/black) with line length of 79 characters to format our code. + +- We use [Ruff](https://ruff.rs/) to sort our imports and format our code with a line length of 79 characters. As long as you run our full [*tox*] suite before committing, or install our [*pre-commit*] hooks (ideally you'll do both – see [*Local Development Environment*](#local-development-environment) above), you won't have to spend any time on formatting your code at all. If you don't, [CI] will catch it for you – but that seems like a waste of your time! diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 49117f9..66bb17f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,16 +3,12 @@ ci: autoupdate_schedule: monthly repos: - - repo: https://github.com/psf/black - rev: 24.8.0 - hooks: - - id: black - - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.6.9 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] + - id: ruff-format - repo: https://github.com/econchick/interrogate rev: 1.7.0 diff --git a/pyproject.toml b/pyproject.toml index 631458f..f606d73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -168,12 +168,9 @@ module = "tests.*" ignore_errors = true -[tool.black] -line-length = 79 - - [tool.ruff] src = ["src", "tests", "noxfile.py"] +line-length = 79 [tool.ruff.lint] select = ["ALL"] @@ -183,13 +180,14 @@ ignore = [ "A003", # shadowing is fine "ANN", # Mypy is better at this "ARG001", # unused arguments are normal when implementing interfaces - "COM", # Black takes care of our commas + "COM", # Formatter takes care of our commas "D", # We prefer our own docstring style. - "E501", # leave line-length enforcement to Black + "E501", # leave line-length enforcement to formatter "ERA001", # Dead code detection is overly eager. "FBT", # we have one function that takes one bool; c'mon! "FIX", # Yes, we want XXX as a marker. "INP001", # sometimes we want Python files outside of packages + "ISC001", # conflicts with ruff format "PLR0913", # yes, many arguments, but most have defaults "PLR2004", # numbers are sometimes fine "PLW2901", # re-assigning within loop bodies is fine diff --git a/tests/test_legacy.py b/tests/test_legacy.py index 6cfdace..af3a947 100644 --- a/tests/test_legacy.py +++ b/tests/test_legacy.py @@ -118,8 +118,7 @@ def test_random_salt(self): assert ( # -1 for not NUL byte - int((DEFAULT_RANDOM_SALT_LENGTH << 2) / 3 + 2) - 1 - == len(salt) + int((DEFAULT_RANDOM_SALT_LENGTH << 2) / 3 + 2) - 1 == len(salt) ) def test_hash_wrong_arg_type(self):