Skip to content

Commit

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

Expand Down
6 changes: 1 addition & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand 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
Expand Down
3 changes: 1 addition & 2 deletions tests/test_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit e26858b

Please sign in to comment.