<commit_before>import logging
import typepad.fields

all_classes = {}
def find_by_name(name):
    """Finds and returns the DataObject subclass with the given name.

    Parameter `name` should be a full dotted module and class name.

    """
    return all_classes[name]

class DataObjectMetaclass(type):
    def __new__(cls, name, bases, attrs):
        fields = {}

        # Inherit all the parent DataObject classes' fields.
        for base in bases:
            if isinstance(base, DataObjectMetaclass):
                fields.update(base.fields)

        # Move all the class's attributes that are Fields to the fields set.
        for attrname, field in attrs.items():
            if isinstance(field, typepad.fields.Field):
                fields[attrname] = field
                del attrs[attrname]

        attrs['fields'] = fields
        obj_cls = super(DataObjectMetaclass, cls).__new__(cls, name, bases, attrs)

        # Register the class so Object fields can have forward-referenced it.
        all_classes['.'.join((obj_cls.__module__, name))] = obj_cls
        # Tell the fields this class so they can find their forward references.
        for field in fields.values():
            field.of_cls = obj_cls

        return obj_cls

class DataObject(object):
<commit_msg>Note annoying edge case<commit_after>import logging
import typepad.fields

all_classes = {}
def find_by_name(name):
    """Finds and returns the DataObject subclass with the given name.

    Parameter `name` should be a full dotted module and class name.

    """
    return all_classes[name]

class DataObjectMetaclass(type):
    def __new__(cls, name, bases, attrs):
        fields = {}

        # Inherit all the parent DataObject classes' fields.
        for base in bases:
            if isinstance(base, DataObjectMetaclass):
                fields.update(base.fields)

        # Move all the class's attributes that are Fields to the fields set.
        for attrname, field in attrs.items():
            # TODO: what if a parent's field was replaced with something not a field in the subclass?
            if isinstance(field, typepad.fields.Field):
                fields[attrname] = field
                del attrs[attrname]

        attrs['fields'] = fields
        obj_cls = super(DataObjectMetaclass, cls).__new__(cls, name, bases, attrs)

        # Register the class so Object fields can have forward-referenced it.
        all_classes['.'.join((obj_cls.__module__, name))] = obj_cls
        # Tell the fields this class so they can find their forward references.
        for field in fields.values():
            field.of_cls = obj_cls

        return obj_cls

class DataObject(object):

{'fraction_non_alphanumeric': 0.08098068350668648, 'fraction_numerical': 0.0, 'mean_word_length': 2.5480895915678525, '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': '2792910', 'n_tokens_mistral': 732, 'n_tokens_neox': 711, 'n_words': 259}