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.
pip install pre-commitVerified import paths — ran on the pinned version, not inferred.
A script to install pre-commit, set up a configuration file with the Black formatter, install git hooks, and run them against all files.
Use non-editable installations or adjust tooling to handle new attributes.
Install `virtualenv` using `pip install virtualenv`.
Ensure Git is installed and configured on the system where pre-commit is run, and execute pre-commit commands from within a directory that is part of a Git repository.
Ensure that Git is installed in the environment and that the 'pre-commit' command is executed inside a Git repository.
Activate your virtual environment (if using one) or ensure `pre-commit` is installed and its executable is discoverable. For Python virtual environments, use `source venv/bin/activate` (Linux/macOS) or `.\venv\Scripts\activate` (Windows) before running `pre-commit`. If not installed, run `pip install pre-commit`.
Carefully check your `.pre-commit-config.yaml` for YAML syntax errors, especially indentation. Ensure the file is named `.pre-commit-config.yaml` and is located at the root of your repository. Use a YAML linter or validator to identify specific issues. Example of a common error: `mapping values are not allowed in this context`.
Run `pre-commit install` to reinstall the Git hook script. Ensure the script at `.git/hooks/pre-commit` has executable permissions (`chmod +x .git/hooks/pre-commit`). If the error persists and you previously used a different hook system (like Node.js `pre-commit`), manually remove the old hook file from `.git/hooks/pre-commit`.
For Python hooks, ensure `default_language_version: python: python3` (or a specific version like `python3.X`) is set in your `.pre-commit-config.yaml`. For other languages, ensure the required tools are installed and accessible by `pre-commit`'s environment. For local hooks (`language: system`), verify the executable is in your system's PATH.
Review the output in your terminal to see which specific hook failed and the reasons for its failure. Correct the issues reported by the hook (e.g., fix linting errors, format the code, resolve test failures) and then attempt to commit again. If you temporarily need to bypass the hooks, use `git commit --no-verify` (not recommended for general use).