Projet

Général

Profil

0004-misc-add-black-isort-pyupgrade-files-notes-54260.patch

Paul Marillonnet, 15 juillet 2021 12:35

Télécharger (3,29 ko)

Voir les différences:

Subject: [PATCH 4/4] misc: add black/isort/pyupgrade files & notes (#54260)

 .git-blame-ignore-revs  |  6 ++++++
 .pre-commit-config.yaml | 18 ++++++++++++++++++
 README.rst              | 21 +++++++++++++++++++++
 tox.ini                 |  9 ++++++++-
 4 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 .git-blame-ignore-revs
 create mode 100644 .pre-commit-config.yaml
.git-blame-ignore-revs
1
# misc: apply black
2
d1aed61b133a4b8292baa2d9fe7931fcd4188591
3
# misc: apply isort
4
16f8e2ae282824f1be70c7c541e8aa7cea2fdc90
5
# misc: apply pyupgrade
6
bbb5bd736196803ff53ae0d665e9372352754bb0
.pre-commit-config.yaml
1
# See https://pre-commit.com for more information
2
# See https://pre-commit.com/hooks.html for more hooks
3
repos:
4
-   repo: https://github.com/psf/black
5
    rev: 20.8b1
6
    hooks:
7
    - id: black
8
      args: ['--target-version', 'py37', '--skip-string-normalization', '--line-length', '110']
9
-   repo: https://github.com/PyCQA/isort
10
    rev: 5.7.0
11
    hooks:
12
    - id: isort
13
      args: ['--profile', 'black', '--line-length', '110']
14
-   repo: https://github.com/asottile/pyupgrade
15
    rev: v2.20.0
16
    hooks:
17
    - id: pyupgrade
18
      args: ['--keep-percent-format', '--py37-plus']
README.rst
11 11
      django_journal.record('my-tag', '{user} did this to {that}',
12 12
                 user=request.user, that=model_instance)
13 13

  
14
Code Style
15
==========
16

  
17
black is used to format the code, using these parameters::
18

  
19
    black --target-version py37 --skip-string-normalization --line-length 110
20

  
21
There is .pre-commit-config.yaml to use pre-commit to automatically run black
22
before commits. (execute `pre-commit install` to install the git hook.)
23

  
24
isort is used to format the imports, using these parameter::
25

  
26
    isort --profile black --line-length 110
27

  
28
pyupgrade is used to automatically upgrade syntax, using these parameters::
29

  
30
    pyupgrade --keep-percent-format --py37-plus
31

  
32
There is .pre-commit-config.yaml to use pre-commit to automatically run black,
33
isort and pyupgrade before commits. (execute `pre-commit install` to install
34
the git hook.)
14 35

  
15 36
Admin display
16 37
-------------
tox.ini
1 1
[tox]
2 2
toxworkdir = /tmp/tox-{env:USER}/django-journal/{env:BRANCH_NAME:}
3
envlist = py3-coverage-django111,py3-django22
3
envlist = py3-coverage-django111,py3-django22,code-style
4 4

  
5 5

  
6 6
[testenv]
......
17 17
  coverage: COVERAGE=--cov-append --cov-report xml --cov-report html --cov=django_journal/
18 18
commands =
19 19
  py.test {posargs: {env:COVERAGE:} --junitxml=junit-{envname}.xml tests/}
20

  
21
[testenv:code-style]
22
skip_install = true
23
deps =
24
  pre-commit
25
commands =
26
  pre-commit run --all-files --show-diff-on-failure
20
-