def parse_mapping(mapping_file: Optional[str]) -> configparser.ConfigParser:
    """
    Parse the file containing the mappings from hosts to pass entries.

    Args:
        mapping_file:
            Name of the file to parse. If ``None``, the default file from the
            XDG location is used.
    """
    LOGGER.debug('Parsing mapping file. Command line: %s', mapping_file)

    def parse(mapping_file):
        config = configparser.ConfigParser()
        config.read_file(mapping_file)
        return config

    # give precedence to the user-specified file
    if mapping_file is not None:
        LOGGER.debug('Parsing command line mapping file')
        return parse(mapping_file)

    # fall back on XDG config location
    xdg_config_dir = xdg.BaseDirectory.load_first_config('pass-git-helper')
    if xdg_config_dir is None:
        raise RuntimeError(
            'No mapping configured so far at any XDG config location. '
            'Please create {config_file}'.format(
                config_file=DEFAULT_CONFIG_FILE))
    mapping_file = os.path.join(xdg_config_dir, CONFIG_FILE_NAME)
    LOGGER.debug('Parsing mapping file %s', mapping_file)
    with open(mapping_file, 'r') as file_handle:
        return parse(file_handle)
Parse the file containing the mappings from hosts to pass entries.

    Args:
        mapping_file:
            Name of the file to parse. If ``None``, the default file from the
            XDG location is used.