Skip to content

Commit ded85eb

Browse files
authored
Merge pull request #3 from AmadeusITGroup/issue_templates_and_other_tweaks
chore(docs): added a bit of description for pre-commit hooks
2 parents 58859ac + 21461f7 commit ded85eb

2 files changed

Lines changed: 72 additions & 3 deletions

File tree

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@ repos:
2121
rev: "25.1.0"
2222
hooks:
2323
- id: "black"
24-
language_version: "python3.11"

README.md

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This is a template repo to act as a reference when starting up a new project in
55
Local installation can be done using [`uv`](https://github.com/astral-sh/uv):
66

77
```bash
8-
$ uv venv -p python3.10
8+
$ uv venv -p python3.11
99
$ uv pip install -e .
1010
$ source .venv/bin/activate
1111
$ python
@@ -38,13 +38,83 @@ Packaging uses [`setuptools-scm`](https://github.com/pypa/setuptools-scm), so th
3838

3939
To run the linting, we recommend `ruff`, a standard configuration is in the repo in `pyproject.toml`.
4040

41+
# Pre-commit Hooks
42+
43+
This project uses [`pre-commit`](https://pre-commit.com/) to ensure code quality and consistency before committing changes. Pre-commit hooks automatically run checks such as linting and formatting on staged files.
44+
45+
## Setting up Pre-commit Hooks
46+
47+
To set up pre-commit hooks for this repository, follow these steps:
48+
49+
1. Install `pre-commit` if you haven't already:
50+
51+
```bash
52+
pip install pre-commit
53+
```
54+
55+
2. Install the pre-commit hooks defined in the `.pre-commit-config.yaml` file:
56+
57+
```bash
58+
pre-commit install
59+
```
60+
61+
3. You can manually run the pre-commit hooks on all files in the repository using:
62+
63+
```bash
64+
pre-commit run --all-files
65+
```
66+
67+
## How it Works
68+
Once installed, the pre-commit hooks will automatically run on staged files whenever you attempt to make a commit. If any of the hooks fail, the commit will be blocked until the issues are resolved.
69+
70+
## Updating Hooks
71+
To update the pre-commit hooks to their latest versions, run:
72+
```bash
73+
pre-commit autoupdate
74+
```
75+
## Available Hooks
76+
77+
Some examples of the pre-commit:
78+
79+
- **black**: Automatically formats Python code to conform to the Black code style.
80+
- **isort**: Sorts imports in Python files according to PEP 8 guidelines.
81+
- **flake8**: Checks Python code for style guide enforcement.
82+
- **mypy**: Performs static type checking on Python code.
83+
- **ruff**: A fast Python linter and code quality tool.
84+
- **bandit**: A security linter for Python code.
85+
- **check-yaml**: Validates YAML files for syntax errors.
86+
- **check-added-large-files**: Prevents large files from being added to the repository.
87+
- **check-merge-conflict**: Checks for merge conflict markers in files.
88+
- **end-of-file-fixer**: Ensures that files end with a newline character.
89+
- **trailing-whitespace**: Removes trailing whitespace from lines in files.
90+
- **detect-private-key**: Detects private keys in files to prevent accidental exposure.
91+
- **check-json**: Validates JSON files for syntax errors.
92+
- **check-ast**: Checks Python files for syntax errors and other issues.
93+
- **check-toml**: Validates TOML files for syntax errors.
94+
- **check-merge-conflict**: Checks for merge conflict markers in files.
95+
- **check-symlinks**: Checks for broken symbolic links in the repository.
96+
- **check-xml**: Validates XML files for syntax errors.
97+
- **check-docs**: Checks for documentation issues in Python files.
98+
- **check-urls**: Checks for broken URLs in files.
99+
- **check-binary-files**: Checks for binary files in the repository.
100+
- **check-merge-conflict**: Checks for merge conflict markers in files.
101+
102+
.. and many more!
103+
104+
## Disabling Hooks Temporarily
105+
If you need to skip the pre-commit hooks for a specific commit, you can use the --no-verify flag:
106+
107+
## Configuration
108+
The hooks are configured in the .pre-commit-config.yaml file located in the root of the repository. You can customize the hooks as needed by editing this file. For more information, refer to the pre-commit documentation.
109+
110+
111+
41112
# Releasing
42113
To release a new version of the package, you can create a pre-release from the main branch using GitHub UI, which will then trigger the release workflow. Alternatively, you can use the `gh` command line tool to create a release:
43114

44115
```bash
45116
gh release create v[a.b.c] --prerelease --title "Kick starting the release" --target main
46117
```
47118

48-
49119
# Contributing
50120
We welcome contributions to this project! If you have an idea for a new feature, bug fix, or improvement, please open an issue or submit a pull request. Before contributing, please read our [contributing guidelines](./CONTRIBUTING.md).

0 commit comments

Comments
 (0)