pre-commit-hooks

6.0.0 · active · verified Sat Apr 11

pre-commit-hooks provides a collection of frequently used Git hooks for the `pre-commit` framework, facilitating code quality checks such as trailing whitespace, end-of-file fixers, JSON/YAML validation, and detection of large files. Currently at version 6.0.0, the library releases updates periodically, often alongside the `pre-commit` framework itself, to introduce new hooks, fix issues, or update Python version requirements.

Warnings

Install

Imports

Quickstart

To use `pre-commit-hooks`, you first need the `pre-commit` framework installed. Then, configure your desired hooks in a `.pre-commit-config.yaml` file in your repository root and install the git hooks. This example demonstrates a basic configuration using common hooks from the v6.0.0 release.

# 1. Create a .pre-commit-config.yaml in your repository root
# Example content:
# .pre-commit-config.yaml
---
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v6.0.0 # Use the latest version or a specific tag
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-json
      - id: check-added-large-files
      - id: debug-statements

# 2. Install pre-commit (if not already installed)
# pip install pre-commit

# 3. Install the git hooks in your repository
# pre-commit install

# 4. (Optional) Manually run all hooks against all files
# pre-commit run --all-files

# Hooks will now run automatically on `git commit`

view raw JSON →