From 25823ba0da4fa57b054fafe3f51047c245f11529 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Tue, 2 Jan 2024 21:35:57 -0500 Subject: [PATCH] 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. In the process, we can remove a `# type: ignore` from lddtree.py; argcomplete has typing info. So does pyelftools, but only in git master. --- .github/workflows/python.yml | 29 ++++++++++++++--------------- lddtree.py | 2 +- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 7b7dcaf..14dbae5 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -10,19 +10,18 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - # NB: v1.4.0 covers Python 3.8. - - uses: ricardochaves/python-lint@v1.4.0 + - uses: actions/setup-python@v5 with: - python-root-list: lddtree.py pylint - use-pylint: true - use-pycodestyle: false - use-flake8: false - use-black: true - use-mypy: true - use-isort: true - extra-pylint-options: "" - extra-pycodestyle-options: "" - extra-flake8-options: "" - extra-black-options: "" - extra-mypy-options: "" - extra-isort-options: "" + python-version: '3.x' + - name: install dependencies + run: | + python -m pip install pylint mypy black 'isort[colors]' + # mypy dependencies for following imported types + python -m pip install argcomplete + - run: pylint --output-format colorized lddtree.py + - run: mypy lddtree.py + env: + TERM: xterm-color + MYPY_FORCE_COLOR: 1 + - run: black --check --diff --color lddtree.py + - run: isort --check --diff --color lddtree.py diff --git a/lddtree.py b/lddtree.py index 8ccd855..0782c1b 100755 --- a/lddtree.py +++ b/lddtree.py @@ -56,7 +56,7 @@ # Disable import errors for all 3rd party modules. # pylint: disable=import-error try: - import argcomplete # type: ignore + import argcomplete except ImportError: argcomplete = cast(Any, None)