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:
parent
fe99c1fa7c
commit
9e8336c04f
Notes:
github-actions[bot]
2025-05-22 14:22:57 +00:00
Author: https://github.com/trflynn89
Commit: 9e8336c04f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4841
Reviewed-by: https://github.com/gmta ✅
3 changed files with 15 additions and 4 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 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 :(
|
||||
# Corresponds to https://gn.googlesource.com/gn/+/225e90c5025bf74f41dbee60d9cde4512c846fe7
|
||||
|
|
|
@ -5,6 +5,15 @@ set -e
|
|||
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
||||
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
|
||||
files=()
|
||||
while IFS= read -r file; do
|
||||
|
@ -22,12 +31,12 @@ else
|
|||
fi
|
||||
|
||||
if (( ${#files[@]} )); then
|
||||
if ! command -v flake8 >/dev/null 2>&1 ; then
|
||||
echo "flake8 is not available, but python files need linting! Either skip this script, or install flake8."
|
||||
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."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
flake8 "${files[@]}" --max-line-length=120
|
||||
black ${check_argument} "${files[@]}"
|
||||
else
|
||||
echo "No py files to check."
|
||||
fi
|
||||
|
|
2
pyproject.toml
Normal file
2
pyproject.toml
Normal file
|
@ -0,0 +1,2 @@
|
|||
[tool.black]
|
||||
line-length = 120
|
Loading…
Add table
Add a link
Reference in a new issue