Skip to content

Commit a00f1f7

Browse files
committed
Use ruff for linting and error checking
Ruff integrating flake8, many of its plugins and isort all into a single program. It's substantially faster, can auto-fix some types of errors, and allows enabling additional checks in future. Needs: #48
1 parent 0421d7e commit a00f1f7

File tree

4 files changed

+21
-40
lines changed

4 files changed

+21
-40
lines changed

.github/workflows/linting.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,8 @@ jobs:
77
- uses: actions/checkout@v2
88
- uses: actions/setup-python@v2
99
- uses: psf/black@stable
10-
isort:
10+
ruff:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v2
14-
- uses: actions/setup-python@v2
15-
- uses: jamescurtin/isort-action@master
16-
with:
17-
configuration: --check-only
18-
flake8:
19-
runs-on: ubuntu-latest
20-
steps:
21-
- uses: actions/checkout@v2
22-
- uses: actions/setup-python@v2
23-
- name: Install dependencies
24-
run: pip install flake8 flake8-pyproject
25-
- name: Run flake8
26-
run: flake8 .
14+
- uses: chartboost/ruff-action@v1

.pre-commit-config.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@ repos:
33
rev: 23.1.0
44
hooks:
55
- id: black
6-
- repo: https://github.com/PyCQA/isort
7-
rev: 5.12.0
6+
- repo: https://github.com/astral-sh/ruff-pre-commit
7+
rev: v0.0.291
88
hooks:
9-
- id: isort
10-
- repo: https://github.com/pycqa/flake8
11-
rev: 6.0.0
12-
hooks:
13-
- id: flake8
14-
additional_dependencies:
15-
- flake8-pyproject
9+
- id: ruff
10+
args: [--fix, --exit-non-zero-on-fix]

pyproject.toml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,17 @@
7979
minversion = "6.0"
8080
testpaths = ["tests"]
8181

82-
[tool.flake8]
83-
ignore = [
84-
"D1", # Missing docstrings
85-
"E203", # whitespace before ':' in slice (incompatible with black)
86-
"E731", # Allow lambdas
87-
"F405", # name undefined due to star imports
88-
"W503", # line break before binary operator (incompatible with black)
89-
]
90-
max-line-length = 99
91-
92-
[tool.isort]
93-
known_first_party = "sphinxcontrib_django"
94-
# Approach Black compatibility (just run black after isort)
95-
include_trailing_comma = true
96-
line_length = 88
97-
multi_line_output = 3
82+
[tool.ruff]
83+
select = [
84+
"F",
85+
"E",
86+
"W",
87+
"I",
88+
# "D",
89+
"RET",
90+
"SIM",
91+
]
92+
ignore = [
93+
"D1", # Missing docstrings
94+
]
95+
line-length = 99

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def do_autodoc():
5353
"""
5454
This function simulates the autodoc functionality.
5555
56-
Taken from https://github.com/sphinx-doc/sphinx/blob/d635d94eebbca0ebb1a5402aa07ed58c0464c6d3/tests/test_ext_autodoc.py#L33-L45 # noqa: E501
56+
Taken from https://github.com/sphinx-doc/sphinx/blob/d635d94eebbca0ebb1a5402aa07ed58c0464c6d3/tests/test_ext_autodoc.py#L33-L45
5757
"""
5858

5959
def do_autodoc(app, objtype, name, options=None):

0 commit comments

Comments
 (0)