summaryrefslogtreecommitdiffstats
path: root/pre_commit/languages
diff options
context:
space:
mode:
Diffstat (limited to 'pre_commit/languages')
-rw-r--r--pre_commit/languages/conda.py4
-rw-r--r--pre_commit/languages/coursier.py4
-rw-r--r--pre_commit/languages/dart.py4
-rw-r--r--pre_commit/languages/docker.py2
-rw-r--r--pre_commit/languages/docker_image.py2
-rw-r--r--pre_commit/languages/dotnet.py4
-rw-r--r--pre_commit/languages/fail.py2
-rw-r--r--pre_commit/languages/golang.py4
-rw-r--r--pre_commit/languages/haskell.py4
-rw-r--r--pre_commit/languages/lua.py4
-rw-r--r--pre_commit/languages/node.py4
-rw-r--r--pre_commit/languages/perl.py4
-rw-r--r--pre_commit/languages/pygrep.py4
-rw-r--r--pre_commit/languages/python.py10
-rw-r--r--pre_commit/languages/r.py4
-rw-r--r--pre_commit/languages/ruby.py7
-rw-r--r--pre_commit/languages/rust.py6
-rw-r--r--pre_commit/languages/script.py2
-rw-r--r--pre_commit/languages/swift.py4
19 files changed, 40 insertions, 39 deletions
diff --git a/pre_commit/languages/conda.py b/pre_commit/languages/conda.py
index 41c355e..80b3e15 100644
--- a/pre_commit/languages/conda.py
+++ b/pre_commit/languages/conda.py
@@ -3,8 +3,8 @@ from __future__ import annotations
import contextlib
import os
import sys
-from typing import Generator
-from typing import Sequence
+from collections.abc import Generator
+from collections.abc import Sequence
from pre_commit import lang_base
from pre_commit.envcontext import envcontext
diff --git a/pre_commit/languages/coursier.py b/pre_commit/languages/coursier.py
index 9c5fbfe..6558bf6 100644
--- a/pre_commit/languages/coursier.py
+++ b/pre_commit/languages/coursier.py
@@ -2,8 +2,8 @@ from __future__ import annotations
import contextlib
import os.path
-from typing import Generator
-from typing import Sequence
+from collections.abc import Generator
+from collections.abc import Sequence
from pre_commit import lang_base
from pre_commit.envcontext import envcontext
diff --git a/pre_commit/languages/dart.py b/pre_commit/languages/dart.py
index e8539ca..129ac59 100644
--- a/pre_commit/languages/dart.py
+++ b/pre_commit/languages/dart.py
@@ -4,8 +4,8 @@ import contextlib
import os.path
import shutil
import tempfile
-from typing import Generator
-from typing import Sequence
+from collections.abc import Generator
+from collections.abc import Sequence
from pre_commit import lang_base
from pre_commit.envcontext import envcontext
diff --git a/pre_commit/languages/docker.py b/pre_commit/languages/docker.py
index 8e53ca9..2632851 100644
--- a/pre_commit/languages/docker.py
+++ b/pre_commit/languages/docker.py
@@ -3,7 +3,7 @@ from __future__ import annotations
import hashlib
import json
import os
-from typing import Sequence
+from collections.abc import Sequence
from pre_commit import lang_base
from pre_commit.prefix import Prefix
diff --git a/pre_commit/languages/docker_image.py b/pre_commit/languages/docker_image.py
index 26f006e..a1a2c16 100644
--- a/pre_commit/languages/docker_image.py
+++ b/pre_commit/languages/docker_image.py
@@ -1,6 +1,6 @@
from __future__ import annotations
-from typing import Sequence
+from collections.abc import Sequence
from pre_commit import lang_base
from pre_commit.languages.docker import docker_cmd
diff --git a/pre_commit/languages/dotnet.py b/pre_commit/languages/dotnet.py
index e9568f2..e1202c4 100644
--- a/pre_commit/languages/dotnet.py
+++ b/pre_commit/languages/dotnet.py
@@ -6,8 +6,8 @@ import re
import tempfile
import xml.etree.ElementTree
import zipfile
-from typing import Generator
-from typing import Sequence
+from collections.abc import Generator
+from collections.abc import Sequence
from pre_commit import lang_base
from pre_commit.envcontext import envcontext
diff --git a/pre_commit/languages/fail.py b/pre_commit/languages/fail.py
index a8ec6a5..6ac4d76 100644
--- a/pre_commit/languages/fail.py
+++ b/pre_commit/languages/fail.py
@@ -1,6 +1,6 @@
from __future__ import annotations
-from typing import Sequence
+from collections.abc import Sequence
from pre_commit import lang_base
from pre_commit.prefix import Prefix
diff --git a/pre_commit/languages/golang.py b/pre_commit/languages/golang.py
index bea91e9..4c13d8f 100644
--- a/pre_commit/languages/golang.py
+++ b/pre_commit/languages/golang.py
@@ -12,11 +12,11 @@ import tempfile
import urllib.error
import urllib.request
import zipfile
+from collections.abc import Generator
+from collections.abc import Sequence
from typing import ContextManager
-from typing import Generator
from typing import IO
from typing import Protocol
-from typing import Sequence
import pre_commit.constants as C
from pre_commit import lang_base
diff --git a/pre_commit/languages/haskell.py b/pre_commit/languages/haskell.py
index 76442eb..c6945c8 100644
--- a/pre_commit/languages/haskell.py
+++ b/pre_commit/languages/haskell.py
@@ -2,8 +2,8 @@ from __future__ import annotations
import contextlib
import os.path
-from typing import Generator
-from typing import Sequence
+from collections.abc import Generator
+from collections.abc import Sequence
from pre_commit import lang_base
from pre_commit.envcontext import envcontext
diff --git a/pre_commit/languages/lua.py b/pre_commit/languages/lua.py
index 12d0661..a475ec9 100644
--- a/pre_commit/languages/lua.py
+++ b/pre_commit/languages/lua.py
@@ -3,8 +3,8 @@ from __future__ import annotations
import contextlib
import os
import sys
-from typing import Generator
-from typing import Sequence
+from collections.abc import Generator
+from collections.abc import Sequence
from pre_commit import lang_base
from pre_commit.envcontext import envcontext
diff --git a/pre_commit/languages/node.py b/pre_commit/languages/node.py
index 3e22dc7..d49c0e3 100644
--- a/pre_commit/languages/node.py
+++ b/pre_commit/languages/node.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
diff --git a/pre_commit/languages/perl.py b/pre_commit/languages/perl.py
index 2a7f162..61b1d11 100644
--- a/pre_commit/languages/perl.py
+++ b/pre_commit/languages/perl.py
@@ -3,8 +3,8 @@ from __future__ import annotations
import contextlib
import os
import shlex
-from typing import Generator
-from typing import Sequence
+from collections.abc import Generator
+from collections.abc import Sequence
from pre_commit import lang_base
from pre_commit.envcontext import envcontext
diff --git a/pre_commit/languages/pygrep.py b/pre_commit/languages/pygrep.py
index ec55560..72a9345 100644
--- a/pre_commit/languages/pygrep.py
+++ b/pre_commit/languages/pygrep.py
@@ -3,9 +3,9 @@ from __future__ import annotations
import argparse
import re
import sys
+from collections.abc import Sequence
+from re import Pattern
from typing import NamedTuple
-from typing import Pattern
-from typing import Sequence
from pre_commit import lang_base
from pre_commit import output
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
diff --git a/pre_commit/languages/r.py b/pre_commit/languages/r.py
index 6feb065..93b62bd 100644
--- a/pre_commit/languages/r.py
+++ b/pre_commit/languages/r.py
@@ -6,8 +6,8 @@ import shlex
import shutil
import tempfile
import textwrap
-from typing import Generator
-from typing import Sequence
+from collections.abc import Generator
+from collections.abc import Sequence
from pre_commit import lang_base
from pre_commit.envcontext import envcontext
diff --git a/pre_commit/languages/ruby.py b/pre_commit/languages/ruby.py
index c88269f..0438ae0 100644
--- a/pre_commit/languages/ruby.py
+++ b/pre_commit/languages/ruby.py
@@ -6,9 +6,9 @@ import importlib.resources
import os.path
import shutil
import tarfile
-from typing import Generator
+from collections.abc import Generator
+from collections.abc import Sequence
from typing import IO
-from typing import Sequence
import pre_commit.constants as C
from pre_commit import lang_base
@@ -25,7 +25,8 @@ run_hook = lang_base.basic_run_hook
def _resource_bytesio(filename: str) -> IO[bytes]:
- return importlib.resources.open_binary('pre_commit.resources', filename)
+ files = importlib.resources.files('pre_commit.resources')
+ return files.joinpath(filename).open('rb')
@functools.lru_cache(maxsize=1)
diff --git a/pre_commit/languages/rust.py b/pre_commit/languages/rust.py
index 7eec0e7..7b04d6c 100644
--- a/pre_commit/languages/rust.py
+++ b/pre_commit/languages/rust.py
@@ -7,8 +7,8 @@ import shutil
import sys
import tempfile
import urllib.request
-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
@@ -134,7 +134,7 @@ def install_environment(
packages_to_install: set[tuple[str, ...]] = {('--path', '.')}
for cli_dep in cli_deps:
- cli_dep = cli_dep[len('cli:'):]
+ cli_dep = cli_dep.removeprefix('cli:')
package, _, crate_version = cli_dep.partition(':')
if crate_version != '':
packages_to_install.add((package, '--version', crate_version))
diff --git a/pre_commit/languages/script.py b/pre_commit/languages/script.py
index 89a3ab2..1eaa1e2 100644
--- a/pre_commit/languages/script.py
+++ b/pre_commit/languages/script.py
@@ -1,6 +1,6 @@
from __future__ import annotations
-from typing import Sequence
+from collections.abc import Sequence
from pre_commit import lang_base
from pre_commit.prefix import Prefix
diff --git a/pre_commit/languages/swift.py b/pre_commit/languages/swift.py
index f16bb04..f7bfe84 100644
--- a/pre_commit/languages/swift.py
+++ b/pre_commit/languages/swift.py
@@ -2,8 +2,8 @@ from __future__ import annotations
import contextlib
import os
-from typing import Generator
-from typing import Sequence
+from collections.abc import Generator
+from collections.abc import Sequence
from pre_commit import lang_base
from pre_commit.envcontext import envcontext