This repository contains a pre-commit configuration tailored for Python projects. It integrates tools like black
, isort
, flake8
, and autoflake
to enforce code quality and style consistency.
This pre-commit setup is designed to streamline Python code formatting and linting processes. It ensures your code is clean, readable, and adheres to best practices before every commit.
To use this pre-commit configuration in your project, follow these steps:
-
Install pre-commit:
If not already installed, install pre-commit globally with:
pip install pre-commit
-
Clone This Repository:
Clone this repository into your local machine:
git clone https://github.com/theopsall/pre-commit-hooks
-
Copy Configuration to Your Project:
Copy the .pre-commit-config.yaml file from this repository to the root of your project.
-
Install Hooks:
Navigate to your project's root directory and install the pre-commit hooks:
pre-commit install
Once installed, pre-commit will run automatically on git commit. However, you can also run it manually on all files:
- To run on all files:
pre-commit run --all-files
- To format a specific file:
Run pre-commit for a specific file with:
pre-commit run --files your-file.py
To update the hooks to their latest versions:
pre-commit autoupdate