import importlib


def has_func(func_name: str) -> bool:
    """
    Assuming `x.y.z.name` as func_name,
    Check if `from x.y import z; z.name` or `from x.y.z import name` works
    """
    try:
        module, cls, func = func_name.rsplit(".", 2)
        mod = importlib.import_module(module)
        return hasattr(getattr(mod, cls), func)
    except (AttributeError, ValueError):
        try:
            module, cls = func_name.rsplit(".", 1)
            mod = importlib.import_module(module)
            return hasattr(mod, cls)
        except (ValueError, ModuleNotFoundError):
            return False
    except ModuleNotFoundError:
        return False