Skip to content

Commit

Permalink
Switch formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Oct 25, 2024
1 parent a7fe7b3 commit 2c506f4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down
10 changes: 3 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
11 changes: 5 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand 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
Expand Down Expand Up @@ -183,6 +181,7 @@ lines-after-imports = 2

[tool.mypy]
strict = true
pretty = true

show_error_codes = true
enable_error_code = ["ignore-without-code"]
Expand Down

0 comments on commit 2c506f4

Please sign in to comment.