from typing import Any


def assert_key_for_scope(scope: str):
    """Checks that a key of the given name and type is present in a config."""

    def assert_key(config: dict, key: str, instance: Any) -> None:
        if not isinstance(config.get(key), instance):
            raise KeyError(f"Missing {key} in {scope}")

    return assert_key