# Path: pre_commit/parse_shebang.py
# class ExecutableNotFoundError(OSError):
#     def to_output(self) -> tuple[int, bytes, None]:
# def parse_filename(filename: str) -> tuple[str, ...]:
# def find_executable(
#         exe: str, _environ: Mapping[str, str] | None = None,
# ) -> str | None:
# def normexe(orig: str) -> str:
#     def _error(msg: str) -> NoReturn:
# def normalize_cmd(cmd: tuple[str, ...]) -> tuple[str, ...]:


import contextlib
import errno
import functools
import importlib.resources
import os.path
import shutil
import stat
import subprocess
import sys
import tempfile
import yaml
    import termios
from types import TracebackType
from typing import Any
from typing import Callable
from typing import Generator
from typing import IO
from pre_commit import parse_shebang
    from os import openpty

        return b''.join((
            f'command: {self.cmd!r}\n'.encode(),
            f'return code: {self.returncode}\n'.encode(),
            f'expected return code: {self.expected_returncode}\n'.encode(),
            b'stdout:', _indent_or_none(self.stdout), b'\n',
            b'stderr:', _indent_or_none(self.stderr),
        ))

    def __str__(self) -> str:
        return self.__bytes__().decode()


def _setdefault_kwargs(kwargs: dict[str, Any]) -> None:
    for arg in ('stdin', 'stdout', 'stderr'):
        kwargs.setdefault(arg, subprocess.PIPE)


def _oserror_to_output(e: OSError) -> tuple[int, bytes, None]:
    return 1, force_bytes(e).rstrip(b'\n') + b'\n', None


def cmd_output_b(
        *cmd: str,
        retcode: int | None = 0,
        **kwargs: Any,
) -> tuple[int, bytes, bytes | None]:
    _setdefault_kwargs(kwargs)

    try:

# Path: pre_commit/parse_shebang.py
# class ExecutableNotFoundError(OSError):
#     def to_output(self) -> tuple[int, bytes, None]:
# def parse_filename(filename: str) -> tuple[str, ...]:
# def find_executable(
#         exe: str, _environ: Mapping[str, str] | None = None,
# ) -> str | None:
# def normexe(orig: str) -> str:
#     def _error(msg: str) -> NoReturn:
# def normalize_cmd(cmd: tuple[str, ...]) -> tuple[str, ...]:


# Path: pre_commit/util.py
import contextlib
import errno
import functools
import importlib.resources
import os.path
import shutil
import stat
import subprocess
import sys
import tempfile
import yaml
    import termios
from types import TracebackType
from typing import Any
from typing import Callable
from typing import Generator
from typing import IO
from pre_commit import parse_shebang
    from os import openpty


        return b''.join((
            f'command: {self.cmd!r}\n'.encode(),
            f'return code: {self.returncode}\n'.encode(),
            f'expected return code: {self.expected_returncode}\n'.encode(),
            b'stdout:', _indent_or_none(self.stdout), b'\n',
            b'stderr:', _indent_or_none(self.stderr),
        ))

    def __str__(self) -> str:
        return self.__bytes__().decode()


def _setdefault_kwargs(kwargs: dict[str, Any]) -> None:
    for arg in ('stdin', 'stdout', 'stderr'):
        kwargs.setdefault(arg, subprocess.PIPE)


def _oserror_to_output(e: OSError) -> tuple[int, bytes, None]:
    return 1, force_bytes(e).rstrip(b'\n') + b'\n', None


def cmd_output_b(
        *cmd: str,
        retcode: int | None = 0,
        **kwargs: Any,
) -> tuple[int, bytes, bytes | None]:
    _setdefault_kwargs(kwargs)

    try:

        cmd = parse_shebang.normalize_cmd(cmd)