<commit_before>class context_variable(object):

    def __init__(self, func):
        self.func = func
        self.__doc__ = func.__doc__

    def __get__(self, obj, objtype=None):
        # Handle case of being called from class instead of an instance
        if obj is None:
            return self
        # Evaluate the property
        value = self.func(obj)
        # Save value into the instance, replacing the descriptor
        object.__setattr__(obj, self.func.__name__, value)
        return value

<commit_msg>Allow plain values, not just methods<commit_after>class context_variable(object):

    def __init__(self, func):
        self.func = func
        self.__doc__ = func.__doc__

    def __get__(self, obj, objtype=None):
        # Handle case of being called from class instead of an instance
        if obj is None:
            return self
        # If we got a plain value, return that
        if not callable(self.func):
            return self.func
        # Evaluate the property
        value = self.func(obj)
        # Save value into the instance, replacing the descriptor
        object.__setattr__(obj, self.func.__name__, value)
        return value


{'fraction_non_alphanumeric': 0.06943268416596104, 'fraction_numerical': 0.0, 'mean_word_length': 2.265193370165746, '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': '899585', 'n_tokens_mistral': 310, 'n_tokens_neox': 304, 'n_words': 114}