def _handle_unknown_keys(data: _UnknownKeysT, cls: T.Union[DataclassInstance, T.Type[DataclassInstance]],
                         msg: str) -> _UnknownKeysT:
    """Remove and warn on keys that are coming from cargo, but are unknown to
    our representations.

    This is intended to give users the possibility of things proceeding when a
    new key is added to Cargo.toml that we don't yet handle, but to still warn
    them that things might not work.

    :param data: The raw data to look at
    :param cls: The Dataclass derived type that will be created
    :param msg: the header for the error message. Usually something like "In N structure".
    :return: The original data structure, but with all unknown keys removed.
    """
    unexpected = set(data) - {x.name for x in dataclasses.fields(cls)}
    if unexpected:
        mlog.warning(msg, 'has unexpected keys', '"{}".'.format(', '.join(sorted(unexpected))),
                     _EXTRA_KEYS_WARNING)
        for k in unexpected:
            # Mypy and Pyright can't prove that this is okay
            del data[k]  # type: ignore[misc]
    return data
Remove and warn on keys that are coming from cargo, but are unknown to
    our representations.

    This is intended to give users the possibility of things proceeding when a
    new key is added to Cargo.toml that we don't yet handle, but to still warn
    them that things might not work.

    :param data: The raw data to look at
    :param cls: The Dataclass derived type that will be created
    :param msg: the header for the error message. Usually something like "In N structure".
    :return: The original data structure, but with all unknown keys removed.
    
mesonbuild/cargo/interpreter.py