Skip to content

Commit 2fddf4f

Browse files
authored
Add zizmor as pre-commit hook (#87)
* Run zizmor to pre-commit and update other hooks * Address feedback from zizmor * Address new suggestions from ruff
1 parent a1e6dfe commit 2fddf4f

File tree

6 files changed

+16
-6
lines changed

6 files changed

+16
-6
lines changed

.github/workflows/cd.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
- uses: actions/checkout@v5
2727
with:
2828
fetch-depth: 0
29+
persist-credentials: false
2930

3031
- uses: actions/setup-python@v6
3132
with:

.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
branches:
88
- main
99

10+
permissions: {}
11+
1012
concurrency:
1113
group: ${{ github.workflow }}-${{ github.ref }}
1214
cancel-in-progress: true
@@ -30,10 +32,11 @@ jobs:
3032
- uses: actions/checkout@v5
3133
with:
3234
fetch-depth: 0
35+
persist-credentials: false
3336
- uses: actions/setup-python@v6
3437
with:
3538
python-version: "3.x"
36-
- uses: pre-commit/action@v3.0.1
39+
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
3740
with:
3841
extra_args: --hook-stage manual --all-files
3942

@@ -53,6 +56,7 @@ jobs:
5356
- uses: actions/checkout@v5
5457
with:
5558
fetch-depth: 0
59+
persist-credentials: false
5660

5761
- uses: actions/setup-python@v6
5862
with:

.pre-commit-config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ repos:
2727
args: [--markdown-linebreak-ext=md]
2828

2929
- repo: https://github.com/astral-sh/ruff-pre-commit
30-
rev: "0acff885bcb16381b67930fefb91e460202f172c" # frozen: v0.12.10
30+
rev: "f298305809c552671cc47e0fec0ba43e96c146a2" # frozen: v0.13.2
3131
hooks:
3232
- id: ruff-check
3333
args: ["--fix", "--show-fixes", "--exit-non-zero-on-fix"]
3434
- id: ruff-format
35+
36+
- repo: https://github.com/woodruffw/zizmor-pre-commit
37+
rev: 3c10df247c55cf21f75003105b879f145096bd4a # frozen: v1.14.2
38+
hooks:
39+
- id: zizmor

tests/test_cache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
def test_directory_size():
1010
assert _cache._directory_size(Path(__file__).parent) > 0
11-
with pytest.raises(FileNotFoundError, match="doesn't exist, can't determine size"):
11+
with pytest.raises(FileNotFoundError, match=r"doesn't exist, can't determine size"):
1212
_cache._directory_size(Path("i/don't/exist"))
1313

1414

@@ -42,7 +42,7 @@ def test_create_validate_cache(tmp_path):
4242
_cache.create_cache(cache_dir)
4343
_cache.validate_cache(cache_dir)
4444

45-
with pytest.raises(FileNotFoundError, match="expected directory .* named .*"):
45+
with pytest.raises(FileNotFoundError, match=r"expected directory .* named .*"):
4646
_cache.validate_cache(tmp_path)
4747

4848

tests/test_docstrings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_as_return_tuple(self):
2929
assert return_annotation.imports == path_anno.imports | sequence_anno.imports
3030

3131
def test_unexpected_value(self):
32-
with pytest.raises(ValueError, match="unexpected '~' in annotation value"):
32+
with pytest.raises(ValueError, match=r"unexpected '~' in annotation value"):
3333
Annotation(value="~.foo")
3434

3535

tests/test_path_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_not_a_package(self, tmp_path):
4646
top_script = tmp_path / "script.py"
4747
top_script.touch()
4848

49-
with pytest.raises(TypeError, match=".* must be a Python file or package"):
49+
with pytest.raises(TypeError, match=r".* must be a Python file or package"):
5050
next(walk_source_package(tmp_path))
5151

5252
def test_single_with_docstub_generated_stub(self, tmp_path):

0 commit comments

Comments
 (0)