From c706b54d949ef12411e2e0c0fd1179765713c71e Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 11 Aug 2021 06:41:52 +0200 Subject: [PATCH] Add pre-commit hooks for bandit, black, codespell, and flake8 (#2270) * Add pre-commit hooks for bandit, black, codespell, and flake8 * Those pesky - -- characters... * Merge workflows and remove reduddency * Resync --- .github/workflows/pre-commit.yml | 17 +++++++++++++++++ .pre-commit-config.yaml | 30 ++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 .github/workflows/pre-commit.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 00000000000..b62f595ebb0 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,17 @@ +# https://pre-commit.com +# This GitHub Action assumes that the repo contains a valid .pre-commit-config.yaml file. +name: pre-commit +on: + pull_request: + push: + branches: [master] +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - run: pip install pre-commit + - run: pre-commit --version + - run: pre-commit install + - run: pre-commit run --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000000..a5c7cf6114b --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,30 @@ +repos: + - repo: https://github.com/PyCQA/bandit/ + rev: 1.7.0 + hooks: + - id: bandit + args: + - --recursive + - --skip + - B101,B108,B301,B403,B404,B603 + - . + - repo: https://github.com/python/black + rev: 21.7b0 + hooks: + - id: black + - repo: https://github.com/codespell-project/codespell + rev: v2.1.0 + hooks: + - id: codespell + args: + - --ignore-words-list=nd,reacher,thist,ths + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.9.2 + hooks: + - id: flake8 + args: + - --ignore=E203,E402,E712,E722,E731,E741,F401,F403,F405,F524,F841,W503 + - --max-complexity=30 + - --max-line-length=456 + - --show-source + - --statistics