Skip to content

Commit 5c1444c

Browse files
committed
github: switch the python checker CI to use something that is maintained
The python-lint action was last updated 3 years ago. It contains very old versions of the lint tools, including pre-1.0 versions of mypy. It doesn't allow installing dependencies for mypy to robustly typecheck. Simply installing the tools ourselves and running them directly is simpler, shorter, easier, and provides better linting analysis. So, do so. Another advantage is that we can now run all the linting tools, even if an earlier one failed. As long as one step fails, the overall status is still a failure. In the process, we can remove a `# type: ignore` from lddtree.py; argcomplete has typing info. So does pyelftools, but only in git master.
1 parent b71d01d commit 5c1444c

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

.github/workflows/python.yml

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,39 @@ name: Python
55

66
on: [push, pull_request]
77

8+
env:
9+
# Reusable list of files to check -- parsed by bash, so does not support
10+
# whitespace.
11+
CHECK_FILES: lddtree.py pylint
12+
813
jobs:
914
python:
1015
runs-on: ubuntu-latest
1116
steps:
1217
- uses: actions/checkout@v4
13-
# NB: v1.4.0 covers Python 3.8.
14-
- uses: ricardochaves/python-lint@v1.4.0
18+
- uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.x'
21+
- uses: actions/cache@v3
1522
with:
16-
python-root-list: lddtree.py pylint
17-
use-pylint: true
18-
use-pycodestyle: false
19-
use-flake8: false
20-
use-black: true
21-
use-mypy: true
22-
use-isort: true
23-
extra-pylint-options: ""
24-
extra-pycodestyle-options: ""
25-
extra-flake8-options: ""
26-
extra-black-options: ""
27-
extra-mypy-options: ""
28-
extra-isort-options: ""
23+
path: ~/.cache/pip
24+
key: lint-pip-${{ github.run_number }}
25+
restore-keys: lint-pip-
26+
- name: install dependencies
27+
run: |
28+
pkgs=(
29+
pylint mypy black 'isort[colors]'
30+
# mypy dependencies for following imported types.
31+
argcomplete
32+
)
33+
python -m pip install "${pkgs[@]}"
34+
- run: pylint --output-format colorized $CHECK_FILES
35+
- run: mypy $CHECK_FILES
36+
if: success() || failure()
37+
env:
38+
TERM: xterm-color
39+
MYPY_FORCE_COLOR: 1
40+
- run: black --check --diff --color $CHECK_FILES
41+
if: success() || failure()
42+
- run: isort --check --diff --color $CHECK_FILES
43+
if: success() || failure()

lddtree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
# Disable import errors for all 3rd party modules.
5757
# pylint: disable=import-error
5858
try:
59-
import argcomplete # type: ignore
59+
import argcomplete
6060
except ImportError:
6161
argcomplete = cast(Any, None)
6262

0 commit comments

Comments
 (0)