code: def pre_commit_install(scm: "Git") -> None:
      import os
  
      from dvc.utils.serialize import modify_yaml
  
      config_path = os.path.join(
          scm.root_dir, ".pre-commit-config.yaml"
      )
      with modify_yaml(config_path) as config:
          entry = {
              "repo": "https://github.com/iterative/dvc",
              "rev": "main",
              "hooks": [
                  {
                      "id": "dvc-pre-commit",
                      "additional_dependencies": [".[all]"],
                      "language_version": "python3",
                      "stages": ["commit"],
                  },
                  {
                      "id": "dvc-pre-push",
                      "additional_dependencies": [".[all]"],
                      "language_version": "python3",
                      "stages": ["push"],
                  },
                  {
                      "id": "dvc-post-checkout",
                      "additional_dependencies": [".[all]"],
                      "language_version": "python3",
                      "stages": ["post-checkout"],
                      "always_run": True,
                  },
              ],
          }
  
          config["repos"] = config.get("repos", [])
          if entry not in config["repos"]:
              config["repos"].append(entry)
  
imports: from typing import TYPE_CHECKING
  from dvc.exceptions import DvcException
label_desc: Use image node_id 1 for calling a global function with example usage: pre_commit_install(scm) without return types