forked from drath/libratbag
build: add Ruff for Python code linting
This commit is contained in:
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -8,7 +8,7 @@ env:
|
||||
libjson-glib-dev libsystemd-dev libudev-dev libunistring-dev
|
||||
python3-dev python3-evdev swig python3-sphinx
|
||||
UBUNTU_DEP_TEST: check python3-gi python3-lxml valgrind
|
||||
PIP_PACKAGES: meson ninja libevdev pyudev pytest sphinx_rtd_theme black
|
||||
PIP_PACKAGES: meson ninja libevdev pyudev pytest sphinx_rtd_theme black ruff
|
||||
|
||||
jobs:
|
||||
build-and-dist:
|
||||
|
||||
17
meson.build
17
meson.build
@@ -649,4 +649,21 @@ test(
|
||||
env: env_test,
|
||||
)
|
||||
|
||||
#### code linting #####
|
||||
run_target(
|
||||
'python-ruff',
|
||||
command : 'tools/python-ruff.sh',
|
||||
)
|
||||
|
||||
python_ruff_check = find_program(join_paths(meson.source_root(), 'test/python-ruff-check.sh'))
|
||||
run_target(
|
||||
'python-ruff-check',
|
||||
command : python_ruff_check,
|
||||
)
|
||||
test(
|
||||
'python-ruff-check',
|
||||
python_ruff_check,
|
||||
env: env_test,
|
||||
)
|
||||
|
||||
subdir('doc')
|
||||
|
||||
@@ -1,2 +1,23 @@
|
||||
[tool.black]
|
||||
target-version = ["py37"]
|
||||
|
||||
[tool.ruff]
|
||||
target-version = "py37"
|
||||
select = [
|
||||
# pycodestyle
|
||||
"E",
|
||||
"W",
|
||||
# pyflakes
|
||||
"F",
|
||||
# pyupgrade
|
||||
# Use modern Python features for the best possible develop experience.
|
||||
"UP",
|
||||
# flake8-bugbear
|
||||
# Find obvious bugs.
|
||||
"B",
|
||||
]
|
||||
ignore = [
|
||||
# Line too long.
|
||||
# We have some places where it's just impossible to make it fit,
|
||||
"E501",
|
||||
]
|
||||
|
||||
10
test/python-ruff-check.sh
Executable file
10
test/python-ruff-check.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -z "$MESON_SOURCE_ROOT" ]; then
|
||||
echo "Expected \$MESON_SOURCE_ROOT to be set. Are you sure you are running this through ninja?"
|
||||
exit 100
|
||||
fi
|
||||
|
||||
cd "$MESON_SOURCE_ROOT" || exit 101
|
||||
|
||||
ruff check $(git ls-files "*.py" "*.py.in")
|
||||
10
tools/python-ruff.sh
Executable file
10
tools/python-ruff.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -z "$MESON_SOURCE_ROOT" ]; then
|
||||
echo "Expected \$MESON_SOURCE_ROOT to be set. Are you sure you are running this through ninja?"
|
||||
exit 100
|
||||
fi
|
||||
|
||||
cd "$MESON_SOURCE_ROOT" || exit 101
|
||||
|
||||
ruff check --fix $(git ls-files "*.py" "*.py.in")
|
||||
Reference in New Issue
Block a user