mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 16:24:40 +04:00
python3.9+
This commit is contained in:
parent
98c647d4fd
commit
c4042d0a58
50 changed files with 84 additions and 85 deletions
|
|
@ -5,9 +5,9 @@ import logging
|
|||
import re
|
||||
import shlex
|
||||
import sys
|
||||
from collections.abc import Sequence
|
||||
from typing import Any
|
||||
from typing import NamedTuple
|
||||
from typing import Sequence
|
||||
|
||||
import cfgv
|
||||
from identify.identify import ALL_TAGS
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ import concurrent.futures
|
|||
import os.path
|
||||
import re
|
||||
import tempfile
|
||||
from collections.abc import Sequence
|
||||
from typing import Any
|
||||
from typing import NamedTuple
|
||||
from typing import Sequence
|
||||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit import git
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import argparse
|
|||
import os.path
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import Sequence
|
||||
from collections.abc import Sequence
|
||||
|
||||
from pre_commit.commands.run import run
|
||||
from pre_commit.envcontext import envcontext
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ import re
|
|||
import subprocess
|
||||
import time
|
||||
import unicodedata
|
||||
from collections.abc import Generator
|
||||
from collections.abc import Iterable
|
||||
from collections.abc import MutableMapping
|
||||
from collections.abc import Sequence
|
||||
from typing import Any
|
||||
from typing import Generator
|
||||
from typing import Iterable
|
||||
from typing import MutableMapping
|
||||
from typing import Sequence
|
||||
|
||||
from identify.identify import tags_from_path
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ class Classifier:
|
|||
def __init__(self, filenames: Iterable[str]) -> None:
|
||||
self.filenames = [f for f in filenames if os.path.lexists(f)]
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
@functools.cache
|
||||
def _types_for_file(self, filename: str) -> set[str]:
|
||||
return tags_from_path(filename)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Sequence
|
||||
from collections.abc import Sequence
|
||||
|
||||
from pre_commit import clientlib
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import Sequence
|
||||
from collections.abc import Sequence
|
||||
|
||||
from pre_commit import clientlib
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,9 @@ from __future__ import annotations
|
|||
import contextlib
|
||||
import enum
|
||||
import os
|
||||
from typing import Generator
|
||||
from typing import MutableMapping
|
||||
from collections.abc import Generator
|
||||
from collections.abc import MutableMapping
|
||||
from typing import NamedTuple
|
||||
from typing import Tuple
|
||||
from typing import Union
|
||||
|
||||
_Unset = enum.Enum('_Unset', 'UNSET')
|
||||
|
|
@ -18,9 +17,9 @@ class Var(NamedTuple):
|
|||
default: str = ''
|
||||
|
||||
|
||||
SubstitutionT = Tuple[Union[str, Var], ...]
|
||||
SubstitutionT = tuple[Union[str, Var], ...]
|
||||
ValueT = Union[str, _Unset, SubstitutionT]
|
||||
PatchesT = Tuple[Tuple[str, ValueT], ...]
|
||||
PatchesT = tuple[tuple[str, ValueT], ...]
|
||||
|
||||
|
||||
def format_env(parts: SubstitutionT, env: MutableMapping[str, str]) -> str:
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import functools
|
|||
import os.path
|
||||
import sys
|
||||
import traceback
|
||||
from typing import Generator
|
||||
from collections.abc import Generator
|
||||
from typing import IO
|
||||
|
||||
import pre_commit.constants as C
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ from __future__ import annotations
|
|||
import contextlib
|
||||
import errno
|
||||
import sys
|
||||
from collections.abc import Generator
|
||||
from typing import Callable
|
||||
from typing import Generator
|
||||
|
||||
|
||||
if sys.platform == 'win32': # pragma: no cover (windows)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
import logging
|
||||
import os.path
|
||||
import sys
|
||||
from typing import Mapping
|
||||
from collections.abc import Mapping
|
||||
|
||||
from pre_commit.errors import FatalError
|
||||
from pre_commit.util import CalledProcessError
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from collections.abc import Sequence
|
||||
from typing import Any
|
||||
from typing import NamedTuple
|
||||
from typing import Sequence
|
||||
|
||||
from pre_commit.prefix import Prefix
|
||||
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ import os
|
|||
import random
|
||||
import re
|
||||
import shlex
|
||||
from collections.abc import Generator
|
||||
from collections.abc import Sequence
|
||||
from typing import Any
|
||||
from typing import ContextManager
|
||||
from typing import Generator
|
||||
from typing import NoReturn
|
||||
from typing import Protocol
|
||||
from typing import Sequence
|
||||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit import parse_shebang
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||
|
||||
import contextlib
|
||||
import logging
|
||||
from typing import Generator
|
||||
from collections.abc import Generator
|
||||
|
||||
from pre_commit import color
|
||||
from pre_commit import output
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import argparse
|
|||
import logging
|
||||
import os
|
||||
import sys
|
||||
from typing import Sequence
|
||||
from collections.abc import Sequence
|
||||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit import clientlib
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
from typing import Sequence
|
||||
from collections.abc import Sequence
|
||||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit import git
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ from __future__ import annotations
|
|||
|
||||
import argparse
|
||||
import re
|
||||
from typing import Iterable
|
||||
from typing import Sequence
|
||||
from collections.abc import Iterable
|
||||
from collections.abc import Sequence
|
||||
|
||||
from cfgv import apply_defaults
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from typing import Sequence
|
||||
from collections.abc import Sequence
|
||||
|
||||
from pre_commit import output
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import os.path
|
||||
from typing import Mapping
|
||||
from collections.abc import Mapping
|
||||
from typing import NoReturn
|
||||
|
||||
from identify.identify import parse_shebang_from_file
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import json
|
|||
import logging
|
||||
import os
|
||||
import shlex
|
||||
from collections.abc import Sequence
|
||||
from typing import Any
|
||||
from typing import Sequence
|
||||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit.all_languages import languages
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import contextlib
|
|||
import logging
|
||||
import os.path
|
||||
import time
|
||||
from typing import Generator
|
||||
from collections.abc import Generator
|
||||
|
||||
from pre_commit import git
|
||||
from pre_commit.errors import FatalError
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ import logging
|
|||
import os.path
|
||||
import sqlite3
|
||||
import tempfile
|
||||
from collections.abc import Generator
|
||||
from collections.abc import Sequence
|
||||
from typing import Callable
|
||||
from typing import Generator
|
||||
from typing import Sequence
|
||||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit import file_lock
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ import shutil
|
|||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
from collections.abc import Generator
|
||||
from types import TracebackType
|
||||
from typing import Any
|
||||
from typing import Callable
|
||||
from typing import Generator
|
||||
|
||||
from pre_commit import parse_shebang
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ import multiprocessing
|
|||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from collections.abc import Generator
|
||||
from collections.abc import Iterable
|
||||
from collections.abc import MutableMapping
|
||||
from collections.abc import Sequence
|
||||
from typing import Any
|
||||
from typing import Callable
|
||||
from typing import Generator
|
||||
from typing import Iterable
|
||||
from typing import MutableMapping
|
||||
from typing import Sequence
|
||||
from typing import TypeVar
|
||||
|
||||
from pre_commit import parse_shebang
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue