Skip to content

Instantly share code, notes, and snippets.

@EckoTan0804
Last active November 18, 2022 21:11
Show Gist options
  • Save EckoTan0804/8d08e4cea323644dd82c43190a55eaa7 to your computer and use it in GitHub Desktop.
Save EckoTan0804/8d08e4cea323644dd82c43190a55eaa7 to your computer and use it in GitHub Desktop.
pre-commit
# Place this file to the root of the project
# Adjust based on your needs
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files # Prevent giant files from being committed.
- id: check-ast # Simply check whether files parse as valid python.
- id: fix-byte-order-marker # Removes UTF-8 byte order marker.
- id: check-case-conflict # Check for files with names that would conflict on a case-insensitive filesystem like MacOS HFS+ or Windows FAT.
- id: check-docstring-first # Check for a common error of placing code before the docstring.
- id: check-json # Attempt to load all json files to verify syntax.
- id: check-yaml # Attempt to load all yaml files to verify syntax.
- id: end-of-file-fixer # Make sure files end in a newline and only a newline.
- id: trailing-whitespace # Trim trailing whitespace.
- id: mixed-line-ending # Replace or checks mixed line ending.
# Sort Python import statements systematically. Further customization is defined in setup.cfg
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
# Validate against 'black' for unambiguous Python formatting.
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
args:
- --line-length=119 # Set max. line length to 119 instead of 88.
# Automatically upgrade syntax for newer versions of the language
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
hooks:
- id: pyupgrade
args: [--py36-plus]
# Run black on python code blocks in documentation files.
- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
hooks:
- id: blacken-docs
additional_dependencies: [black==22.10.0]
# Format docstrings in a consistent way, on top of 'black' requirements.
- repo: https://github.com/myint/docformatter
rev: v1.5.0
hooks:
- id: docformatter
args:
- --in-place
- --wrap-descriptions=119
- --wrap-summaries=119
# Check compliance with Python docstring conventions.
- repo: https://github.com/pycqa/pydocstyle
rev: 6.1.1
hooks:
- id: pydocstyle
# Check compliance with flake8.
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
args:
- --config=setup.cfg
[flake8]
max-line-length = 119
max-complexity = 11
ignore = C901, W503, W504, E203, F401
[isort]
# More options see: https://pycqa.github.io/isort/docs/configuration/options.html
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
line_length = 88
profile = black
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment