Skip to content

Instantly share code, notes, and snippets.

@cosimo
Last active February 9, 2023 17:18
Show Gist options
  • Save cosimo/a6b9d3451034cd92bdab92d95931a92a to your computer and use it in GitHub Desktop.
Save cosimo/a6b9d3451034cd92bdab92d95931a92a to your computer and use it in GitHub Desktop.
Pre-commit checks with pre-commit python app

Pre-commit app usage

Installation

pip install pre-commit

Usage

Example of .pre-commit-config.yaml:

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v2.3.0
    hooks:
      - id: check-yaml
      - id: end-of-file-fixer
      - id: trailing-whitespace
  - repo: https://github.com/psf/black
    rev: 22.3.0
    hooks:
      - id: black
  - repo: https://github.com/pycqa/pylint
    rev: pylint-2.8.1
    hooks:
      - id: pylint
        args: ["--max-line-length=120", "--disable=import-error,missing-module-docstring,missing-function-docstring"]

There is another hook that is interesting but as of now conflicts with black so I commented it out:

  - repo: https://github.com/asottile/reorder_python_imports
    rev: v2.6.0
    hooks:
      - id: reorder-python-imports
        language_version: python3

To run the pre-commit application:

pre-commit run --all-files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment