summaryrefslogtreecommitdiffstats
path: root/pre_commit/languages/python.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-12-11 08:29:45 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-12-11 08:29:45 +0000
commitbfb804ed317bbbd1e0089c80c1b1d3510185bca6 (patch)
tree93ee86b21565e569256a09e651a10c08befcd4b8 /pre_commit/languages/python.py
parentAdding upstream version 3.5.0. (diff)
downloadpre-commit-bfb804ed317bbbd1e0089c80c1b1d3510185bca6.tar.xz
pre-commit-bfb804ed317bbbd1e0089c80c1b1d3510185bca6.zip
Adding upstream version 3.6.0.upstream/3.6.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'pre_commit/languages/python.py')
-rw-r--r--pre_commit/languages/python.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/pre_commit/languages/python.py b/pre_commit/languages/python.py
index 3ef3436..9f4bf69 100644
--- a/pre_commit/languages/python.py
+++ b/pre_commit/languages/python.py
@@ -4,8 +4,8 @@ import contextlib
import functools
import os
import sys
-from typing import Generator
-from typing import Sequence
+from collections.abc import Generator
+from collections.abc import Sequence
import pre_commit.constants as C
from pre_commit import lang_base
@@ -24,7 +24,7 @@ ENVIRONMENT_DIR = 'py_env'
run_hook = lang_base.basic_run_hook
-@functools.lru_cache(maxsize=None)
+@functools.cache
def _version_info(exe: str) -> str:
prog = 'import sys;print(".".join(str(p) for p in sys.version_info))'
try:
@@ -65,7 +65,7 @@ def _find_by_py_launcher(
version: str,
) -> str | None: # pragma: no cover (windows only)
if version.startswith('python'):
- num = version[len('python'):]
+ num = version.removeprefix('python')
cmd = ('py', f'-{num}', '-c', 'import sys; print(sys.executable)')
env = dict(os.environ, PYTHONIOENCODING='UTF-8')
try:
@@ -124,7 +124,7 @@ def _sys_executable_matches(version: str) -> bool:
return False
try:
- info = tuple(int(p) for p in version[len('python'):].split('.'))
+ info = tuple(int(p) for p in version.removeprefix('python').split('.'))
except ValueError:
return False