docs: def teed_call(cmd_args,
                stdout_targets: List[TextIO] = None,
                stderr_targets: List[TextIO] = None,
                encoding: str = sys.getdefaultencoding(),
                **kwargs):
      """
      Runs a command and captures its output via :func:`tee` to one or more 
      destinations. The output is always captured (otherwise we would lose 
      control of the output and ability to ``tee`` it); if no destination is 
      specified, we add a null handler.
  
      We insist on ``TextIO`` output files to match ``sys.stdout`` (etc.).
  
      A variation on:
      https://stackoverflow.com/questions/4984428/python-subprocess-get-childrens-output-to-file-and-terminal
  
      Args:
          cmd_args: arguments for the command to run
          stdout_targets: file-like objects to write ``stdout`` to
          stderr_targets: file-like objects to write ``stderr`` to 
          encoding: encoding to apply to ``stdout`` and ``stderr``
          kwargs: additional arguments for :class:`subprocess.Popen`
          
      """  # noqa
      # Make a copy so we can append without damaging the original:
      stdout_targets = stdout_targets.copy() if stdout_targets else []  # type: List[TextIO]  # noqa
      stderr_targets = stderr_targets.copy() if stderr_targets else []  # type: List[TextIO]  # noqa
      p = Popen(cmd_args, stdout=PIPE, stderr=PIPE, **kwargs)
      threads = []  # type: List[Thread]
      with open(os.devnull, "w") as null:  # type: TextIO
          if not stdout_targets:
              stdout_targets.append(null)
          if not stderr_targets:
              stderr_targets.append(null)
          # Now, by default, because we're not using "universal_newlines", both
          # p.stdout and p.stderr are binary.
          stdout_txt = TextIOWrapper(p.stdout, encoding=encoding)  # type: TextIO  # noqa
          stderr_txt = TextIOWrapper(p.stderr, encoding=encoding)  # type: TextIO  # noqa
          threads.append(tee(stdout_txt, *stdout_targets))
          threads.append(tee(stderr_txt, *stderr_targets))
          for t in threads:
              t.join()  # wait for IO completion
          return p.wait()