From d47f1fa1e872331f511a8e74d0c30fe93690e77a Mon Sep 17 00:00:00 2001 From: Eugene Kuznetsov Date: Fri, 12 Jan 2024 16:14:20 +0100 Subject: [PATCH] Fix: more meaningful error when autopep8 is missing Instead of getting a Python UnboundLocalError. Pull Request: https://projects.blender.org/blender/blender/pulls/116613 --- tools/utils_maintenance/autopep8_format_paths.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/utils_maintenance/autopep8_format_paths.py b/tools/utils_maintenance/autopep8_format_paths.py index 1410123c3ca..42e319ca209 100755 --- a/tools/utils_maintenance/autopep8_format_paths.py +++ b/tools/utils_maintenance/autopep8_format_paths.py @@ -105,6 +105,7 @@ def autopep8_ensure_version(autopep8_format_cmd_argument: str) -> Optional[Tuple continue AUTOPEP8_FORMAT_CMD = autopep8_format_cmd break + version_str = None if version_output is not None: version_str = next(iter(v for v in version_output.split() if v[0].isdigit()), None) if version_str is not None: @@ -175,6 +176,11 @@ def main() -> None: version = autopep8_ensure_version(args.autopep8_command) if version is None: print("Unable to detect 'autopep8 --version'") + print( + "You may want to install autopep8-%d.%d, " + "or use the precompiled libs repository." % + (VERSION_MAX_RECOMMENDED[0], VERSION_MAX_RECOMMENDED[1]), + ) sys.exit(1) if version < VERSION_MIN: print("Version of autopep8 is too old:", version, "<", VERSION_MIN)