Skip to content

Use only pre-commit for style linters and fixers #1535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,4 @@ jobs:
python -m pip install --upgrade tox

- name: Test with tox
run: tox -e docs,style,packaging
run: tox -e docs,packaging
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@ docs/_build
example/db.sqlite3
htmlcov
.tox
node_modules
package-lock.json
geckodriver.log
coverage.xml
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ repos:
- id: eslint
files: \.js?$
types: [file]
args:
- --fix
- repo: https://github.com/psf/black
rev: 21.11b1
hooks:
Expand Down
24 changes: 1 addition & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,11 @@
.PHONY: flake8 example test coverage translatable_strings update_translations

PRETTIER_TARGETS = '**/*.(css|js)'

style: package-lock.json
isort .
black --target-version=py36 .
flake8
npx eslint --ignore-path .gitignore --fix .
npx prettier --ignore-path .gitignore --write $(PRETTIER_TARGETS)
! grep -r '\(style=\|onclick=\|<script>\|<style\)' debug_toolbar/templates/

style_check: package-lock.json
isort -c .
black --target-version=py36 --check .
flake8
npx eslint --ignore-path .gitignore .
npx prettier --ignore-path .gitignore --check $(PRETTIER_TARGETS)
! grep -r '\(style=\|onclick=\|<script>\|<style\)' debug_toolbar/templates/
.PHONY: example test coverage translatable_strings update_translations

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

package-lock.json: package.json
npm install
touch $@

test:
DJANGO_SETTINGS_MODULE=tests.settings \
python -m django test $${TEST_ARGS:-tests}
Expand Down
9 changes: 7 additions & 2 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,19 @@ Style
The Django Debug Toolbar uses `black <https://github.com/psf/black>`__ to
format code and additionally uses flake8 and isort. The toolbar uses
`pre-commit <https://pre-commit>`__ to automatically apply our style guidelines
when a commit is made. If necessary this can be bypassed using::
when a commit is made. Set up pre-commit before committing with:

$ pre-commit install

If necessary you can bypass pre-commit locally with::

$ git commit --no-verify

Note that it runs on CI.

To reformat the code manually use::

$ make style
$ pre-commit run --all-files

Patches
-------
Expand Down
1 change: 1 addition & 0 deletions docs/spelling_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ middleware
middlewares
multi
neo
pre
profiler
psycopg
py
Expand Down
6 changes: 0 additions & 6 deletions package.json

This file was deleted.

9 changes: 0 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[tox]
envlist =
docs
style
packaging
py{36,37}-dj{22,31,32}-{sqlite,postgresql,postgis,mysql}
py{38,39}-dj{22,31,32,40,main}-{sqlite,postgresql,postgis,mysql}
Expand Down Expand Up @@ -68,14 +67,6 @@ deps =
Sphinx
sphinxcontrib-spelling

[testenv:style]
commands = make style_check
deps =
black>=19.10b0
flake8
isort>=5.0.2
skip_install = true

[testenv:packaging]
commands =
python setup.py sdist bdist_wheel
Expand Down