Hugo Osvaldo Barrera: 1 Use ruff for linting 6 files changed, 27 insertions(+), 30 deletions(-)
Copy & paste the following snippet into your terminal to import this patchset into git:
curl -s https://lists.sr.ht/~postmarketos/pmbootstrap-devel/patches/41487/mbox | git am -3Learn more about email & git
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.
CI error is wrong since it (I believe on purpose) doesn't use the build.yml from the patch but the one from the repo. Should work fine when applied to git. Reviewed-by: Luca Weiss <luca@z3ntu.xyz>
Thanks! Reviewed-by: Oliver Smith <ollieparanoid@postmarketos.org>
--- .build.yml | 4 ++-- .ci/flake8.sh | 24 ------------------------ .ci/ruff.sh | 19 +++++++++++++++++++ pmb/ci/__init__.py | 2 +- pyproject.toml | 5 +++++ setup.cfg | 3 --- 6 files changed, 27 insertions(+), 30 deletions(-) delete mode 100755 .ci/flake8.sh create mode 100755 .ci/ruff.sh create mode 100644 pyproject.toml diff --git a/.build.yml b/.build.yml index f700a3bc..5914c34e 100644 --- a/.build.yml +++ b/.build.yml @@ -9,9 +9,9 @@ tasks: - shellcheck: | cd pmbootstrap sudo .ci/shellcheck.sh - - flake8: | + - ruff: | cd pmbootstrap - sudo .ci/flake8.sh + sudo .ci/ruff.sh - vermin: | cd pmbootstrap sudo .ci/vermin.sh diff --git a/.ci/flake8.sh b/.ci/flake8.sh deleted file mode 100755 index 7aabef94..00000000 --- a/.ci/flake8.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 diff --git a/.ci/ruff.sh b/.ci/ruff.sh new file mode 100755 index 00000000..edf721d0 --- /dev/null +++ b/.ci/ruff.sh @@ -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 . diff --git a/pmb/ci/__init__.py b/pmb/ci/__init__.py index 6d2f1e71..39d3c61a 100644 --- a/pmb/ci/__init__.py +++ b/pmb/ci/__init__.py @@ -16,7 +16,7 @@ def get_ci_scripts(topdir): :param topdir: top directory of the git repository, get it with: pmb.helpers.git.get_topdir() :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": []}, ...} """ ret = {} diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..4f99e226 --- /dev/null +++ b/pyproject.toml @@ -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 diff --git a/setup.cfg b/setup.cfg index c8ecd261..aa76baec 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,2 @@ [bdist_wheel] universal=0 - -[flake8] -max-line-length=100 -- 2.40.1
builds.sr.ht <builds@sr.ht>pmbootstrap/patches/.build.yml: FAILED in 38s [Use ruff for linting][0] from [Hugo Osvaldo Barrera][1] [0]: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/patches/41487 [1]: mailto:hugo@whynothugo.nl ✗ #998164 FAILED pmbootstrap/patches/.build.yml https://builds.sr.ht/~postmarketos/job/998164
Applied, thanks! [1/1] Use ruff for linting commit: 27618d5ffdb0b6cbf9471dc01a2ed14e1655ced0 Best regards