misc: add black/isort/pyupgrade files & notes (#54260)

This commit is contained in:
Paul Marillonnet 2021-07-15 12:29:36 +02:00
parent 7233202758
commit 7eae5d8d52
4 changed files with 49 additions and 1 deletions

2
.git-blame-ignore-revs Normal file
View File

@ -0,0 +1,2 @@
# misc: apply black/isort/pyupgrade (#54260)
72332027586fb99a6dfbc0130cd34987096bd586

18
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,18 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
args: ['--target-version', 'py37', '--skip-string-normalization', '--line-length', '110']
- repo: https://github.com/PyCQA/isort
rev: 5.7.0
hooks:
- id: isort
args: ['--profile', 'black', '--line-length', '110']
- repo: https://github.com/asottile/pyupgrade
rev: v2.20.0
hooks:
- id: pyupgrade
args: ['--keep-percent-format', '--py37-plus']

View File

@ -11,6 +11,27 @@ To use just do::
django_journal.record('my-tag', '{user} did this to {that}',
user=request.user, that=model_instance)
Code Style
==========
black is used to format the code, using these parameters::
black --target-version py37 --skip-string-normalization --line-length 110
There is .pre-commit-config.yaml to use pre-commit to automatically run black
before commits. (execute `pre-commit install` to install the git hook.)
isort is used to format the imports, using these parameter::
isort --profile black --line-length 110
pyupgrade is used to automatically upgrade syntax, using these parameters::
pyupgrade --keep-percent-format --py37-plus
There is .pre-commit-config.yaml to use pre-commit to automatically run black,
isort and pyupgrade before commits. (execute `pre-commit install` to install
the git hook.)
Admin display
-------------

View File

@ -1,6 +1,6 @@
[tox]
toxworkdir = /tmp/tox-{env:USER}/django-journal/{env:BRANCH_NAME:}
envlist = py3-coverage-django111,py3-django22
envlist = py3-coverage-django111,py3-django22,code-style
[testenv]
@ -17,3 +17,10 @@ setenv =
coverage: COVERAGE=--cov-append --cov-report xml --cov-report html --cov=django_journal/
commands =
py.test {posargs: {env:COVERAGE:} --junitxml=junit-{envname}.xml tests/}
[testenv:code-style]
skip_install = true
deps =
pre-commit
commands =
pre-commit run --all-files --show-diff-on-failure