diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 21d8ad2..0046708 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -137,8 +137,10 @@ But it's way more comfortable to run it locally and catch avoidable errors befor A very important return value. """ ``` + - If you add or change public APIs, tag the docstring using `.. versionadded:: 16.0.0 WHAT` or `.. versionchanged:: 16.2.0 WHAT`. -- We use [Ruff](https://ruff.rs/) to sort our imports, and we use [Black](https://github.com/psf/black) with line length of 79 characters to format our code. + +- We follow [PEP 8](https://peps.python.org/pep-0008/) as enforced by [Ruff](https://ruff.rs/) 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 af49cad..da4a094 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,15 +1,11 @@ --- repos: - - repo: https://github.com/psf/black - rev: 24.4.2 - hooks: - - id: black - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.4 + rev: v0.7.1 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] + - id: ruff-format - repo: https://github.com/codespell-project/codespell rev: v2.3.0 @@ -24,7 +20,7 @@ repos: args: [tests] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer diff --git a/pyproject.toml b/pyproject.toml index ed6c4c1..e143d33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -132,12 +132,9 @@ fail-under = 100 whitelist-regex = ["test_.*"] -[tool.black] -line-length = 79 - - [tool.ruff] src = ["src", "tests"] +line-length = 79 [tool.ruff.lint] select = ["ALL"] @@ -146,11 +143,12 @@ ignore = [ "ANN", # Mypy is better at this "ARG001", # we don't control all args passed in "ARG005", # we need stub lambdas - "COM", # Black takes care of our commas + "COM", # ruff format 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 ruff format "FIX", # Yes, we want XXX as a marker. "INP001", # sometimes we want Python files outside of packages + "ISC001", # conflicts with ruff format "N801", # some artistic freedom when naming things after RFCs "N802", # ditto "PLR2004", # numbers are sometimes fine @@ -183,6 +181,7 @@ lines-after-imports = 2 [tool.mypy] strict = true +pretty = true show_error_codes = true enable_error_code = ["ignore-without-code"]