Fix: more meaningful error when autopep8 is missing

Instead of getting a Python UnboundLocalError.

Pull Request: https://projects.blender.org/blender/blender/pulls/116613
This commit is contained in:
Eugene Kuznetsov 2024-01-12 16:14:20 +01:00 committed by Brecht Van Lommel
parent 679721ed64
commit d47f1fa1e8
1 changed files with 6 additions and 0 deletions

View File

@ -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)