1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-08 05:27:14 +09:00

Meta: Lint python files with black

It's the industry standard nowadays. This also lets us add a flag to the
lint-python.sh script to overwrite our python files in place.
This commit is contained in:
Timothy Flynn 2025-05-22 07:24:42 -04:00 committed by Jelle Raaijmakers
parent fe99c1fa7c
commit 9e8336c04f
Notes: github-actions[bot] 2025-05-22 14:22:57 +00:00
3 changed files with 15 additions and 4 deletions

View file

@ -15,7 +15,7 @@ jobs:
run: | run: |
set -e set -e
brew install curl flake8 llvm@20 ninja optipng shellcheck swift-format unzip brew install black curl llvm@20 ninja optipng shellcheck swift-format unzip
# Note: gn isn't available in homebrew :( # Note: gn isn't available in homebrew :(
# Corresponds to https://gn.googlesource.com/gn/+/225e90c5025bf74f41dbee60d9cde4512c846fe7 # Corresponds to https://gn.googlesource.com/gn/+/225e90c5025bf74f41dbee60d9cde4512c846fe7

View file

@ -5,6 +5,15 @@ set -e
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P) script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
cd "${script_path}/.." || exit 1 cd "${script_path}/.." || exit 1
check_argument="--check"
if [ "$#" -gt "0" ]; then
if [ "--overwrite-inplace" = "$1" ] ; then
check_argument=""
shift
fi
fi
if [ "$#" -eq "0" ]; then if [ "$#" -eq "0" ]; then
files=() files=()
while IFS= read -r file; do while IFS= read -r file; do
@ -22,12 +31,12 @@ else
fi fi
if (( ${#files[@]} )); then if (( ${#files[@]} )); then
if ! command -v flake8 >/dev/null 2>&1 ; then if ! command -v black >/dev/null 2>&1 ; then
echo "flake8 is not available, but python files need linting! Either skip this script, or install flake8." echo "black is not available, but python files need linting! Either skip this script, or install black."
exit 1 exit 1
fi fi
flake8 "${files[@]}" --max-line-length=120 black ${check_argument} "${files[@]}"
else else
echo "No py files to check." echo "No py files to check."
fi fi

2
pyproject.toml Normal file
View file

@ -0,0 +1,2 @@
[tool.black]
line-length = 120