add black configuration (#52457)

This commit is contained in:
Valentin Deniaud 2021-03-30 10:10:04 +02:00
parent 4bb33d3d3c
commit 3dc618a571
5 changed files with 29 additions and 1 deletions

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

@ -0,0 +1,2 @@
# misc: apply black
4bb33d3d3c62516cfdb1ff5bba9216936a07d368

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

@ -0,0 +1,8 @@
# 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']

2
Jenkinsfile vendored
View File

@ -14,7 +14,7 @@ pipeline {
sh """
python3 -m venv ${env.TMPDIR}/venv/
${env.TMPDIR}/venv/bin/pip install tox
PGPORT=`python -c 'import struct; import socket; s=socket.socket(); s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack("ii", 1, 0)); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'` pg_virtualenv -o fsync=off ${env.TMPDIR}/venv/bin/tox -rv -e rbac-py3-dj111,authentic-py3-dj111-drf39,authentic-py3-dj22-drf39,pylint"""
PGPORT=`python -c 'import struct; import socket; s=socket.socket(); s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack("ii", 1, 0)); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'` pg_virtualenv -o fsync=off ${env.TMPDIR}/venv/bin/tox -rv -e code-style,rbac-py3-dj111,authentic-py3-dj111-drf39,authentic-py3-dj22-drf39,pylint"""
}
post {
always {

10
README
View File

@ -68,6 +68,16 @@ Upgrade
using a previous one you must first upgrade to 2.1.12 before tempting
upgrade to a release later than 2.2.0.
Code Style
==========
black is used to format the code, using thoses 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.)
Support
=======

View File

@ -6,6 +6,7 @@
[tox]
toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/authentic/
envlist =
code-style
authentic-py3-dj111-drf39
authentic-py3-dj22-drf39
@ -106,6 +107,13 @@ commands =
./getlasso3.sh
./authentic2-ctl {posargs:--help}
[testenv:code-style]
skip_install = true
deps =
pre-commit
commands =
pre-commit run black --all-files --show-diff-on-failure
[pytest]
filterwarnings =
ignore