|
1 | | -# pre-commit is a tool that you run locally |
2 | | -# to perform a predefined set of tasks manually and/or |
3 | | -# automatically before git commits are made. |
4 | | -# Here we are using pre-commit with the precommit.ci bot to implement |
5 | | -# code fixes automagically in pr's. You will still want to install pre-commit |
6 | | -# to run locally |
7 | | -# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level |
8 | | -# To run on a pr, add a comment with the text "pre-commit.ci run" |
9 | | -# Common tasks |
10 | | -# |
11 | | -# - Run on all files: pre-commit run --all-files |
12 | | -# - Register git hooks: pre-commit install --install-hooks |
| 1 | +# pre-commit (https://pre-commit.com/) is a tool that runs source code checks |
| 2 | +# such as linting, formatting, and code style. |
| 3 | + |
| 4 | +# CI |
| 5 | +# pyosMeta uses pre-commit with the precommit.ci bot to check pull requests. |
| 6 | +# Configuration reference doc: https://pre-commit.com/#pre-commit-configyaml---top-level |
| 7 | + |
| 8 | +# Developers |
| 9 | +# You may want to install pre-commit to run locally on each minimum_pre_commit_version |
| 10 | +# See https://pre-commit.com/#install |
| 11 | +# To set up pre-commit hooks: pre-commit install |
| 12 | +# To run on all files: pre-commit run --all-files |
13 | 13 |
|
14 | 14 | ci: |
| 15 | + # pyosMeta disables autofixing of PRs to simplify new contributor experience and cleaner git history |
15 | 16 | autofix_prs: false |
16 | | - #skip: [flake8, end-of-file-fixer] |
17 | | - autofix_commit_msg: | |
18 | | - '[pre-commit.ci 🤖] Apply code format tools to PR' |
19 | | - # Update hook versions every quarter (so we don't get hit with weekly update pr's) |
| 17 | + # Frequency of hook updates |
20 | 18 | autoupdate_schedule: weekly |
21 | 19 |
|
22 | 20 | repos: |
23 | | - # Misc commit checks |
| 21 | + # Out of the box hooks for pre-commit https://github.com/pre-commit/pre-commit-hooks |
24 | 22 | - repo: https://github.com/pre-commit/pre-commit-hooks |
25 | 23 | rev: v4.5.0 |
26 | | - # ref: https://github.com/pre-commit/pre-commit-hooks#hooks-available |
27 | 24 | hooks: |
28 | | - # Autoformat: Makes sure files end in a newline and only a newline. |
| 25 | + # Makes sure files end in a newline and only a newline. |
29 | 26 | - id: end-of-file-fixer |
30 | | - # Lint: Check for files with names that would conflict on a |
31 | | - # case-insensitive filesystem like MacOS HFS+ or Windows FAT. |
| 27 | + # Check for files with names that would conflict on a case-insensitive filesystem like MacOS HFS+ or Windows FAT. |
32 | 28 | - id: check-case-conflict |
| 29 | + # Remove trailing whitespace on code lines |
33 | 30 | - id: trailing-whitespace |
34 | 31 |
|
| 32 | + # Spelling hook |
35 | 33 | - repo: https://github.com/codespell-project/codespell |
36 | 34 | rev: v2.2.6 |
37 | 35 | hooks: |
38 | 36 | - id: codespell |
39 | 37 | additional_dependencies: |
40 | 38 | - tomli |
41 | 39 |
|
42 | | - # Linting: Python code (see the file .flake8) |
| 40 | + # Linting hook for Python code (see the file .flake8) |
43 | 41 | - repo: https://github.com/PyCQA/flake8 |
44 | 42 | rev: "7.0.0" |
45 | 43 | hooks: |
46 | 44 | - id: flake8 |
47 | 45 |
|
| 46 | + # Code formatting hook |
48 | 47 | - repo: https://github.com/psf/black |
49 | 48 | rev: 24.2.0 |
50 | 49 | hooks: |
51 | 50 | - id: black |
52 | 51 |
|
| 52 | + # Best practice style for module imports |
53 | 53 | - repo: https://github.com/PyCQA/isort |
54 | 54 | rev: 5.13.2 |
55 | 55 | hooks: |
|
0 commit comments