diff --git a/.github/workflows/lint-code.yml b/.github/workflows/lint-code.yml index 8d820d7a8e8..db536259569 100644 --- a/.github/workflows/lint-code.yml +++ b/.github/workflows/lint-code.yml @@ -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 diff --git a/Meta/lint-python.sh b/Meta/lint-python.sh index b4995e1d770..773505c4a86 100755 --- a/Meta/lint-python.sh +++ b/Meta/lint-python.sh @@ -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 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000000..55ec8d784c3 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[tool.black] +line-length = 120