Skip to content

Pre-commit Hooks

Pre-commit hook

The pre-commit hook is a tool for ensuring code consistency and quality by automatically formatting and fixing code. This helps maintain a clean and consistent codebase across all contributors.

Installation Steps

  • Install pre-commit package:

pip install pre-commit

  • Set Up Pre-commit Hook:

pre-commit install

  • Make sure you have a .pre-commit-config.yaml file in your project's root directory to define the configuration for the pre-commit hook.

Typical Output

When the pre-commit hook is triggered, it scans the staged files and enforces the configured tools to format and rectify any detected issues. The output provides a detailed summary of the actions performed by each tool, including code formatting adjustments and error resolutions, offering transparency and accountability in the code review process

Verifying Tests

To verify that all tests have passed after the pre-commit hook has executed, review the logs output. Address any errors or warnings reported by the pre-commit tools before proceeding with the commit.