from pathlib import Path
import pkgutil


def all_modules(modules_to_ignore=None):
    """Get a list of all modules from toy_pkg."""
    if modules_to_ignore is None:
        modules_to_ignore = {
            "tests",
        }
    all_modules = []
    root = str(Path(__file__).parent.parent)
    for importer, modname, ispkg in pkgutil.walk_packages(
        path=[root], prefix="toy_pkg."
    ):
        mod_parts = modname.split(".")
        if any(part in modules_to_ignore for part in mod_parts) or "._" in modname:
            continue
        all_modules.append(modname)
    return all_modules