-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun-all-linters
More file actions
executable file
·58 lines (47 loc) · 1.76 KB
/
run-all-linters
File metadata and controls
executable file
·58 lines (47 loc) · 1.76 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2023 Gert van Dijk <github@gertvandijk.nl>
#
# SPDX-License-Identifier: CC0-1.0
# Stop at first error.
set -e
# Allow to override path to python interpreter in order to run this from a
# non-virtualenv aware application like VS Code.
PYTHON="${PYTHON_INTERPRETER:-python}"
echo -n "Using Python interpreter at location: $PYTHON "
echo "(to override specify \$PYTHON_INTERPRETER)"
PYTHON_SOURCES_DIRS=(
src/
tests/
)
echo
echo "Ruff..."
"$PYTHON" -m ruff check --diff "${PYTHON_SOURCES_DIRS[@]}" || \
(echo "Run 'ruff check --fix ${PYTHON_SOURCES_DIRS[*]}' to fix auto-fixable."; exit 1)
# `ruff check --diff` (above) implies `--fix-only`, so it only reports auto-fixable
# changes. Requires a second pass to surface non-fixable violations too.
"$PYTHON" -m ruff check "${PYTHON_SOURCES_DIRS[@]}"
echo "OK!"
echo "Ruff format..."
"$PYTHON" -m ruff format --diff || (echo "Run 'ruff format' to fix."; exit 1)
echo "OK!"
# Other than '--cache-dir=/dev/null', mypy options are specified in pyproject.toml.
# Keep in sync with /.vscode/settings.json, key 'python.linting.mypyArgs', except for
# the '--cache-dir' option.
# Observed weird inconsistent results with default --cache-dir enabled (mypy 0.971);
# disable cache explicitly for this script.
echo "mypy (PyKMP package)..."
"$PYTHON" -m mypy --cache-dir=/dev/null --package pykmp
echo "mypy (PyKMP tests folder)..."
"$PYTHON" -m mypy --cache-dir=/dev/null ./tests
echo "OK!"
echo "Pyright..."
"$PYTHON" -m pyright
echo "OK!"
echo "REUSE lint..."
"$PYTHON" -m reuse lint -q 2>/dev/null \
|| (echo "Run 'reuse lint' to view licensing issues."; exit 1)
echo "OK!"
echo "validate-pyproject..."
"$PYTHON" -m validate_pyproject pyproject.toml
echo "OK!"
echo "Everything looks OK! 🎉"