code: def _push_refspecs(
      repo, target, refspecs, force_git_push, res_kwargs
  ):
      push_res = repo.push(
          remote=target,
          refspec=refspecs,
          git_options=["--force"] if force_git_push else None,
      )
      # TODO maybe compress into a single message whenever everything is
      # OK?
      for pr in push_res:
          ops = pr["operations"]
          status = (
              "error"
              if any(
                  o in ops
                  for o in (
                      "error",
                      "no-match",
                      "rejected",
                      "remote-rejected",
                      "remote-failure",
                  )
              )
              else "notneeded"
              if "uptodate" in pr["operations"]
              else "ok"
              if any(
                  o in ops
                  for o in (
                      "new-tag",
                      "new-branch",
                      "forced-update",
                      "fast-forward",
                  )
              )
              # no really a good fit, but we have tested all relevant
              # operations above, so in some sense this condition should be
              # impossible to achieve
              else "impossible"
          )
          refspec = "{}:{}".format(pr["from_ref"], pr["to_ref"])
          yield dict(
              res_kwargs,
              status=status,
              target=pr["remote"],
              refspec=refspec,
              operations=ops,
              hints=pr.get("hints", None),
              # seems like a good idea to pass on Git's native message
              # TODO maybe implement a dedicated result renderer, instead
              # of duplicating information only so that the default one
              # can make sense at all
              message="{}->{}:{} {}".format(
                  pr["from_ref"], pr["remote"], pr["to_ref"], pr["note"]
              ),
          )
  
imports: from itertools import chain
  import logging
  import re
  from datalad.interface.base import Interface, build_doc, eval_results
  from datalad.interface.common_opts import jobs_opt, recursion_limit, recursion_flag
  from datalad.interface.utils import render_action_summary
  from datalad.interface.results import annexjson2result
  from datalad.log import log_progress
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.gitrepo import GitRepo
  from datalad.support.param import Parameter
  from datalad.support.constraints import EnsureStr, EnsureNone, EnsureChoice
  from datalad.support.exceptions import CommandError
  from datalad.utils import Path, ensure_list, todo_interface_for_extensions
  from datalad.distribution.dataset import Dataset, EnsureDataset, datasetmethod, require_dataset, resolve_path
  from datalad.core.local.diff import diff_dataset
label_desc: Use image node_id 5 for calling a global function with example usage: _push_refspecs(repo, target, refspecs, force_git_push, res_kwargs) without return types