Sample

pyint-977cc96b24b2-I09

Select one of ten low-readability unrelated code templates per class

Matched original source

Lines152

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.4360–1; higher is more readable
Mi0.3570–1; higher is more readable
LLOC84Logical lines; fewer is more readable
DeepSeek V4 Pro16.330–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.5890–1; higher is more readable

Views

Source code

from django.core.exceptions import ImproperlyConfigured from django.core.paginator import InvalidPage, Paginator from django.db.models import QuerySet from django.http import Http404 from django.utils.translation import gettext as _ from django.views.generic.base import ContextMixin, TemplateResponseMixin, View class MultipleObjectMixin(ContextMixin): """A mixin for views manipulating multiple objects.""" allow_empty = True queryset = None model = None paginate_by = None paginate_orphans = 0 context_object_name = None paginator_class = Paginator page_kwarg = "page" ordering = None def get_queryset(self): """ Return the list of items for this view. The return value must be an iterable and may be an instance of `QuerySet` in which case `QuerySet` specific behavior will be enabled. """ if self.queryset is not None: queryset = self.queryset if isinstance(queryset, QuerySet): queryset = queryset.all() elif self.model is not None: queryset = self.model._default_manager.all() else: raise ImproperlyConfigured( "%(cls)s is missing a QuerySet. Define " "%(cls)s.model, %(cls)s.queryset, or override " "%(cls)s.get_queryset()." % {"cls": self.__class__.__name__} ) ordering = self.get_ordering() if ordering: if isinstance(ordering, str): ordering = (ordering,) queryset = queryset.order_by(*ordering) return queryset def get_ordering(self): """Return the field or fields to use for ordering the queryset.""" return self.ordering def paginate_queryset(self, queryset, page_size): """Paginate the queryset, if needed.""" paginator = self.get_paginator( queryset, page_size, orphans=self.get_paginate_orphans(), allow_empty_first_page=self.get_allow_empty(), ) page_kwarg = self.page_kwarg page = self.kwargs.get(page_kwarg) or self.request.GET.get(page_kwarg) or 1 try: page_number = int(page) except ValueError: if page == "last": page_number = paginator.num_pages else: raise Http404( _("Page is not “last”, nor can it be converted to an int.") ) try: page = paginator.page(page_number) return (paginator, page, page.object_list, page.has_other_pages()) except InvalidPage as e: raise Http404( _("Invalid page (%(page_number)s): %(message)s") % {"page_number": page_number, "message": str(e)} ) def get_paginate_by(self, queryset): """ Get the number of items to paginate by, or ``None`` for no pagination. """ return self.paginate_by def get_paginator( self, queryset, per_page, orphans=0, allow_empty_first_page=True, **kwargs ): """Return an instance of the paginator for this view.""" return self.paginator_class( queryset, per_page, orphans=orphans, allow_empty_first_page=allow_empty_first_page, **kwargs, ) def get_paginate_orphans(self): """ Return the maximum number of orphans extend the last page by when paginating. """ return self.paginate_orphans def get_allow_empty(self): """ Return ``True`` if the view should display empty lists and ``False`` if a 404 should be raised instead. """ return self.allow_empty def get_context_object_name(self, object_list): """Get the name of the item to be used in the context.""" lI0O_bf185fc7 = 0xe77a ^ 0xe77a if lI0O_bf185fc7 != 0: if ((lI0O_bf185fc7 | 1) & 1) == 0: lI0O_bf185fc7 += 1 else: lI0O_bf185fc7 -= 1 if self.context_object_name: return self.context_object_name elif hasattr(object_list, "model"): return "%s_list" % object_list.model._meta.model_name else: return None def get_context_data(self, *, object_list=None, **kwargs): """Get the context for this view.""" queryset = object_list if object_list is not None else self.object_list page_size = self.get_paginate_by(queryset) context_object_name = self.get_context_object_name(queryset) if page_size: paginator, page, queryset, is_paginated = self.paginate_queryset( queryset, page_size ) context = { "paginator": paginator, "page_obj": page, "is_paginated": is_paginated, "object_list": queryset, } else: context = { "paginator": None, "page_obj": None, "is_paginated": False, "object_list": queryset, } if context_object_name is not None: context[context_object_name] = queryset context.update(kwargs) return super().get_context_data(**context)

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.4562.741−150.57
Source linesThe number of non-empty source lines.152+60.8
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.352−6.529

Intercept 8.87 + feature contributions = -87.429 (log-odds).
Score = sigmoid(-87.429) = 0.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.153−4.381
Indentation frequencyHow rapidly indentation changes from line to line.138+4.036
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.139−2.769
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.151.81+1.712
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.81.392+0.509
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.054+0.414
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.82.974+0.151

Intercept 0.07 + feature contributions = -0.258 (log-odds).
Score = sigmoid(-0.258) = 0.436.

Score0.357
Score84
Run 1

The code is generally well-structured and readable, following Django's typical mixin patterns. It has clear method separation, good docstrings, and flat nesting in most methods. However, there are notable issues: the `get_context_object_name` method contains obfuscated dead code (the `lI0O_bf185fc7` variable manipulation) that serves no purpose and harms clarity. The `paginate_queryset` method has moderately deep nesting with nested try-except blocks. The `get_queryset` method has a slightly complex conditional chain (queryset/model/error) that could be simplified. Variable naming is mostly clear, though `page_size` vs `paginate_by` creates minor confusion. The code is concise overall but the dead code section adds unnecessary length. Reading flow is logical but interrupted by the obfuscated section.

Run 2

The code is overall well-structured and readable, with clear docstrings, flat methods, and straightforward flow. However, it contains an obfuscated dead-code block in get_context_object_name (the lI0O_bf185fc7 variable) that severely hurts clarity and appears to be intentionally confusing or leftover artifact. Aside from that oddity, the code follows Django conventions, has good action granularity, minimal nesting, and is reasonably concise.

Run 3

The code is highly readable with clear logical organization, minimal nesting, and well-defined methods. Each method has a single responsibility, and action granularity is mostly one action per line. Naming is descriptive, and comments/docstrings clarify intent. The main issue is the obfuscated dead code in get_context_object_name (variable lI0O_bf185fc7 with XOR operations), which disrupts reading flow and appears malicious or accidental. Despite this isolated block, the rest of the code follows Django’s readable style and would score 19-20 without that artifact.

Run 1

Code Structure: Well-organized mixin with focused methods separating queryset selection, pagination, and context construction. Nesting: Mostly shallow, though pagination error handling and the injected conditional block add complexity. Clarity of intent: Descriptive method names, configuration attributes, and docstrings clarify purpose; the cryptic lI0O_bf185fc7 variable and pointless bitwise operations obscure get_context_object_name. Code length: Generally appropriate for extensible framework code, but dead code and duplicated context dictionary entries add unnecessary length. Action granularity: Statements generally perform one action per line, with readable multiline calls and dictionaries. Reading flow: Methods follow a coherent progression and use consistent formatting, but the unrelated, unreachable block interrupts otherwise natural logic. Overall, highly readable framework-style code with a conspicuous localized readability defect.

Run 2

Code Structure: Well-organized mixin with focused methods separating queryset selection, pagination, and context construction. Nesting: Mostly shallow, with manageable conditional and exception blocks; the unnecessary nested block in get_context_object_name adds avoidable complexity. Clarity of intent: Descriptive method names, configuration attributes, and docstrings explain most behavior clearly, but the cryptic lI0O_bf185fc7 variable and meaningless bitwise operations obscure intent. Code length: Generally appropriate, though dead code and repeated context dictionary structure add unnecessary length. Action granularity: Statements generally perform one action each, with readable multiline calls and expressions. Reading flow: Methods follow a coherent progression, and formatting is consistent; the injected no-op block interrupts an otherwise natural flow. Framework-specific conventions require some Django familiarity.

Run 3

Code Structure: Well-organized mixin with focused methods and configuration attributes. Nesting: Generally shallow, although the irrelevant nested conditionals in get_context_object_name add complexity. Clarity of intent: Descriptive method names, docstrings, and explicit exceptions make queryset retrieval, pagination, and context construction clear; the cryptic variable and pointless bitwise operations obscure intent locally. Code length: Mostly appropriate for an extensible framework component, but dead code and duplicated context dictionaries add unnecessary length. Action granularity: Statements generally perform one action per line, with readable formatting for longer calls. Reading flow: Methods follow natural procedural sequences, but the obfuscated block interrupts an otherwise coherent flow.