diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000..e9f3bf4 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# misc: apply pyupgrade/isort/black (#56062) +65d33f00b7a0e9b5c75dde1b92c1484de740030e diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b5353c2 --- /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/asottile/pyupgrade + rev: v2.20.0 + hooks: + - id: pyupgrade + args: ['--keep-percent-format', '--py37-plus'] +- repo: https://github.com/PyCQA/isort + rev: 5.7.0 + hooks: + - id: isort + args: ['--profile', 'black', '--line-length', '110'] +- repo: https://github.com/psf/black + rev: 20.8b1 + hooks: + - id: black + args: ['--target-version', 'py37', '--skip-string-normalization', '--line-length', '110'] diff --git a/README.rst b/README.rst index d66c825..0968de5 100644 --- a/README.rst +++ b/README.rst @@ -220,3 +220,25 @@ measures also in the same ordre as the query. The `count` measure is a special measure which is always present whose expression is always `count({fact_table}.{key})` where `fact_table` and `key` are the corresponding attributes of the cube. + +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.) + +isort is used to format the imports, using those parameter: + + isort --profile black --line-length 110 + +pyupgrade is used to automatically upgrade syntax, using those 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.) diff --git a/tox.ini b/tox.ini index 724105b..505d6bc 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,16 @@ [tox] toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/bijoe/{env:BRANCH_NAME:} -envlist = py3-dj22 +envlist = + py3-dj22 + code-style + +[testenv:code-style] +skip_install = true +deps = + pre-commit +commands = + pre-commit run --all-files --show-diff-on-failure [testenv] usedevelop = true @@ -31,6 +40,7 @@ deps = dj22: https://git.entrouvert.org/hobo.git/snapshot/hobo-main.tar.gz commands = py3-dj22: py.test {posargs: --junitxml=test_{envname}_results.xml --cov-report xml --cov-report html --cov=bijoe tests/} + [pytest] filterwarnings = once:.*