Skip to content

Commit 56fc03e

Browse files
committed
Use pathspec.PathSpec.from_lines("gitwildmatch", ...) to ignore all .md files.
1 parent 822217b commit 56fc03e

3 files changed

Lines changed: 16 additions & 65 deletions

File tree

.pre-commit-config.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ repos:
2424
hooks:
2525
- id: check-spdx
2626
name: Check SPDX-License-Identifier
27-
entry: ./toolshed/check_spdx.py
28-
language: system
27+
entry: python ./toolshed/check_spdx.py
28+
language: python
29+
additional_dependencies:
30+
- pathspec
2931

3032
- repo: https://github.com/PyCQA/bandit
3133
rev: 8ff25e07e487f143571cc305e56dd0253c60bc7b #v1.8.3

.spdx-ignore

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
# Cleanup hint: tail -n +2 .spdx-ignore | LC_ALL=C sort | uniq
1+
*.md
22
.gitattributes
33
.github/BACKPORT_BRANCH
4-
.github/PULL_REQUEST_TEMPLATE.md
54
.github/copy-pr-bot.yaml
65
.gitignore
7-
CONTRIBUTING.md
8-
LICENSE.md
9-
README.md
10-
SECURITY.md
116
ci/versions.json
127
cuda_bindings/LICENSE
138
cuda_bindings/MANIFEST.in
14-
cuda_bindings/README.md
159
cuda_bindings/benchmarks/conftest.py
1610
cuda_bindings/benchmarks/kernels.py
1711
cuda_bindings/benchmarks/pytest.ini
@@ -46,7 +40,6 @@ cuda_bindings/cuda/bindings/_lib/param_packer.h
4640
cuda_bindings/cuda/bindings/_lib/param_packer.pxd
4741
cuda_bindings/cuda/bindings/_lib/utils.pxd.in
4842
cuda_bindings/cuda/bindings/_lib/utils.pyx.in
49-
cuda_bindings/cuda/bindings/_path_finder/README.md
5043
cuda_bindings/cuda/bindings/_version.py
5144
cuda_bindings/cuda/bindings/cydriver.pxd.in
5245
cuda_bindings/cuda/bindings/cydriver.pyx.in
@@ -72,7 +65,6 @@ cuda_bindings/cuda/cuda.pyx
7265
cuda_bindings/cuda/cudart.pyx
7366
cuda_bindings/cuda/nvrtc.pyx
7467
cuda_bindings/docs/Makefile
75-
cuda_bindings/docs/README.md
7668
cuda_bindings/docs/build_docs.sh
7769
cuda_bindings/docs/make.bat
7870
cuda_bindings/docs/source/_static/images/Nsight-Compute-CLI-625x473.png
@@ -81,37 +73,7 @@ cuda_bindings/docs/source/_static/logo-dark-mode.png
8173
cuda_bindings/docs/source/_static/logo-light-mode.png
8274
cuda_bindings/docs/source/_templates/main.html
8375
cuda_bindings/docs/source/_templates/sidebar/variant-selector.html
84-
cuda_bindings/docs/source/conduct.md
8576
cuda_bindings/docs/source/conf.py
86-
cuda_bindings/docs/source/contribute.md
87-
cuda_bindings/docs/source/environment_variables.md
88-
cuda_bindings/docs/source/install.md
89-
cuda_bindings/docs/source/motivation.md
90-
cuda_bindings/docs/source/overview.md
91-
cuda_bindings/docs/source/release/11.4.0-notes.md
92-
cuda_bindings/docs/source/release/11.5.0-notes.md
93-
cuda_bindings/docs/source/release/11.6.0-notes.md
94-
cuda_bindings/docs/source/release/11.6.1-notes.md
95-
cuda_bindings/docs/source/release/11.7.0-notes.md
96-
cuda_bindings/docs/source/release/11.7.1-notes.md
97-
cuda_bindings/docs/source/release/11.8.0-notes.md
98-
cuda_bindings/docs/source/release/11.8.1-notes.md
99-
cuda_bindings/docs/source/release/11.8.2-notes.md
100-
cuda_bindings/docs/source/release/11.8.3-notes.md
101-
cuda_bindings/docs/source/release/11.8.4-notes.md
102-
cuda_bindings/docs/source/release/11.8.5-notes.md
103-
cuda_bindings/docs/source/release/11.8.6-notes.md
104-
cuda_bindings/docs/source/release/12.0.0-notes.md
105-
cuda_bindings/docs/source/release/12.1.0-notes.md
106-
cuda_bindings/docs/source/release/12.2.0-notes.md
107-
cuda_bindings/docs/source/release/12.2.1-notes.md
108-
cuda_bindings/docs/source/release/12.3.0-notes.md
109-
cuda_bindings/docs/source/release/12.4.0-notes.md
110-
cuda_bindings/docs/source/release/12.5.0-notes.md
111-
cuda_bindings/docs/source/release/12.6.0-notes.md
112-
cuda_bindings/docs/source/release/12.6.1-notes.md
113-
cuda_bindings/docs/source/release/12.6.2-notes.md
114-
cuda_bindings/docs/source/release/12.8.0-notes.md
11577
cuda_bindings/docs/versions.json
11678
cuda_bindings/examples/0_Introduction/clock_nvrtc_test.py
11779
cuda_bindings/examples/0_Introduction/simpleCubemapTexture_test.py
@@ -147,19 +109,15 @@ cuda_bindings/tests/test_interoperability.py
147109
cuda_bindings/tests/test_kernelParams.py
148110
cuda_bindings/tests/test_nvrtc.py
149111
cuda_core/LICENSE
150-
cuda_core/README.md
151112
cuda_core/cuda/core/__init__.pxd
152113
cuda_core/cuda/core/experimental/dlpack.h
153114
cuda_core/docs/Makefile
154-
cuda_core/docs/README.md
155115
cuda_core/docs/build_docs.sh
156116
cuda_core/docs/source/_static/javascripts/version_dropdown.js
157117
cuda_core/docs/source/_static/logo-dark-mode.png
158118
cuda_core/docs/source/_static/logo-light-mode.png
159119
cuda_core/docs/source/_templates/main.html
160120
cuda_core/docs/source/_templates/sidebar/variant-selector.html
161-
cuda_core/docs/source/conduct.md
162-
cuda_core/docs/source/install.md
163121
cuda_core/docs/versions.json
164122
cuda_core/tests/conftest.py
165123
cuda_core/tests/cython/build_tests.sh
@@ -178,7 +136,6 @@ cuda_core/tests/test_stream.py
178136
cuda_core/tests/test_system.py
179137
cuda_python/LICENSE
180138
cuda_python/docs/Makefile
181-
cuda_python/docs/README.md
182139
cuda_python/docs/build_all_docs.sh
183140
cuda_python/docs/build_docs.sh
184141
cuda_python/docs/environment-docs.yml
@@ -188,9 +145,4 @@ cuda_python/docs/source/_static/logo-light-mode.png
188145
cuda_python/docs/source/_templates/main.html
189146
cuda_python/docs/source/_templates/sidebar/variant-selector.html
190147
cuda_python/docs/source/conf.py
191-
cuda_python/docs/source/release.md
192-
cuda_python/docs/source/release/11.8.6-notes.md
193-
cuda_python/docs/source/release/12.6.1-notes.md
194-
cuda_python/docs/source/release/12.6.2-notes.md
195-
cuda_python/docs/source/release/12.8.0-notes.md
196148
cuda_python/docs/versions.json

toolshed/check_spdx.py

100755100644
Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#!/usr/bin/env python3
2-
31
# Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
42
# SPDX-License-Identifier: Apache-2.0
53

64
import os
75
import sys
86

7+
import pathspec
8+
99
# Intentionally puzzling together EXPECTED_SPDX_STR so that we don't overlook
1010
# if the identifier is missing in this file.
1111
EXPECTED_SPDX_STR = "-".join(("SPDX", "License", "Identifier: "))
@@ -15,16 +15,13 @@
1515

1616

1717
def load_spdx_ignore():
18-
if not os.path.exists(SPDX_IGNORE_FILENAME):
19-
return set()
20-
lines = []
21-
with open(SPDX_IGNORE_FILENAME, "r", encoding="utf-8") as f:
22-
for line in f.read().splitlines():
23-
if not line.startswith("#"):
24-
lines.append(line)
25-
ignore_set = set(lines)
26-
ignore_set.add(SPDX_IGNORE_FILENAME)
27-
return ignore_set
18+
if os.path.exists(SPDX_IGNORE_FILENAME):
19+
with open(SPDX_IGNORE_FILENAME, "r", encoding="utf-8") as f:
20+
lines = f.readlines()
21+
else:
22+
lines = []
23+
lines.append(SPDX_IGNORE_FILENAME + "\n")
24+
return pathspec.PathSpec.from_lines("gitwildmatch", lines)
2825

2926

3027
def has_spdx(filepath):
@@ -36,11 +33,11 @@ def has_spdx(filepath):
3633
def main(args):
3734
assert args, "filepaths expected to be passed from pre-commit"
3835

39-
ignore_set = load_spdx_ignore()
36+
ignore_spec = load_spdx_ignore()
4037

4138
returncode = 0
4239
for filepath in args:
43-
if not has_spdx(filepath) and filepath not in ignore_set:
40+
if not ignore_spec.match_file(filepath) and not has_spdx(filepath):
4441
print(f"MISSING {EXPECTED_SPDX_STR} {filepath!r}")
4542
returncode = 1
4643
return returncode

0 commit comments

Comments
 (0)