pre-commit

4.5.1 · active · verified Sat Mar 28

A framework for managing and maintaining multi-language pre-commit hooks. Current version: 4.5.1. Released on December 16, 2025. Maintained with regular updates.

Warnings

Install

Imports

Quickstart

A script to install pre-commit, set up a configuration file with the Black formatter, install git hooks, and run them against all files.

import os

# Install pre-commit
os.system('pip install pre-commit')

# Create a configuration file
with open('.pre-commit-config.yaml', 'w') as f:
    f.write('repos:\n  - repo: https://github.com/pre-commit/mirrors-black\n    rev: v22.10.0\n    hooks:\n      - id: black\n')

# Install the git hook scripts
os.system('pre-commit install')

# Run hooks against all files
os.system('pre-commit run --all-files')

view raw JSON →