def asType(dtype: type, key: str, value: str):
    """Convert an incoming string to a given type

    Thin wrapper around ``dtype(value)`` with a better error
    message.

    Parameters
    ----------
    dtype : type, callable
        Desired datatype or function that can produce it given ``value``
    key : str
        Name of the setting. Used only in error reporting
    value : str
        Incoming value from the configuration

    Raises
    ------
    TypeError
    """
    try:
        return dtype(value)
    except Exception as ee:
        raise TypeError(f"Could not coerce {key}={value} to {dtype}") from ee