Skip to content

Instantly share code, notes, and snippets.

@LouisdeBruijn
Last active January 8, 2024 09:33
Show Gist options
  • Save LouisdeBruijn/e300efc9207bcfbff2ed8cd18bf56859 to your computer and use it in GitHub Desktop.
Save LouisdeBruijn/e300efc9207bcfbff2ed8cd18bf56859 to your computer and use it in GitHub Desktop.
autoflake, isort, black and flake8 pre-commits
repos:
- repo: local
hooks:
- id: autoflake
name: Remove unused variables and imports
entry: bash -c 'autoflake "$@"; git add -u' -- # This runs autoflake and stages the reformatted python files before running autoflake again, which should then "pass"
language: python
args: ["--in-place", "--remove-all-unused-imports", "--remove-unused-variables", "--expand-star-imports", "--ignore-init-module-imports"]
files: \.py$
- id: isort
name: Sorting import statements
entry: bash -c 'isort "$@"; git add -u' --
language: python
args: ["--filter-files"]
files: \.py$
- id: black
name: Black Python code formatting
entry: bash -c 'black "$@"; git add -u' --
language: python
types: [python]
language_version: python3.7
args: ["--line-length=120"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment