misc: add black/isort/pyupgrade files & notes (#54260)
This commit is contained in:
parent
7233202758
commit
7eae5d8d52
|
@ -0,0 +1,2 @@
|
||||||
|
# misc: apply black/isort/pyupgrade (#54260)
|
||||||
|
72332027586fb99a6dfbc0130cd34987096bd586
|
|
@ -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']
|
21
README.rst
21
README.rst
|
@ -11,6 +11,27 @@ To use just do::
|
||||||
django_journal.record('my-tag', '{user} did this to {that}',
|
django_journal.record('my-tag', '{user} did this to {that}',
|
||||||
user=request.user, that=model_instance)
|
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
|
Admin display
|
||||||
-------------
|
-------------
|
||||||
|
|
9
tox.ini
9
tox.ini
|
@ -1,6 +1,6 @@
|
||||||
[tox]
|
[tox]
|
||||||
toxworkdir = /tmp/tox-{env:USER}/django-journal/{env:BRANCH_NAME:}
|
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]
|
[testenv]
|
||||||
|
@ -17,3 +17,10 @@ setenv =
|
||||||
coverage: COVERAGE=--cov-append --cov-report xml --cov-report html --cov=django_journal/
|
coverage: COVERAGE=--cov-append --cov-report xml --cov-report html --cov=django_journal/
|
||||||
commands =
|
commands =
|
||||||
py.test {posargs: {env:COVERAGE:} --junitxml=junit-{envname}.xml tests/}
|
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
|
||||||
|
|
Loading…
Reference in New Issue