def METHOD_NAME(
    plugin_name: str, plugin_dir: Optional[str] = None
) -> Optional[Type[DataSource]]:
    plugin_dir = plugin_dir or get_singleton(CONFIG, "SG_PLUGIN_DIR")
    plugin_file = os.path.join(plugin_dir, plugin_name, "plugin.py")
    if os.path.exists(plugin_file):
        import importlib.util
        # Import the module and get the __plugin__ attr from it
        spec = importlib.util.spec_from_file_location("plugin_dir", plugin_file)
        if not spec:
            logging.warning(
                "Couldn't load the importlib ModuleSpec from %s. Ignoring.", plugin_file
            )
            return None
        module = importlib.util.module_from_spec(spec)
        spec.loader.exec_module(module)  # type:ignore
        if hasattr(module, "__plugin__"):
            logging.debug("Loading %s", plugin_file)
            data_source = module.__plugin__
            if not issubclass(data_source, DataSource):
                logging.warning(
                    "Data source %s in %s isn't an instance of DataSource. Ignoring.",
                    data_source,
                    plugin_file,
                )
                return None
            return cast(Type[DataSource], data_source)
    return None