<commit_before>
from marshmallow_jsonapi.fields import HyperlinkRelated
from marshmallow_jsonapi.utils import get_value_or_raise


class IncludingHyperlinkRelated(HyperlinkRelated):

    def __init__(self, nestedObj, *args,  **kwargs):
        if callable(nestedObj):
            nestedObj = nestedObj(many=False)
        self.nestedObj = nestedObj
        super(IncludingHyperlinkRelated, self).__init__(*args, **kwargs)

    def add_resource_linkage(self, value):
        def render(item):
            attributes = self._extract_attributes(item)
            type_ = attributes.pop('type', self.type_)
            return {'type': type_,
                    'id': get_value_or_raise(self.id_field, item),
                    'attributes': attributes}
        if self.many:
            included_data = [render(each) for each in value]
        else:
            included_data = render(value)
        return included_data

    def _extract_attributes(self, value):
        sub = self.nestedObj.dump(value).data<commit_msg>Enforce that our Including Hyperlink includes<commit_after>
from marshmallow_jsonapi.fields import HyperlinkRelated
from marshmallow_jsonapi.utils import get_value_or_raise


class IncludingHyperlinkRelated(HyperlinkRelated):

    def __init__(self, nestedObj, *args,  **kwargs):
        if callable(nestedObj):
            nestedObj = nestedObj(many=False)
        self.nestedObj = nestedObj
        kwargs['type_'] = " "
        kwargs['include_data'] = True
        super(IncludingHyperlinkRelated, self).__init__(*args, **kwargs)

    def add_resource_linkage(self, value):
        def render(item):
            attributes = self._extract_attributes(item)
            type_ = attributes.pop('type', self.type_)
            return {'type': type_,
                    'id': get_value_or_raise(self.id_field, item),
                    'attributes': attributes}
        if self.many:
            included_data = [render(each) for each in value]
        else:
            included_data = render(value)
        return included_data

    def _extract_attributes(self, value):
        sub = self.nestedObj.dump(value).data
{'fraction_non_alphanumeric': 0.09260991580916744, 'fraction_numerical': 0.0, 'mean_word_length': 2.72, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6122781', 'n_tokens_mistral': 614, 'n_tokens_neox': 578, 'n_words': 129}