# Buggy code
def is_valid(self):
    if not self.runner_name:
        ErrorDialog(_("Runner not provided"))
        return False
    if not self.name_entry.get_text():
        ErrorDialog(_("Please fill in the name"))
        return False
    if (
        self.runner_name in ("steam", "winesteam")
        and self.lutris_config.game_config.get("appid") is None
    ):
        ErrorDialog(_("Steam AppId not provided"))
        return False
    invalid_fields = []
    runner_module = importlib.import_module("lutris.runners." + self.runner_name)
    runner_class = getattr(runner_module, self.runner_name)
    runner_instance = runner_class()
    for config in ["game", "runner"]:
        for k, v in getattr(self.lutris_config, config + "_config").items():
            option = runner_instance.find_option(config + "_options", k)
            if option is None:
                continue
            validator = option.get("validator")
            if validator is not None:
                try:
                    res = validator(v)
                    logger.debug("%s validated successfully: %s", k, res)
                except Exception:
                    invalid_fields.append(option.get("label"))
    if invalid_fields:
        ErrorDialog(
            _("The following fields have invalid values: ") + ", ".join(invalid_fields)
        )
        return False
    return True


# Traceback (ModuleNotFoundError)
Traceback (most recent call last):
File "~/src/lutris/lutris/gui/config/common.py", line 503, in on_save
if not self.is_valid():
File "~/src/lutris/lutris/gui/config/common.py", line 481, in is_valid
runner_module = importlib.import_module("lutris.runners." + self.runner_name)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'lutris.runners.citra'

# Fixed code
def is_valid(self):
    if not self.runner_name:
        ErrorDialog(_("Runner not provided"))
        return False
    if not self.name_entry.get_text():
        ErrorDialog(_("Please fill in the name"))
        return False
    if (
        self.runner_name in ("steam", "winesteam")
        and self.lutris_config.game_config.get("appid") is None
    ):
        ErrorDialog(_("Steam AppId not provided"))
        return False
    invalid_fields = []
    runner_class = import_runner(self.runner_name)
    runner_instance = runner_class()
    for config in ["game", "runner"]:
        for k, v in getattr(self.lutris_config, config + "_config").items():
            option = runner_instance.find_option(config + "_options", k)
            if option is None:
                continue
            validator = option.get("validator")
            if validator is not None:
                try:
                    res = validator(v)
                    logger.debug("%s validated successfully: %s", k, res)
                except Exception:
                    invalid_fields.append(option.get("label"))
    if invalid_fields:
        ErrorDialog(
            _("The following fields have invalid values: ") + ", ".join(invalid_fields)
        )
        return False
    return True