Last active
January 8, 2024 09:33
-
-
Save LouisdeBruijn/e300efc9207bcfbff2ed8cd18bf56859 to your computer and use it in GitHub Desktop.
autoflake, isort, black and flake8 pre-commits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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