mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 16:49:54 +00:00
Meta+CI: Enforce python linting with ruff
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
We could use flake8 for linting, but ruff is compatible with black formatting out-of-the-box. It also seems to catch more than flake8, such as unnecessary f-strings.
This commit is contained in:
parent
18718e0876
commit
c204149bbd
Notes:
github-actions[bot]
2025-06-09 15:26:24 +00:00
Author: https://github.com/trflynn89
Commit: c204149bbd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5038
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/R-Goc
3 changed files with 24 additions and 6 deletions
2
.github/workflows/lint-code.yml
vendored
2
.github/workflows/lint-code.yml
vendored
|
@ -15,7 +15,7 @@ jobs:
|
|||
run: |
|
||||
set -e
|
||||
|
||||
brew install black curl llvm@20 ninja optipng shellcheck swift-format unzip
|
||||
brew install curl llvm@20 ninja optipng ruff shellcheck swift-format unzip
|
||||
|
||||
# Note: gn isn't available in homebrew :(
|
||||
# Corresponds to https://gn.googlesource.com/gn/+/225e90c5025bf74f41dbee60d9cde4512c846fe7
|
||||
|
|
|
@ -5,11 +5,11 @@ set -e
|
|||
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
||||
cd "${script_path}/.." || exit 1
|
||||
|
||||
check_argument="--check"
|
||||
overwrite=0
|
||||
|
||||
if [ "$#" -gt "0" ]; then
|
||||
if [ "--overwrite-inplace" = "$1" ] ; then
|
||||
check_argument=""
|
||||
overwrite=1
|
||||
shift
|
||||
fi
|
||||
fi
|
||||
|
@ -31,12 +31,18 @@ else
|
|||
fi
|
||||
|
||||
if (( ${#files[@]} )); then
|
||||
if ! command -v black >/dev/null 2>&1 ; then
|
||||
echo "black is not available, but python files need linting! Either skip this script, or install black."
|
||||
if ! command -v ruff >/dev/null 2>&1 ; then
|
||||
echo "Please install ruff: pip3 install ruff"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
black ${check_argument} "${files[@]}"
|
||||
if [[ ${overwrite} -eq 0 ]] ; then
|
||||
ruff check "${files[@]}"
|
||||
ruff format --check "${files[@]}"
|
||||
else
|
||||
ruff check --fix "${files[@]}"
|
||||
ruff format "${files[@]}"
|
||||
fi
|
||||
else
|
||||
echo "No py files to check."
|
||||
fi
|
||||
|
|
|
@ -1,2 +1,14 @@
|
|||
[tool.black]
|
||||
line-length = 120
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 120
|
||||
|
||||
[tool.ruff.lint]
|
||||
# On top of the defaults (`E4`, E7`, `E9`, and `F`), enable flake8-bugbear (`B`) and isort (`i`).
|
||||
# https://docs.astral.sh/ruff/rules/
|
||||
select = ["E4", "E7", "E9", "F", "B", "I"]
|
||||
|
||||
[tool.ruff.lint.isort]
|
||||
force-single-line = true
|
||||
lines-between-types = 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue