pre_commit: prefer pythonX over pythonX.Y

This patch prevent reinstallation of pre-commit hooks or any script generated
by shebang function to just update the script shebang, since the scripts are
not heavily dependent on a specific Python 3 version:

    /usr/bin/env: ‘python3.9’: No such file or directory

Signed-off-by: Luís Ferreira <contact@lsferreira.net>
This commit is contained in:
Luís Ferreira 2021-12-22 18:38:55 +00:00
parent de177e8850
commit c37446c430
No known key found for this signature in database
GPG key ID: 730750D54B7A9F66

View file

@ -59,8 +59,8 @@ def shebang() -> str:
py, _ = os.path.splitext(SYS_EXE) py, _ = os.path.splitext(SYS_EXE)
else: else:
exe_choices = [ exe_choices = [
f'python{sys.version_info[0]}.{sys.version_info[1]}',
f'python{sys.version_info[0]}', f'python{sys.version_info[0]}',
f'python{sys.version_info[0]}.{sys.version_info[1]}',
] ]
# avoid searching for bare `python` as it's likely to be python 2 # avoid searching for bare `python` as it's likely to be python 2
if SYS_EXE != 'python': if SYS_EXE != 'python':