From 20f7eec81211098b729347e147bfdc55c6ab99c1 Mon Sep 17 00:00:00 2001 From: Nok Lam Chan Date: Thu, 8 Jun 2023 18:42:33 +0100 Subject: [PATCH] Update .pre-commit-config.yaml to optimise developer experience (#2661) --- .pre-commit-config.yaml | 111 +++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 53 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 60c45abdc1..163bff3f2f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,36 +19,6 @@ repos: exclude: "^kedro/templates/|^features/steps/test_starter/" - id: requirements-txt-fixer # Sorts entries in requirements.txt exclude: "^kedro/templates/|^features/steps/test_starter/" - - id: flake8 - args: - - "--max-line-length=88" - - "--max-complexity=18" - - "--max-complexity=18" - - "--select=B,C,E,F,W,T4,B9" - - "--ignore=E203,E266,E501,W503" - exclude: "^kedro/templates/|^features/steps/test_starter/" - - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.961 - hooks: - - id: mypy - args: [--allow-redefinition, --ignore-missing-imports] - exclude: | - (?x)( - ^kedro/templates/| - ^docs/| - ^features/steps/test_starter/ - ) - additional_dependencies: - - types-cachetools - - types-filelock - - types-PyYAML - - types-redis - - types-requests - - types-setuptools - - types-toml - - attrs - - repo: https://github.com/asottile/blacken-docs rev: v1.12.1 hooks: @@ -82,18 +52,7 @@ repos: language: system pass_filenames: false entry: lint-imports - - id: secret_scan - name: "Secret scan" - language: system - exclude: ^features/steps/test_starter - pass_filenames: false - entry: make secret-scan - - id: bandit - name: "Bandit security check" - language: system - types: [file, python] - exclude: ^kedro/templates/|^tests/|^features/steps/test_starter - entry: bandit -ll + # It's impossible to specify per-directory configuration, so we just run it many times. # https://github.com/PyCQA/pylint/issues/618 @@ -106,6 +65,13 @@ repos: exclude: ^kedro/templates/ entry: pylint -j 4 --disable=unnecessary-pass stages: [commit] + - id: pylint-quick-tests + name: "Quick Pylint on tests/*" + language: system + types: [file, python] + files: ^tests/ + entry: pylint -j 4 --disable=missing-docstring,redefined-outer-name,no-self-use,invalid-name,protected-access,too-many-arguments,too-many-public-methods + stages: [commit] - id: pylint-quick-features name: "Quick Pylint on features/*" language: system @@ -114,13 +80,6 @@ repos: exclude: ^features/steps/test_starter entry: pylint -j 4 --disable=missing-docstring,no-name-in-module stages: [commit] - - id: pylint-quick-tests - name: "Quick Pylint on tests/*" - language: system - types: [file, python] - files: ^tests/ - entry: pylint -j 4 --disable=missing-docstring,redefined-outer-name,no-self-use,invalid-name,protected-access,too-many-arguments,too-many-public-methods - stages: [commit] # The same pylint checks, but running on all files. It's for manual run with `make lint` - id: pylint-kedro @@ -129,6 +88,12 @@ repos: pass_filenames: false stages: [manual] entry: pylint -j 4 --disable=unnecessary-pass --init-hook="import sys; sys.setrecursionlimit(2000)" kedro + - id: pylint-tests + name: "Pylint on tests/*" + language: system + pass_filenames: false + stages: [manual] + entry: pylint -j 4 --disable=missing-docstring,redefined-outer-name,no-self-use,invalid-name,protected-access,too-many-arguments,too-many-public-methods,use-implicit-booleaness-not-comparison tests - id: pylint-features name: "Pylint on features/*" language: system @@ -136,9 +101,49 @@ repos: stages: [manual] exclude: ^features/steps/test_starter entry: pylint -j 4 --disable=missing-docstring,no-name-in-module features - - id: pylint-tests - name: "Pylint on tests/*" + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.2.3 + hooks: + - id: flake8 + args: + - "--max-line-length=88" + - "--max-complexity=18" + - "--max-complexity=18" + - "--select=B,C,E,F,W,T4,B9" + - "--ignore=E203,E266,E501,W503" + exclude: "^kedro/templates/|^features/steps/test_starter/" + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.961 + hooks: + - id: mypy + args: [--allow-redefinition, --ignore-missing-imports] + exclude: | + (?x)( + ^kedro/templates/| + ^docs/| + ^features/steps/test_starter/ + ) + additional_dependencies: + - types-cachetools + - types-filelock + - types-PyYAML + - types-redis + - types-requests + - types-setuptools + - types-toml + - attrs + - repo: local + hooks: + # Slow lintint + - id: secret_scan + name: "Secret scan" language: system + exclude: ^features/steps/test_starter pass_filenames: false - stages: [manual] - entry: pylint -j 4 --disable=missing-docstring,redefined-outer-name,no-self-use,invalid-name,protected-access,too-many-arguments,too-many-public-methods,use-implicit-booleaness-not-comparison tests + entry: make secret-scan + - id: bandit + name: "Bandit security check" + language: system + types: [file, python] + exclude: ^kedro/templates/|^tests/|^features/steps/test_starter + entry: bandit -ll