# Path: pre_commit/color.py
# def add_color_option(parser: argparse.ArgumentParser) -> None:
#     parser.add_argument(
#         '--color', default=os.environ.get('PRE_COMMIT_COLOR', 'auto'),
#         type=use_color,
#         metavar='{' + ','.join(COLOR_CHOICES) + '}',
#         help='Whether to use color in output.  Defaults to `%(default)s`.',
#     )
# 
# Path: pre_commit/errors.py
# class FatalError(RuntimeError):
#     pass
# 
# Path: pre_commit/languages/all.py
# class Language(NamedTuple):
#     ENVIRONMENT_DIR: str | None
# 
# Path: pre_commit/logging_handler.py
# @contextlib.contextmanager
# def logging_handler(use_color: bool) -> Generator[None, None, None]:
#     handler = LoggingHandler(use_color)
#     logger.addHandler(handler)
#     logger.setLevel(logging.INFO)
#     try:
#         yield
#     finally:
#         logger.removeHandler(handler)
# 
# Path: pre_commit/util.py
# def parse_version(s: str) -> tuple[int, ...]:
#     """poor man's version comparison"""
#     return tuple(int(p) for p in s.split('.'))
# 
# Path: pre_commit/util.py
# def yaml_dump(o: Any, **kwargs: Any) -> str:
# def force_bytes(exc: Any) -> bytes:
# def clean_path_on_failure(path: str) -> Generator[None, None, None]:
# def tmpdir() -> Generator[str, None, None]:
# def resource_bytesio(filename: str) -> IO[bytes]:
# def resource_text(filename: str) -> str:
# def make_executable(filename: str) -> None:
#     def __init__(
#             self,
#             returncode: int,
#             cmd: tuple[str, ...],
#             expected_returncode: int,
#             stdout: bytes,
#             stderr: bytes | None,
#     ) -> None:
#     def __bytes__(self) -> bytes:
#         def _indent_or_none(part: bytes | None) -> bytes:
#     def __str__(self) -> str:
# def _setdefault_kwargs(kwargs: dict[str, Any]) -> None:
# def _oserror_to_output(e: OSError) -> tuple[int, bytes, None]:
# def cmd_output_b(
#         *cmd: str,
#         retcode: int | None = 0,
#         **kwargs: Any,
# ) -> tuple[int, bytes, bytes | None]:
# def cmd_output(*cmd: str, **kwargs: Any) -> tuple[int, str, str | None]:
#         def __init__(self) -> None:
#         def __enter__(self) -> Pty:
#         def close_w(self) -> None:
#         def close_r(self) -> None:
#         def __exit__(
#                 self,
#                 exc_type: type[BaseException] | None,
#                 exc_value: BaseException | None,
#                 traceback: TracebackType | None,
#         ) -> None:
#     def cmd_output_p(
#             *cmd: str,
#             retcode: int | None = 0,
#             **kwargs: Any,
#     ) -> tuple[int, bytes, bytes | None]:
# def rmtree(path: str) -> None:
#     def handle_remove_readonly(
#             func: Callable[..., Any],
#             path: str,
#             exc: tuple[type[OSError], OSError, TracebackType],
#     ) -> None:
# def parse_version(s: str) -> tuple[int, ...]:
# def win_exe(s: str) -> str:
# class CalledProcessError(RuntimeError):
#     class Pty:


import argparse
import functools
import logging
import re
import shlex
import sys
import cfgv
import pre_commit.constants as C
from typing import Any
from typing import Sequence
from identify.identify import ALL_TAGS
from pre_commit.color import add_color_option
from pre_commit.errors import FatalError
from pre_commit.languages.all import all_languages
from pre_commit.logging_handler import logging_handler
from pre_commit.util import parse_version
from pre_commit.util import yaml_load
from __future__ import annotations




logger = logging.getLogger('pre_commit')

check_string_regex = cfgv.check_and(cfgv.check_string, cfgv.check_regex)


def check_type_tag(tag: str) -> None:
    if tag not in ALL_TAGS:
        raise cfgv.ValidationError(
            f'Type tag {tag!r} is not recognized.  '
            f'Try upgrading identify and pre-commit?',
        )


def check_min_version(version: str) -> None:

# Path: pre_commit/color.py
# def add_color_option(parser: argparse.ArgumentParser) -> None:
#     parser.add_argument(
#         '--color', default=os.environ.get('PRE_COMMIT_COLOR', 'auto'),
#         type=use_color,
#         metavar='{' + ','.join(COLOR_CHOICES) + '}',
#         help='Whether to use color in output.  Defaults to `%(default)s`.',
#     )
# 
# Path: pre_commit/errors.py
# class FatalError(RuntimeError):
#     pass
# 
# Path: pre_commit/languages/all.py
# class Language(NamedTuple):
#     ENVIRONMENT_DIR: str | None
# 
# Path: pre_commit/logging_handler.py
# @contextlib.contextmanager
# def logging_handler(use_color: bool) -> Generator[None, None, None]:
#     handler = LoggingHandler(use_color)
#     logger.addHandler(handler)
#     logger.setLevel(logging.INFO)
#     try:
#         yield
#     finally:
#         logger.removeHandler(handler)
# 
# Path: pre_commit/util.py
# def parse_version(s: str) -> tuple[int, ...]:
#     """poor man's version comparison"""
#     return tuple(int(p) for p in s.split('.'))
# 
# Path: pre_commit/util.py
# def yaml_dump(o: Any, **kwargs: Any) -> str:
# def force_bytes(exc: Any) -> bytes:
# def clean_path_on_failure(path: str) -> Generator[None, None, None]:
# def tmpdir() -> Generator[str, None, None]:
# def resource_bytesio(filename: str) -> IO[bytes]:
# def resource_text(filename: str) -> str:
# def make_executable(filename: str) -> None:
#     def __init__(
#             self,
#             returncode: int,
#             cmd: tuple[str, ...],
#             expected_returncode: int,
#             stdout: bytes,
#             stderr: bytes | None,
#     ) -> None:
#     def __bytes__(self) -> bytes:
#         def _indent_or_none(part: bytes | None) -> bytes:
#     def __str__(self) -> str:
# def _setdefault_kwargs(kwargs: dict[str, Any]) -> None:
# def _oserror_to_output(e: OSError) -> tuple[int, bytes, None]:
# def cmd_output_b(
#         *cmd: str,
#         retcode: int | None = 0,
#         **kwargs: Any,
# ) -> tuple[int, bytes, bytes | None]:
# def cmd_output(*cmd: str, **kwargs: Any) -> tuple[int, str, str | None]:
#         def __init__(self) -> None:
#         def __enter__(self) -> Pty:
#         def close_w(self) -> None:
#         def close_r(self) -> None:
#         def __exit__(
#                 self,
#                 exc_type: type[BaseException] | None,
#                 exc_value: BaseException | None,
#                 traceback: TracebackType | None,
#         ) -> None:
#     def cmd_output_p(
#             *cmd: str,
#             retcode: int | None = 0,
#             **kwargs: Any,
#     ) -> tuple[int, bytes, bytes | None]:
# def rmtree(path: str) -> None:
#     def handle_remove_readonly(
#             func: Callable[..., Any],
#             path: str,
#             exc: tuple[type[OSError], OSError, TracebackType],
#     ) -> None:
# def parse_version(s: str) -> tuple[int, ...]:
# def win_exe(s: str) -> str:
# class CalledProcessError(RuntimeError):
#     class Pty:


# Path: pre_commit/clientlib.py
import argparse
import functools
import logging
import re
import shlex
import sys
import cfgv
import pre_commit.constants as C
from typing import Any
from typing import Sequence
from identify.identify import ALL_TAGS
from pre_commit.color import add_color_option
from pre_commit.errors import FatalError
from pre_commit.languages.all import all_languages
from pre_commit.logging_handler import logging_handler
from pre_commit.util import parse_version
from pre_commit.util import yaml_load

from __future__ import annotations




logger = logging.getLogger('pre_commit')

check_string_regex = cfgv.check_and(cfgv.check_string, cfgv.check_regex)


def check_type_tag(tag: str) -> None:
    if tag not in ALL_TAGS:
        raise cfgv.ValidationError(
            f'Type tag {tag!r} is not recognized.  '
            f'Try upgrading identify and pre-commit?',
        )


def check_min_version(version: str) -> None:

    if parse_version(version) > parse_version(C.VERSION):