def METHOD_NAME(self, d):
    d_to_check = d if self._version == 2 else d["attributes"]
    if not all(isinstance(item, str) for item in d_to_check):
        # TODO: Raise an error for non-string keys
        # raise TypeError("attribute keys must be strings")
        warnings.warn(
            "only attribute keys of type 'string' will be allowed in the future",
            DeprecationWarning,
            stacklevel=2,
        )
        try:
            d_to_check = {str(k): v for k, v in d_to_check.items()}
        except TypeError as ex:  # pragma: no cover
            raise TypeError("attribute keys can not be stringified") from ex
        if self._version == 2:
            d = d_to_check
        else:
            d["attributes"] = d_to_check
    if self._version == 2:
        self.store[self.key] = json_dumps(d)
        if self.cache:
            self._cached_asdict = d
    else:
        if self.key in self.store:
            # Cannot write the attributes directly to JSON, but have to
            # store it within the pre-existing attributes key of the v3
            # metadata.
            # Note: this changes the store.counter result in test_caching_on!
            meta = self.store._metadata_class.parse_metadata(self.store[self.key])
            if "attributes" in meta and "filters" in meta["attributes"]:
                # need to preserve any existing "filters" attribute
                d["attributes"]["filters"] = meta["attributes"]["filters"]
            meta["attributes"] = d["attributes"]
        else:
            meta = d
        self.store[self.key] = json_dumps(meta)
        if self.cache:
            self._cached_asdict = d["attributes"]