Use ruff for linting
Use ruff instead of flake8. Aside from being substantially faster, ruff includes a lot of flake's plug-ins built-in, some of which may be useful to enable as a follow-up. Also move the relevant configuration out of the script in .ci/ and into the project-wide settings. A side effect of this is that IDEs should detect these settings, and ignore the same rules as CI, avoiding false positives while developing locally. Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org> Reviewed-by: Luca Weiss <luca@z3ntu.xyz> Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20230529203448.18656-1-hugo@whynothugo.nl%3E
This commit is contained in:
parent
ecb7660f15
commit
27618d5ffd
|
@ -9,9 +9,9 @@ tasks:
|
||||||
- shellcheck: |
|
- shellcheck: |
|
||||||
cd pmbootstrap
|
cd pmbootstrap
|
||||||
sudo .ci/shellcheck.sh
|
sudo .ci/shellcheck.sh
|
||||||
- flake8: |
|
- ruff: |
|
||||||
cd pmbootstrap
|
cd pmbootstrap
|
||||||
sudo .ci/flake8.sh
|
sudo .ci/ruff.sh
|
||||||
- vermin: |
|
- vermin: |
|
||||||
cd pmbootstrap
|
cd pmbootstrap
|
||||||
sudo .ci/vermin.sh
|
sudo .ci/vermin.sh
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
#!/bin/sh -e
|
|
||||||
# Description: lint all python scripts
|
|
||||||
# https://postmarketos.org/pmb-ci
|
|
||||||
|
|
||||||
if [ "$(id -u)" = 0 ]; then
|
|
||||||
set -x
|
|
||||||
apk -q add py3-flake8
|
|
||||||
exec su "${TESTUSER:-build}" -c "sh -e $0"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# E402: module import not on top of file, not possible for testcases
|
|
||||||
# E722: do not use bare except
|
|
||||||
# W504: line break occurred after a binary operator
|
|
||||||
ign="E402,E722,W504"
|
|
||||||
|
|
||||||
set -x
|
|
||||||
|
|
||||||
# __init__.py with additional ignore:
|
|
||||||
# F401: imported, but not used
|
|
||||||
# shellcheck disable=SC2046
|
|
||||||
flake8 --ignore "F401,$ign" $(find . -not -path '*/venv/*' -name '__init__.py')
|
|
||||||
|
|
||||||
# Check all other files
|
|
||||||
flake8 --ignore="$ign" --exclude=__init__.py
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/sh -e
|
||||||
|
# Description: lint all python scripts
|
||||||
|
# https://postmarketos.org/pmb-ci
|
||||||
|
|
||||||
|
if [ "$(id -u)" = 0 ]; then
|
||||||
|
set -x
|
||||||
|
apk -q add ruff
|
||||||
|
exec su "${TESTUSER:-build}" -c "sh -e $0"
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
# __init__.py with additional ignore:
|
||||||
|
# F401: imported, but not used
|
||||||
|
# shellcheck disable=SC2046
|
||||||
|
ruff --ignore "F401" $(find . -not -path '*/venv/*' -name '__init__.py')
|
||||||
|
|
||||||
|
# Check all other files
|
||||||
|
ruff --exclude=__init__.py .
|
|
@ -16,7 +16,7 @@ def get_ci_scripts(topdir):
|
||||||
:param topdir: top directory of the git repository, get it with:
|
:param topdir: top directory of the git repository, get it with:
|
||||||
pmb.helpers.git.get_topdir()
|
pmb.helpers.git.get_topdir()
|
||||||
:returns: a dict of CI scripts found in the git repository, e.g.
|
:returns: a dict of CI scripts found in the git repository, e.g.
|
||||||
{"flake8": {"description": "lint all python scripts",
|
{"ruff": {"description": "lint all python scripts",
|
||||||
"options": []},
|
"options": []},
|
||||||
...} """
|
...} """
|
||||||
ret = {}
|
ret = {}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
[tool.ruff]
|
||||||
|
# E402: module import not on top of file, not possible for testcases
|
||||||
|
# E722: do not use bare except
|
||||||
|
ignore=["E402", "E722"]
|
||||||
|
line-length=100
|
Loading…
Reference in New Issue