-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathrun-codespell.py
More file actions
40 lines (33 loc) · 1.02 KB
/
run-codespell.py
File metadata and controls
40 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
Copyright (C) 2024 Intel Corporation
Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""
import subprocess # nosec B404
import logging
import sys
logging.basicConfig(
level=logging.INFO, format="[%(levelname)s]: [%(asctime)s] %(message)s"
)
def codespell_scan():
try:
codespell_result = subprocess.run( # nosec
[
"codespell",
"-H",
"--quiet-level=3",
"--skip=./.git,./.venv,./.github/workflows/.spellcheck-conf.toml",
],
text=True,
stdout=subprocess.PIPE,
)
if codespell_result.returncode != 0:
for line in codespell_result.stdout.splitlines():
logging.error(line.strip())
sys.exit(1)
else:
logging.info("No spelling errors found")
except subprocess.CalledProcessError as ex:
logging.error(ex)
sys.exit(1)
codespell_scan()