docs: def dumpfn(obj, fn, *args, **kwargs):
      """
      Dump to a json/yaml directly by filename instead of a File-like object.
      For YAML, ruamel.yaml must be installed. The file type is automatically
      detected. YAML is assumed if the filename contains "yaml" (lower or upper
      case). Otherwise, json is always assumed.
  
      Args:
          obj (object): Object to dump.
          fn (str/Path): filename or pathlib.Path.
          \*args: Any of the args supported by json/yaml.dump.
          \*\*kwargs: Any of the kwargs supported by json/yaml.dump.
  
      Returns:
          (object) Result of json.load.
      """
      if "mpk" in os.path.basename(fn).lower():
          if msgpack is None:
              raise RuntimeError(
                  "Loading of message pack files is not "
                  "possible as msgpack-python is not installed.")
          if "default" not in kwargs:
              kwargs["default"] = default
          with zopen(fn, "wb") as fp:
              msgpack.dump(obj, fp, *args, **kwargs)
      else:
          with zopen(fn, "wt") as fp:
              if "yaml" in os.path.basename(fn).lower():
                  if yaml is None:
                      raise RuntimeError("Loading of YAML files is not "
                                         "possible as ruamel.yaml is not installed.")
                  if "Dumper" not in kwargs:
                      kwargs["Dumper"] = Dumper
                  yaml.dump(obj, fp, *args, **kwargs)
              else:
                  if "cls" not in kwargs:
                      kwargs["cls"] = MontyEncoder
                  fp.write("%s" % json.dumps(obj, *args, **kwargs))