mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00: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
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue