diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000..37ed232 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# misc: apply black/isort/pyupgrade (#54260) +72332027586fb99a6dfbc0130cd34987096bd586 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..ce247d6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -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'] diff --git a/README.rst b/README.rst index e6c48e2..7ce2465 100644 --- a/README.rst +++ b/README.rst @@ -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 ------------- diff --git a/tox.ini b/tox.ini index 2f1925f..cbbfb51 100644 --- a/tox.ini +++ b/tox.ini @@ -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