def configure_target_or_source(switch, key):
    """ Obtains the java version to be used for the target or source switch, if
        the given `switch` is either `target` or `source`.

    Parameters
    ----------
    switch : str
        A javac switch, without the preceding `-`
    key : str or bool
        The value given to the switch, if any

    Returns
    -------
    str or bool
        If the switch is either target or source, and the key is not a boolean,
        then a string containing the java version without the preceding `1.`
        Else, returns the key, unaltered.

    """
    if switch in ["source", "target"]:
        if not isinstance(key, bool) and key.startswith("1."):
            return key[2:]
    return key