Skip to content

Commit 8b84823

Browse files
committed
πŸ‘Œ Template: switch to Ruff hook from repo for pre-commit
Use the Ruff pre-commit hook from the astral repository, instead of a `local` repo relying on Hatch. Hatch uses Ruff under the hood anyways, and we don't want contributors to have to install Hatch. Moreover, using a locally installed Hatch instance has shown to not always be robust or deterministic in the past, especially in CI. Some of the `ignore` rules might not make sense at this point, since Ruff does not `select` them by default. But we keep them and their rationale for now, since we may introduce their classifier in the future. `ruff check --fix` can change code semantics/structure (e.g., remove unused imports, reorder/simplify, apply pyupgrade-like fixes). These edits often need reformatting afterwards. Hence, we switch the order of the pre-commit to run the linter first.
1 parent ac840bd commit 8b84823

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
repos:
2-
- repo: local
3-
hooks:
4-
- id: format
5-
name: Format with Ruff
6-
entry: hatch fmt -f
7-
language: system
8-
types: [python]
9-
- id: lint
10-
name: Lint with Ruff
11-
entry: hatch fmt -l
12-
language: system
13-
types: [python]
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.13.2
4+
hooks:
5+
- id: ruff-check
6+
name: Lint with Ruff
7+
types_or: [ python, pyi ]
8+
args: [ --fix ]
9+
- id: ruff-format
10+
name: Format with Ruff
11+
types_or: [ python, pyi ]

β€Žtemplate/tests/conftest.pyβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
Docs: https://docs.pytest.org/en/stable/how-to/fixtures.html#conftest-py-sharing-fixtures-across-multiple-files
44
"""
5+
56
import pytest
67

78

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
21
def test_example(readability_counts):
32
assert readability_counts is True

0 commit comments

Comments
Β (0)