From fe01afc9a7ff9de7dd6d25222274f65d21adf27d Mon Sep 17 00:00:00 2001 From: ruuushhh Date: Fri, 17 Nov 2023 13:50:36 +0530 Subject: [PATCH] Add Pre commit hook for linting --- .pre-commit-config.yaml | 42 +++++++++++++++++++++++++++++++++++++++++ bandit.yaml | 1 + 2 files changed, 43 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 bandit.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..077c587 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,42 @@ +default_stages: [commit] +fail_fast: true +exclude: "^(sql/|(.*\/)?migrations\/)" +default_language_version: # noqa + python: python3 + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - id: check-ast + - id: check-merge-conflict + - id: debug-statements + - id: detect-private-key + - id: end-of-file-fixer + - id: trailing-whitespace + + - repo: https://github.com/timothycrosley/isort + rev: 5.12.0 + hooks: + - id: isort + args: ["--profile", "black", "--trailing-comma", "--line-length=125"] # Fixed the syntax error here + + - repo: https://github.com/pycqa/flake8 + rev: 6.1.0 + hooks: + - id: flake8 + additional_dependencies: [flake8-isort, flake8-tidy-imports] + + - repo: https://github.com/Lucas-C/pre-commit-hooks-bandit + rev: v1.0.5 + hooks: + - id: python-bandit-vulnerability-check + args: ["-lll", "--recursive", "-c", "bandit.yaml", "."] # Fixed the syntax error here + files: '\.py$' # Fixed the regex syntax here + + - repo: local + hooks: + - id: flake8 + name: flake8 + entry: flake8 + language: system diff --git a/bandit.yaml b/bandit.yaml new file mode 100644 index 0000000..4505dcc --- /dev/null +++ b/bandit.yaml @@ -0,0 +1 @@ +exclude_dirs: ['./venv', './.venv'] # noqa