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.
pip install pre-commitVerified import paths — ran on the pinned version, not inferred.
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.
Upgrade your Python environment to 3.9 or later. If you need to use an older Python version, pin `pre-commit-hooks` to a version prior to 6.0.0 (e.g., `rev: v5.0.0`).
For `check-byte-order-marker`, migrate to `fix-byte-order-marker`. For `fix-encoding-pragma`, consider using `pyupgrade` or a similar tool.
Review your `file-contents-sorter` hook configuration. If both arguments are present, remove one or adjust your workflow to achieve the desired sorting behavior in two separate steps if necessary.
Remove `check-docstring-first` from your `.pre-commit-config.yaml`. Consider using other tools for docstring validation if needed.
Ensure `pre-commit` is installed (`pip install pre-commit`) and then run `pre-commit install` in your repository to activate the hooks. Refer to the quickstart example for configuration.
No dependency data recorded yet.