Skip to content

Commit 3034577

Browse files
authored
Switch to ruff for linting (#261)
* Switch to Ruff for linting * Remove flak8, pep8, isort, prospector config Use ruff instead
1 parent 9bc493b commit 3034577

File tree

6 files changed

+48
-174
lines changed

6 files changed

+48
-174
lines changed

.ruff.toml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# https://docs.astral.sh/ruff/configuration/
2+
extend-include = ["*.ipynb"]
3+
4+
exclude = [
5+
"manage.py",
6+
"docs",
7+
"settings/",
8+
"common/",
9+
"readthedocs/rtd_tests/",
10+
"readthedocs/templates/",
11+
"**/tests/*.py",
12+
"**/test_*.py",
13+
"**/tests.py",
14+
"**/conftest.py",
15+
]
16+
17+
# Same as Black.
18+
line-length = 100
19+
indent-width = 4
20+
21+
# Assume Python 3.12
22+
target-version = "py312"
23+
24+
[lint]
25+
# Enable:
26+
# Pyflakes (`F`)
27+
# pycodestyle (`E`) error codes.
28+
# isort (`I`) import sorting
29+
select = ["E4", "E7", "E9", "F", "I"]
30+
31+
[lint.isort]
32+
# https://docs.astral.sh/ruff/settings/#lintisort
33+
force-single-line = true
34+
case-sensitive = false
35+
lines-after-imports = 2
36+
37+
# https://docs.astral.sh/ruff/settings/#lint_isort_known-first-party
38+
known-first-party = ["readthedocs", "readthedocsinc", "readthedocsext"]

flake8

Lines changed: 0 additions & 3 deletions
This file was deleted.

isort.cfg

Lines changed: 0 additions & 19 deletions
This file was deleted.

pep8

Lines changed: 0 additions & 3 deletions
This file was deleted.

pre-commit-config.yaml

Lines changed: 10 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -38,81 +38,29 @@ repos:
3838
- id: mixed-line-ending
3939
args: ['--fix=lf']
4040

41-
- repo: https://github.com/PyCQA/autoflake
42-
rev: v2.2.0
43-
hooks:
44-
- id: autoflake
45-
args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variable']
46-
47-
# TODO: re-enable it and use `--range` to select the modified lines
48-
# - repo: https://github.com/myint/docformatter.git
49-
# rev: v1.4
50-
# hooks:
51-
# - id: docformatter
52-
# args: ['--in-place', '--wrap-summaries=80', '--wrap-descriptions=80', '--pre-summary-newline']
53-
5441
- repo: https://github.com/adamchainz/django-upgrade
5542
rev: "1.14.1"
5643
hooks:
5744
- id: django-upgrade
5845
args: [--target-version, "4.2"]
5946

60-
- repo: https://github.com/psf/black
61-
rev: 23.7.0
62-
hooks:
63-
- id: black
64-
# It is recommended to specify the latest version of Python
65-
# supported by your project here, or alternatively use
66-
# pre-commit's default_language_version, see
67-
# https://pre-commit.com/#top_level-default_language_version
68-
language_version: python3.10
69-
exclude: |
70-
(?x)^(
71-
readthedocs/rtd_tests/files/conf.py|
72-
.*/migrations/.*
73-
)$
74-
75-
# NOTE: run `isort` after `black` to keep the format of isort finally
76-
- repo: https://github.com/pycqa/isort
77-
rev: 5.12.0
78-
hooks:
79-
- id: isort
80-
name: isort (python)
81-
exclude: |
82-
(?x)^(
83-
.*/migrations/.*
84-
)
85-
8647
- repo: https://github.com/asottile/blacken-docs
8748
rev: 1.16.0
8849
hooks:
8950
- id: blacken-docs
9051
additional_dependencies: [black==23.7.0]
9152

92-
- repo: https://github.com/PyCQA/prospector
93-
rev: 1.10.2
94-
hooks:
95-
- id: prospector
96-
args:
97-
- --profile=prospector.yml
98-
- --die-on-tool-error
99-
exclude: |
100-
(?x)^(
101-
docs/.*|
102-
common/.*|
103-
.*/settings/.*|
104-
.*/rtd_tests/.*|
105-
.*/tests/.*|
106-
.*/migrations/.*
107-
)$
108-
# This PYTHONPATH environment variable is required for readthedocs-corporate when running `tox -e pre-commit`
109-
entry: env PYTHONPATH=readthedocs:../readthedocs.org:./ DJANGO_SETTINGS_MODULE=readthedocs.settings.test prospector
110-
# We have to install the dependencies from an URL since we don't have access to this file easily from pre-commit
111-
additional_dependencies:
112-
- -r
113-
- https://raw.githubusercontent.com/readthedocs/readthedocs.org/main/requirements/testing.txt
114-
11553
- repo: https://github.com/aspiredu/django-safemigrate
11654
rev: "4.2"
11755
hooks:
11856
- id: check
57+
58+
- repo: https://github.com/astral-sh/ruff-pre-commit
59+
# Ruff version.
60+
rev: v0.9.9
61+
hooks:
62+
# Run the linter.
63+
- id: ruff
64+
args: [ --fix ]
65+
# Run the formatter.
66+
- id: ruff-format

prospector.yml

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)