<commit_before>import abc
from django.http.response import JsonResponse
from rest_framework import status

from analytics_data_api.v0.exceptions import (
    LearnerNotFoundError,
    CourseNotSpecifiedError,
    CourseKeyMalformedError
)


class BaseProcessErrorMiddleware(object):
    """
    Base error.
    """

    __metaclass__ = abc.ABCMeta

    @abc.abstractproperty
    def error(self):
        """ Error class to catch. """
        pass

    @abc.abstractproperty
    def error_code(self):
        """ Error code to return. """
        pass

    @abc.abstractproperty
    def status_code(self):
        """ HTTP status code to return. """
        pass

    def process_exception(self, _request, exception):
        if type(exception) is self.error:
            return JsonResponse({
                "error_code": self.error_code,
                "developer_message": str(exception)<commit_msg>Fixed unidiomatic-typecheck pylint error.<commit_after>import abc
from django.http.response import JsonResponse
from rest_framework import status

from analytics_data_api.v0.exceptions import (
    LearnerNotFoundError,
    CourseNotSpecifiedError,
    CourseKeyMalformedError
)


class BaseProcessErrorMiddleware(object):
    """
    Base error.
    """

    __metaclass__ = abc.ABCMeta

    @abc.abstractproperty
    def error(self):
        """ Error class to catch. """
        pass

    @abc.abstractproperty
    def error_code(self):
        """ Error code to return. """
        pass

    @abc.abstractproperty
    def status_code(self):
        """ HTTP status code to return. """
        pass

    def process_exception(self, _request, exception):
        if isinstance(exception, self.error):
            return JsonResponse({
                "error_code": self.error_code,
                "developer_message": str(exception)
{'fraction_non_alphanumeric': 0.08868335146898804, 'fraction_numerical': 0.001088139281828074, 'mean_word_length': 2.6560636182902586, 'pattern_counts': {'":': 4, '<': 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': '229362', 'n_tokens_mistral': 509, 'n_tokens_neox': 493, 'n_words': 123}