import attr


def filter_unknown_attributes(cls, package_data):
    """
    Given a  mapping of package_data, return a new mapping of package_data that
    contains only known `cls` attr class attributes.
    """
    known_fields = attr.fields_dict(cls)
    return {
        key: value for key, value in package_data.items()
        if key in known_fields
    }