From cff2f440f97d4de02384b35a0f76216cc75a25b9 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Fri, 8 Nov 2024 12:11:23 -0800 Subject: [PATCH] yapf: Add more detailed error message and TODO (flutter/engine#56458) The yapf Python formatter is abandoned and only works with Python versions up to and including Python 3.11. upgraded, this will become more and more problematic. On some Linux distributions side-by-side python installations are unsupported, for example. Issue: https://github.com/flutter/flutter/issues/158384 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- engine/src/flutter/tools/yapf.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/tools/yapf.sh b/engine/src/flutter/tools/yapf.sh index 382cc0c2118..ce651152971 100755 --- a/engine/src/flutter/tools/yapf.sh +++ b/engine/src/flutter/tools/yapf.sh @@ -36,14 +36,22 @@ function follow_links() ( SCRIPT_DIR=$(follow_links "$(dirname -- "${BASH_SOURCE[0]}")") SRC_DIR="$(cd "$SCRIPT_DIR/../.."; pwd -P)" YAPF_DIR="$(cd "$SRC_DIR/flutter/third_party/yapf"; pwd -P)" + +# TODO: https://github.com/flutter/flutter/issues/158384 +# Migrate to a supported Python formatter. if command -v python3.10 &> /dev/null; then PYTHON_EXEC="python3.10" +elif command -v python3.11 &> /dev/null; then + PYTHON_EXEC="python3.11" else python3 -c " import sys version = sys.version_info if (version.major, version.minor) > (3, 11): - print(f'Error: python3 version {version.major}.{version.minor} is greater than 3.11.', file=sys.stderr) + print(f'Error: The yapf Python formatter requires Python version 3.11 or ' + f'earlier. The installed python3 version is ' + f'{version.major}.{version.minor}.', + file=sys.stderr) sys.exit(1) else: print(f'Using python3 version {version.major}.{version.minor}.')