Skip to content

Commit 39e5135

Browse files
WhyNotHugomatthiask
authored andcommitted
Use ruff for linting
Use ruff instead of flake8+isort+pyupgrade+pygrep-hooks. This change configures ruff to apply all the same rules that these tools apply. I've omitted E501 for now since there are a few violations.
1 parent b7af52d commit 39e5135

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
lines changed

.flake8

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

.pre-commit-config.yaml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,18 @@ repos:
77
- id: end-of-file-fixer
88
- id: trailing-whitespace
99
- id: mixed-line-ending
10-
- repo: https://github.com/pycqa/flake8
11-
rev: 6.0.0
12-
hooks:
13-
- id: flake8
1410
- repo: https://github.com/pycqa/doc8
1511
rev: v1.1.1
1612
hooks:
1713
- id: doc8
18-
- repo: https://github.com/asottile/pyupgrade
19-
rev: v3.4.0
20-
hooks:
21-
- id: pyupgrade
22-
args: [--py38-plus]
2314
- repo: https://github.com/adamchainz/django-upgrade
2415
rev: 1.13.0
2516
hooks:
2617
- id: django-upgrade
2718
args: [--target-version, "3.2"]
28-
- repo: https://github.com/pycqa/isort
29-
rev: 5.12.0
30-
hooks:
31-
- id: isort
3219
- repo: https://github.com/pre-commit/pygrep-hooks
3320
rev: v1.10.0
3421
hooks:
35-
- id: python-check-blanket-noqa
36-
- id: python-check-mock-methods
37-
- id: python-no-eval
38-
- id: python-no-log-warn
3922
- id: rst-backticks
4023
- id: rst-directive-colons
4124
- repo: https://github.com/pre-commit/mirrors-prettier
@@ -53,6 +36,11 @@ repos:
5336
types: [file]
5437
args:
5538
- --fix
39+
- repo: https://github.com/charliermarsh/ruff-pre-commit
40+
rev: 'v0.0.267'
41+
hooks:
42+
- id: ruff
43+
args: [--fix, --exit-non-zero-on-fix]
5644
- repo: https://github.com/psf/black
5745
rev: 23.3.0
5846
hooks:

debug_toolbar/panels/sql/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def contrasting_color_generator():
132132
"""
133133

134134
def rgb_to_hex(rgb):
135-
return "#%02x%02x%02x" % tuple(rgb)
135+
return "#{:02x}{:02x}{:02x}".format(*tuple(rgb))
136136

137137
triples = [
138138
(1, 0, 0),

docs/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Style
101101
-----
102102

103103
The Django Debug Toolbar uses `black <https://github.com/psf/black>`__ to
104-
format code and additionally uses flake8 and isort. The toolbar uses
104+
format code and additionally uses ruff. The toolbar uses
105105
`pre-commit <https://pre-commit.com>`__ to automatically apply our style
106106
guidelines when a commit is made. Set up pre-commit before committing with::
107107

pyproject.toml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ packages = ["debug_toolbar"]
4949
[tool.hatch.version]
5050
path = "debug_toolbar/__init__.py"
5151

52-
[tool.isort]
53-
combine_as_imports = true
54-
profile = "black"
55-
5652
[tool.coverage.html]
5753
skip_covered = true
5854
skip_empty = true
@@ -69,3 +65,25 @@ source = ["src", ".tox/*/site-packages"]
6965
# Update coverage badge link in README.rst when fail_under changes
7066
fail_under = 94
7167
show_missing = true
68+
69+
[tool.ruff.isort]
70+
combine-as-imports = true
71+
72+
[tool.ruff]
73+
select = [
74+
# flake8/Pyflakes
75+
"F",
76+
# flake8/pycodestyle
77+
"E",
78+
"W",
79+
# isort
80+
"I",
81+
# pyupgrade
82+
"UP",
83+
# pygrep-hooks
84+
"PGH",
85+
]
86+
ignore = [
87+
"E501",
88+
]
89+
target-version = "py38"

requirements_dev.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ Jinja2
77
# Testing
88

99
coverage[toml]
10-
flake8
1110
html5lib
12-
isort
1311
selenium
1412
tox
1513
black

0 commit comments

Comments
 (0)