|
1 | | -# Formatting and checks, as in the salt-extension copier template. |
2 | | -# Install with: pre-commit install |
| 1 | +--- |
| 2 | +minimum_pre_commit_version: 2.4.0 |
3 | 3 | repos: |
4 | 4 | - repo: https://github.com/pre-commit/pre-commit-hooks |
5 | | - rev: v5.0.0 |
| 5 | + rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # v6.0.0 |
6 | 6 | hooks: |
7 | | - - id: check-merge-conflict |
8 | | - - id: trailing-whitespace |
| 7 | + - id: check-merge-conflict # Check for files that contain merge conflict strings. |
| 8 | + args: [--assume-in-merge] |
| 9 | + - id: trailing-whitespace # Trim trailing whitespace. |
9 | 10 | args: [--markdown-linebreak-ext=md] |
10 | | - - id: end-of-file-fixer |
11 | | - - id: check-yaml |
12 | | - - id: check-toml |
13 | | - - id: debug-statements |
| 11 | + - id: mixed-line-ending # Ensure files use UNIX-style newlines only. |
| 12 | + args: [--fix=lf] |
| 13 | + - id: end-of-file-fixer # Ensure files end with a newline. |
| 14 | + - id: check-ast # Check whether files parse as valid Python. |
| 15 | + |
| 16 | + # ----- Formatting ----------------------------------------------------------------------------> |
| 17 | + - repo: https://github.com/saltstack/pre-commit-remove-import-headers |
| 18 | + rev: e79f595c0df31b8cb152c53993ce7c3c64f07cd4 # 1.1.0 |
| 19 | + hooks: |
| 20 | + - id: remove-import-headers |
| 21 | + |
| 22 | + - repo: local |
| 23 | + hooks: |
| 24 | + - id: check-cli-examples |
| 25 | + name: Check CLI examples on execution modules |
| 26 | + entry: python .pre-commit-hooks/check-cli-examples.py |
| 27 | + language: python |
| 28 | + files: ^src/saltext/noderings/modules/.*\.py$ |
| 29 | + |
| 30 | + - repo: local |
| 31 | + hooks: |
| 32 | + - id: check-docs |
| 33 | + name: Check rST doc files exist for modules/states |
| 34 | + entry: python .pre-commit-hooks/make-autodocs.py |
| 35 | + language: python |
| 36 | + pass_filenames: false |
| 37 | + |
| 38 | + - repo: https://github.com/saltstack/salt-rewrite |
| 39 | + # Automatically rewrite code with known rules |
| 40 | + rev: 2401c0faef69b6b846c719d611bcfe358234d5d1 # 2.5.2 |
| 41 | + hooks: |
| 42 | + - id: salt-rewrite |
| 43 | + alias: rewrite-docstrings |
| 44 | + name: Salt extensions docstrings auto-fixes |
| 45 | + files: ^src/saltext/noderings/.*\.py$ |
| 46 | + args: [--silent] |
| 47 | + |
| 48 | + - repo: https://github.com/saltstack/salt-rewrite |
| 49 | + # Automatically rewrite code with known rules |
| 50 | + rev: 2401c0faef69b6b846c719d611bcfe358234d5d1 # 2.5.2 |
| 51 | + hooks: |
| 52 | + - id: salt-rewrite |
| 53 | + alias: rewrite-tests |
| 54 | + name: Rewrite the test suite |
| 55 | + files: ^tests/.*\.py$ |
| 56 | + args: [--silent, -E, fix_docstrings] |
14 | 57 |
|
15 | 58 | - repo: https://github.com/asottile/pyupgrade |
16 | | - rev: v3.20.0 |
| 59 | + rev: 75992aaa40730136014f34227e0135f63fc951b4 # v3.21.2 |
17 | 60 | hooks: |
18 | 61 | - id: pyupgrade |
19 | | - args: [--py311-plus] |
| 62 | + name: Rewrite Code to be Py3.11+ |
| 63 | + args: [ |
| 64 | + --py311-plus, |
| 65 | + ] |
20 | 66 | exclude: src/saltext/noderings/version.py |
21 | 67 |
|
22 | 68 | - repo: https://github.com/PyCQA/isort |
23 | | - rev: 8.0.1 |
| 69 | + rev: a333737ed43df02b18e6c95477ea1b285b3de15a # 8.0.1 |
24 | 70 | hooks: |
25 | 71 | - id: isort |
26 | | - args: [--py, "311"] |
| 72 | + args: [ |
| 73 | + --py 311, |
| 74 | + ] |
27 | 75 | exclude: src/saltext/noderings/(__init__|version).py |
28 | 76 |
|
29 | 77 | - repo: https://github.com/psf/black |
30 | | - rev: 26.5.1 |
| 78 | + rev: 87928e6d6761a4a6d22250e1fee5601b3998086e # 26.5.1 |
31 | 79 | hooks: |
32 | 80 | - id: black |
33 | | - args: [-l, "100"] |
| 81 | + args: [-l 100] |
| 82 | + exclude: src/saltext/noderings/version.py |
| 83 | + |
| 84 | + - repo: https://github.com/adamchainz/blacken-docs |
| 85 | + rev: fda77690955e9b63c6687d8806bafd56a526e45f # 1.20.0 |
| 86 | + hooks: |
| 87 | + - id: blacken-docs |
| 88 | + args: [--skip-errors] |
| 89 | + files: ^(docs/.*\.rst|src/saltext/noderings/.*\.py)$ |
| 90 | + additional_dependencies: |
| 91 | + - black==26.5.1 |
| 92 | + # <---- Formatting ----------------------------------------------------------------------------- |
| 93 | + |
| 94 | + # ----- Security ------------------------------------------------------------------------------> |
| 95 | + - repo: https://github.com/PyCQA/bandit |
| 96 | + rev: 92ae8b82fb422a639f0ed8d99e96cea769594e08 # 1.9.4 |
| 97 | + hooks: |
| 98 | + - id: bandit |
| 99 | + alias: bandit-salt |
| 100 | + name: Run bandit against the code base |
| 101 | + args: [--silent, -lll, --skip, B701] |
34 | 102 | exclude: src/saltext/noderings/version.py |
35 | 103 |
|
36 | 104 | - repo: https://github.com/PyCQA/bandit |
37 | | - rev: 1.8.3 |
| 105 | + rev: 92ae8b82fb422a639f0ed8d99e96cea769594e08 # 1.9.4 |
38 | 106 | hooks: |
39 | 107 | - id: bandit |
| 108 | + alias: bandit-tests |
| 109 | + name: Run bandit against the test suite |
40 | 110 | args: [--silent, -lll, --skip, B701] |
41 | | - exclude: ^tests/ |
| 111 | + files: ^tests/.* |
| 112 | + # <---- Security ------------------------------------------------------------------------------- |
| 113 | + |
| 114 | + # ----- Code Analysis -------------------------------------------------------------------------> |
| 115 | + |
| 116 | + - repo: local |
| 117 | + hooks: |
| 118 | + - id: nox |
| 119 | + alias: lint-src |
| 120 | + name: Lint Source Code |
| 121 | + language: python |
| 122 | + entry: nox -e lint-code-pre-commit -- |
| 123 | + files: ^((setup|noxfile)|src/.*)\.py$ |
| 124 | + require_serial: true |
| 125 | + additional_dependencies: |
| 126 | + - nox==2026.4.10 |
| 127 | + - uv==0.11.26 # Makes this hook much faster |
| 128 | + |
| 129 | + - id: nox |
| 130 | + alias: lint-tests |
| 131 | + name: Lint Tests |
| 132 | + language: python |
| 133 | + entry: nox -e lint-tests-pre-commit -- |
| 134 | + files: ^tests/.*\.py$ |
| 135 | + require_serial: true |
| 136 | + additional_dependencies: |
| 137 | + - nox==2026.4.10 |
| 138 | + - uv==0.11.26 # Makes this hook much faster |
| 139 | + |
| 140 | + - repo: https://github.com/Mateusz-Grzelinski/actionlint-py |
| 141 | + rev: 694e2c0dfb4253d51f3c6c54b8f9fec0a16764dc # v1.7.11.24 |
| 142 | + hooks: |
| 143 | + - id: actionlint |
| 144 | + additional_dependencies: |
| 145 | + - shellcheck-py==0.11.0.1 |
| 146 | + # <---- Code Analysis -------------------------------------------------------------------------- |
0 commit comments