Skip to content

Commit 5665d68

Browse files
authored
Use only pre-commit for style linters and fixers (#1535)
* Use only pre-commit for style linters and fixers The method of using the `Makefile`, running under `tox`, duplicated the work of pre-commit and pre-commit.ci. Additionally tox did not use the same pinned versions and arguments as in `.pre-commit-config.yaml`, so there is the potential for a version clash to cause the two paths to conflict, e.g. when a new version of Black is released. Sticking to only `pre-commit` seems sensible, saves some CI time, and allows some files to be removed. * spelling
1 parent 250d3fe commit 5665d68

File tree

8 files changed

+12
-43
lines changed

8 files changed

+12
-43
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,4 @@ jobs:
221221
python -m pip install --upgrade tox
222222
223223
- name: Test with tox
224-
run: tox -e docs,style,packaging
224+
run: tox -e docs,packaging

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,5 @@ docs/_build
1010
example/db.sqlite3
1111
htmlcov
1212
.tox
13-
node_modules
14-
package-lock.json
1513
geckodriver.log
1614
coverage.xml

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ repos:
3838
- id: eslint
3939
files: \.js?$
4040
types: [file]
41+
args:
42+
- --fix
4143
- repo: https://github.com/psf/black
4244
rev: 21.11b1
4345
hooks:

Makefile

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,11 @@
1-
.PHONY: flake8 example test coverage translatable_strings update_translations
2-
3-
PRETTIER_TARGETS = '**/*.(css|js)'
4-
5-
style: package-lock.json
6-
isort .
7-
black --target-version=py36 .
8-
flake8
9-
npx eslint --ignore-path .gitignore --fix .
10-
npx prettier --ignore-path .gitignore --write $(PRETTIER_TARGETS)
11-
! grep -r '\(style=\|onclick=\|<script>\|<style\)' debug_toolbar/templates/
12-
13-
style_check: package-lock.json
14-
isort -c .
15-
black --target-version=py36 --check .
16-
flake8
17-
npx eslint --ignore-path .gitignore .
18-
npx prettier --ignore-path .gitignore --check $(PRETTIER_TARGETS)
19-
! grep -r '\(style=\|onclick=\|<script>\|<style\)' debug_toolbar/templates/
1+
.PHONY: example test coverage translatable_strings update_translations
202

213
example:
224
python example/manage.py migrate --noinput
235
-DJANGO_SUPERUSER_PASSWORD=p python example/manage.py createsuperuser \
246
--noinput --username="$(USER)" --email="$(USER)@mailinator.com"
257
python example/manage.py runserver
268

27-
package-lock.json: package.json
28-
npm install
29-
touch $@
30-
319
test:
3210
DJANGO_SETTINGS_MODULE=tests.settings \
3311
python -m django test $${TEST_ARGS:-tests}

docs/contributing.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,19 @@ Style
103103
The Django Debug Toolbar uses `black <https://github.com/psf/black>`__ to
104104
format code and additionally uses flake8 and isort. The toolbar uses
105105
`pre-commit <https://pre-commit>`__ to automatically apply our style guidelines
106-
when a commit is made. If necessary this can be bypassed using::
106+
when a commit is made. Set up pre-commit before committing with:
107+
108+
$ pre-commit install
109+
110+
If necessary you can bypass pre-commit locally with::
107111

108112
$ git commit --no-verify
109113

114+
Note that it runs on CI.
110115

111116
To reformat the code manually use::
112117

113-
$ make style
118+
$ pre-commit run --all-files
114119

115120
Patches
116121
-------

docs/spelling_wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ middleware
2121
middlewares
2222
multi
2323
neo
24+
pre
2425
profiler
2526
psycopg
2627
py

package.json

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

tox.ini

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[tox]
22
envlist =
33
docs
4-
style
54
packaging
65
py{36,37}-dj{22,31,32}-{sqlite,postgresql,postgis,mysql}
76
py{38,39}-dj{22,31,32,40,main}-{sqlite,postgresql,postgis,mysql}
@@ -68,14 +67,6 @@ deps =
6867
Sphinx
6968
sphinxcontrib-spelling
7069

71-
[testenv:style]
72-
commands = make style_check
73-
deps =
74-
black>=19.10b0
75-
flake8
76-
isort>=5.0.2
77-
skip_install = true
78-
7970
[testenv:packaging]
8071
commands =
8172
python setup.py sdist bdist_wheel

0 commit comments

Comments
 (0)