|
| 1 | +# https://pre-commit.ci/ |
| 2 | +# Configuration for Continuous Integration service |
| 3 | +ci: |
| 4 | + # Can't run Windows scons scripts on Linux. |
| 5 | + # Pyright does not seem to work in pre-commit CI |
| 6 | + skip: [unitTest, pyright] |
| 7 | + autoupdate_schedule: monthly |
| 8 | + autoupdate_commit_msg: "Pre-commit auto-update" |
| 9 | + autofix_commit_msg: "Pre-commit auto-fix" |
| 10 | + submodules: true |
| 11 | + |
| 12 | +default_language_version: |
| 13 | + python: python3.11 |
| 14 | + |
| 15 | +repos: |
| 16 | +- repo: https://github.com/pre-commit-ci/pre-commit-ci-config |
| 17 | + rev: v1.6.1 |
| 18 | + hooks: |
| 19 | + - id: check-pre-commit-ci-config |
| 20 | + |
| 21 | +- repo: meta |
| 22 | + hooks: |
| 23 | + # ensures that exclude directives apply to any file in the repository. |
| 24 | + - id: check-useless-excludes |
| 25 | + # ensures that the configured hooks apply to at least one file in the repository. |
| 26 | + - id: check-hooks-apply |
| 27 | + |
| 28 | +- repo: https://github.com/pre-commit/pre-commit-hooks |
| 29 | + rev: v5.0.0 |
| 30 | + hooks: |
| 31 | + # Prevents commits to certain branches |
| 32 | + - id: no-commit-to-branch |
| 33 | + args: ["--branch", "main"] |
| 34 | + # Checks that large files have not been added. Default cut-off for "large" files is 500kb. |
| 35 | + - id: check-added-large-files |
| 36 | + # Checks python syntax |
| 37 | + - id: check-ast |
| 38 | + # Checks for filenames that will conflict on case insensitive filesystems (the majority of Windows filesystems, most of the time) |
| 39 | + - id: check-case-conflict |
| 40 | + # Checks for artifacts from resolving merge conflicts. |
| 41 | + - id: check-merge-conflict |
| 42 | + # Checks Python files for debug statements, such as python's breakpoint function, or those inserted by some IDEs. |
| 43 | + - id: debug-statements |
| 44 | + # Removes trailing whitespace. |
| 45 | + - id: trailing-whitespace |
| 46 | + types_or: [python, batch, markdown, toml, yaml, powershell] |
| 47 | + # Ensures all files end in 1 (and only 1) newline. |
| 48 | + - id: end-of-file-fixer |
| 49 | + types_or: [python, batch, markdown, toml, yaml, powershell] |
| 50 | + # Removes the UTF-8 BOM from files that have it. |
| 51 | + # See https://github.com/nvaccess/nvda/blob/master/projectDocs/dev/codingStandards.md#encoding |
| 52 | + - id: fix-byte-order-marker |
| 53 | + types_or: [python, batch, markdown, toml, yaml, powershell] |
| 54 | + # Validates TOML files. |
| 55 | + - id: check-toml |
| 56 | + # Validates YAML files. |
| 57 | + - id: check-yaml |
| 58 | + # Ensures that links to lines in files under version control point to a particular commit. |
| 59 | + - id: check-vcs-permalinks |
| 60 | + # Avoids using reserved Windows filenames. |
| 61 | + - id: check-illegal-windows-names |
| 62 | + # Checks that tests are named test_*.py. |
| 63 | + - id: name-tests-test |
| 64 | + args: ["--unittest"] |
| 65 | + |
| 66 | +- repo: https://github.com/asottile/add-trailing-comma |
| 67 | + rev: v3.2.0 |
| 68 | + hooks: |
| 69 | + # Ruff preserves indent/new-line formatting of function arguments, list items, and similar iterables, |
| 70 | + # if a trailing comma is added. |
| 71 | + # This adds a trailing comma to args/iterable items in case it was missed. |
| 72 | + - id: add-trailing-comma |
| 73 | + |
| 74 | +- repo: https://github.com/astral-sh/ruff-pre-commit |
| 75 | + # Matches Ruff version in pyproject. |
| 76 | + rev: v0.12.7 |
| 77 | + hooks: |
| 78 | + - id: ruff |
| 79 | + name: lint with ruff |
| 80 | + args: [ --fix ] |
| 81 | + - id: ruff-format |
| 82 | + name: format with ruff |
| 83 | + |
| 84 | +- repo: https://github.com/RobertCraigie/pyright-python |
| 85 | + rev: v1.1.403 |
| 86 | + hooks: |
| 87 | + - id: pyright |
| 88 | + name: Check types with pyright |
| 89 | + |
| 90 | +- repo: https://github.com/astral-sh/uv-pre-commit |
| 91 | + rev: 0.8.4 |
| 92 | + hooks: |
| 93 | + - id: uv-lock |
| 94 | + name: Verify uv lock file |
| 95 | + # Override python interpreter from .python-versions as that is too strict for pre-commit.ci |
| 96 | + args: ["-p3.13"] |
| 97 | + |
| 98 | +- repo: local |
| 99 | + hooks: |
| 100 | + - id: unitTest |
| 101 | + name: unit tests |
| 102 | + entry: ./rununittests.bat |
| 103 | + language: script |
| 104 | + pass_filenames: false |
| 105 | + types_or: [python, batch] |
| 106 | + |
0 commit comments