From 29e6fceb33c6e74a6de7c3ad487d76e86849fa30 Mon Sep 17 00:00:00 2001 From: Andreas Berthoud Date: Sun, 4 Jul 2021 17:15:02 +0200 Subject: [PATCH] Add pre-commit hooks --- .pre-commit-config.yaml | 35 +++++++++++++++++++++++++++++++++++ pyproject.toml | 15 +++++++++++++++ setup.cfg | 15 +++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 pyproject.toml create mode 100644 setup.cfg diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..82a8289 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,35 @@ +repos: + - repo: https://github.com/pre-commit/mirrors-isort + rev: v5.7.0 # https://github.com/pre-commit/mirrors-isort/tags + hooks: + - id: isort + + - repo: https://github.com/psf/black + rev: 20.8b1 # https://github.com/psf/black/tags + hooks: + - id: black + + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.9.0 # https://gitlab.com/pycqa/flake8/-/tags + hooks: + - id: flake8 + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.812 # https://github.com/pre-commit/mirrors-mypy/tags + hooks: + - id: mypy + exclude: 'docs' + + - repo: https://github.com/asottile/add-trailing-comma + rev: v2.1.0 # https://github.com/asottile/add-trailing-comma/tags + hooks: + - id: add-trailing-comma + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.4.0 # https://github.com/pre-commit/pre-commit-hooks/tags + hooks: + - id: check-json + - id: check-xml + - id: check-yaml + - id: debug-statements + - id: requirements-txt-fixer \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..284ac42 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,15 @@ +[tool.isort] +profile = "hug" +force_single_line = true + +[tool.black] +# line-length = 88 # default. adapt if necessary, must be in sync with flake8 config +exclude = ''' +( + /( + | \.git # root of the project + | \venv* + | nucleo* + )/ +) +''' \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..033c324 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,15 @@ +[tool:pytest] +pep8ignore = E501 + +[flake8] +# ignore errors and warnings +# - whitespace before ':', see https://github.com/psf/black/issues/315 +# - line break before binary operator, see https://github.com/psf/black/issues/52 +ignore = E203, W503 + +# must be in sync with 'black' formatter config in pyproject.toml +max-line-length = 88 + +[mypy] +ignore_missing_imports = True +exclude=docs/