docs: def _delete_dir(dir):
      """
      Delete a directory.
      """
      try:
          shutil.rmtree(dir)  # delete directory
      except OSError as exc:
          if exc.errno != 2:  # code 2 - no such file or directory
              raise  # re-raise exception
      except UnboundLocalError:
          pass