You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+72-2Lines changed: 72 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ This is a template repo to act as a reference when starting up a new project in
5
5
Local installation can be done using [`uv`](https://github.com/astral-sh/uv):
6
6
7
7
```bash
8
-
$ uv venv -p python3.10
8
+
$ uv venv -p python3.11
9
9
$ uv pip install -e .
10
10
$ source .venv/bin/activate
11
11
$ python
@@ -38,13 +38,83 @@ Packaging uses [`setuptools-scm`](https://github.com/pypa/setuptools-scm), so th
38
38
39
39
To run the linting, we recommend `ruff`, a standard configuration is in the repo in `pyproject.toml`.
40
40
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
+
41
112
# Releasing
42
113
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:
43
114
44
115
```bash
45
116
gh release create v[a.b.c] --prerelease --title "Kick starting the release" --target main
46
117
```
47
118
48
-
49
119
# Contributing
50
120
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