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 +++ /dev/null @@ -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