# 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 re
import textwrap
import yaml
from pre_commit.util import yaml_load
from __future__ import annotations





def _is_header_line(line: str) -> bool:
    return line.startswith(('#', '---')) or not line.strip()


def _migrate_map(contents: str) -> str:

# 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/commands/migrate_config.py
import re
import textwrap
import yaml
from pre_commit.util import yaml_load

from __future__ import annotations





def _is_header_line(line: str) -> bool:
    return line.startswith(('#', '---')) or not line.strip()


def _migrate_map(contents: str) -> str:

    if isinstance(yaml_load(contents), list):