Skip to content

Instantly share code, notes, and snippets.

@martimors
Last active March 14, 2023 21:56
Show Gist options
  • Save martimors/fb44970abb6361b0faeeec1990d212d3 to your computer and use it in GitHub Desktop.
Save martimors/fb44970abb6361b0faeeec1990d212d3 to your computer and use it in GitHub Desktop.
Pre-commits for a python project
repos:
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
args: [--config=./pyproject.toml]
- repo: https://github.com/python-poetry/poetry
rev: 1.3.0
hooks:
- id: poetry-check
- id: poetry-lock
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.252"
hooks:
- id: ruff
args:
- --fix
- --exit-non-zero-on-fix
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.294
hooks:
- id: pyright
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.0-alpha.4"
hooks:
- id: prettier
types: [markdown]
args: ["--prose-wrap", "always", "--print-width", "100"]
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies:
- flake8-unused-arguments
- flake8-bugbear
- pep8-naming
- flake8-annotations
- flake8-builtins
- flake8-docstrings
- pandas-vet
- darglint
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.9.0
hooks:
- id: reorder-python-imports
# Fix coding patterns from old Python versions
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py310-plus]
# Misc checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-json
- id: check-yaml
args: [--allow-multiple-documents]
- id: debug-statements
- id: check-merge-conflict
- id: check-added-large-files
args: ["--maxkb=1000"]
- id: detect-aws-credentials
args: [--allow-missing-credentials]
- id: detect-private-key
# Linting on Dockerfile
- repo: https://github.com/AleksaC/hadolint-py
rev: v2.12.0.2
hooks:
- id: hadolint
# Check security issues
- repo: https://github.com/PyCQA/bandit
rev: "1.7.4"
hooks:
- id: bandit
args: ["-c", "pyproject.toml"]
additional_dependencies: ["bandit[toml]"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment