import types


def type_legacy_mro(cls):
    """
    drop in replacement of type.mro for loading legacy hickle 4.x files which were
    created without generalized PyContainer objects available. Consequently some
    h5py.Datasets and h5py.Group objects expose function objects as their py_obj_type
    type.mro expects classes only.

    Parameters
    ----------
    cls (type):
        the py_obj_type/class of the object to load or dump

    Returns
    -------
        mro list for cls as returned by type.mro  or in case cls is a function or method
        a single element tuple is returned
    """
    if isinstance(
        cls,
        (types.FunctionType,types.BuiltinFunctionType,types.MethodType,types.BuiltinMethodType)
    ):
        return (cls,)
    return type.mro(cls)