def get_module_source(mod: Union[ModuleType, Path, str]) -> str:
    """Get the source code of the given module, given by a module object, path,
    or qualifed name."""

    if isinstance(mod, ModuleType):
        return inspect.getsource(mod)
    elif isinstance(mod, Path):
        with open(mod, "r") as f:
            return f.read()
    elif isinstance(mod, str):
        loc = importlib.util.find_spec(mod).origin
        if loc is None:
            raise ValueError(
                f"Could not find module {mod}. Might be a namespace module."
            )

        with open(loc, "r") as f:
            return f.read()

    else:
        raise ValueError(f"Unknown type {type(mod).__name__}")
Get the source code of the given module, given by a module object, path,
    or qualifed name.
.grit/dealias_trulens_eval.py