def METHOD_NAME(
    self,
    section: str,
    option: str,
    value: Any,
    type_: Type[TWant],
    converter: Optional[Callable[[Any], TWant]],
    type_desc: str,
) -> TWant:
    """Check that `value` has the type we want, converting if needed.
    Returns the resulting value of the desired type.
    """
    if isinstance(value, type_):
        return value
    if isinstance(value, str) and converter is not None:
        try:
            return converter(value)
        except Exception as e:
            raise ValueError(
                f"Option [{section}]{option} couldn't convert to {type_desc}: {value!r}"
            ) from e
    raise ValueError(
        f"Option [{section}]{option} is not {type_desc}: {value!r}"
    )