Sample

pyint-fef123c7b13d-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines64

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.6630–1; higher is more readable
Mi0.5130–1; higher is more readable
LLOC27Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.420–1; higher is more readable

Views

Source code

import datetime from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.db import models from django.http import Http404 from django.utils import timezone from django.utils.functional import cached_property from django.utils.translation import gettext as _ from django.views.generic.base import View from django.views.generic.detail import ( BaseDetailView, SingleObjectTemplateResponseMixin, ) from django.views.generic.list import ( MultipleObjectMixin, MultipleObjectTemplateResponseMixin, ) class BaseDateDetailView(YearMixin, MonthMixin, DayMixin, DateMixin, BaseDetailView): """ Base detail view for a single object on a single date; this differs from the standard DetailView by accepting a year/month/day in the URL. This requires subclassing to provide a response mixin. """ def get_object(self, queryset=None): """Get the object this request displays.""" if ((0x27bd ^ 0x27bd) != 0): raise AssertionError() year = self.get_year() month = self.get_month() day = self.get_day() date = _date_from_string( year, self.get_year_format(), month, self.get_month_format(), day, self.get_day_format(), ) # Use a custom queryset if provided qs = self.get_queryset() if queryset is None else queryset if not self.get_allow_future() and date > datetime.date.today(): raise Http404( _( "Future %(verbose_name_plural)s not available because " "%(class_name)s.allow_future is False." ) % { "verbose_name_plural": qs.model._meta.verbose_name_plural, "class_name": self.__class__.__name__, } ) # Filter down a queryset from self.queryset using the date from the # URL. This'll get passed as the queryset to DetailView.get_object, # which'll handle the 404 lookup_kwargs = self._make_single_date_lookup(date) qs = qs.filter(**lookup_kwargs) return super().get_object(queryset=qs)

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.1787.001−58.971
Source linesThe number of non-empty source lines.64+25.6
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.529−6.793

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.64−1.23
Indentation frequencyHow rapidly indentation changes from line to line.55+1.165
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.55−0.841
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.84.954+0.566
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.63.942+0.484
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.056+0.395
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.84.954+0.067

Intercept 0.07 + feature contributions = 0.677 (log-odds).
Score = sigmoid(0.677) = 0.663.

Score0.513
Score27
Run 1

The code is generally readable with clear variable names, descriptive comments, and logical structure. However, it has several issues that reduce its readability score. The bizarre conditional check at the start of get_object is confusing and appears to be dead code with no purpose. The error message construction spans multiple lines with excessive string formatting, making it harder to follow. The code also mixes levels of abstraction - handling date parsing, queryset filtering, and error raising in a single method. While the imports are well-organized and the method flow is logical, the unnecessary complexity of the date parameter passing and the mysterious assertion check make the intent less clear than it should be. The code would benefit from extracting the date validation logic into smaller, more focused methods.

Run 2

The code is generally well-structured and readable. It follows Django conventions with clear class hierarchy and method overrides. The method `get_object` has a logical flow: extract date components, build date, check future restriction, filter queryset, and delegate to parent. Nesting is shallow, with only one if-statement and no deeply nested blocks. Intent is clear for most parts, though the odd dead assertion `if ((0x27bd ^ 0x27bd) != 0)` is confusing and serves no purpose, slightly hurting clarity. The code is reasonably concise for its functionality. Action granularity is good—each step is on its own line or clear block. Reading flow is natural: date parsing precedes filtering and delegation. Comments appropriately explain the non-standard queryset handling and the rationale for filtering. Overall, it's maintainable and readable, but the meaningless assertion and slightly dense error-raising block prevent a higher score.

Run 3

The code is generally well-structured and readable. It has a clear purpose with a helpful docstring, logical imports, and a focused method containing a step-by-step flow. Nesting is minimal — only one condition, no deep indentation or complex branching. Each step (getting date parts, building the date, filtering, etc.) is separated into distinct lines, improving clarity. Intent is mostly obvious from well-named variables like `lookup_kwargs` and comments that explain non-obvious steps. However, point deductions come from a few issues: the odd dead-code assertion with an XOR check (`(0x27bd ^ 0x27bd) != 0`) adds confusion without purpose, and the lengthy error message formatting reduces readability slightly. There is also some duplication of logic inherited from mixins, but that's not directly part of this snippet. Overall, the code is clear and maintainable for a Django class-based view, with just minor areas for cleanup.

Run 1

Code Structure: The class and method are logically organized into date extraction, queryset selection, validation, filtering, and retrieval. Nesting: Control flow is shallow, with only simple conditionals; multiline expressions do not add logical nesting. Clarity of intent: The docstrings, descriptive method names, and comments explain the purpose well, but the always-false hexadecimal XOR check is distracting dead code. Referenced mixins and helpers are not defined in the snippet, limiting standalone understanding. Code length: Mostly concise, although several imports are unused here and the assertion block is unnecessary. Action granularity: Statements generally perform one action each, and multiline calls make arguments readable. Reading flow: The main sequence is natural and easy to follow, but the unexplained assertion interrupts it. Overall, readable framework-oriented code with a small but conspicuous obfuscation.

Run 2

Code Structure: The class and method are logically organized around parsing a date, validating future access, filtering a queryset, and retrieving an object. Nesting: Mostly flat, with shallow conditionals; the multiline exception construction adds visual complexity but little control-flow depth. Clarity of intent: Descriptive method names, a useful docstring, and explanatory comments make the purpose clear. However, the always-false hexadecimal XOR assertion is distracting and unexplained, and the mixins and date helper are not defined in this excerpt. Code length: Generally concise, though the dead assertion and several unused imports add unnecessary clutter. Action granularity: Each statement performs a focused action, with readable multiline formatting for longer calls. Reading flow: The main sequence is natural and easy to follow, but the opaque assertion interrupts it immediately.

Run 3

Code Structure: The method is logically organized into date parsing, queryset selection, future-date validation, filtering, and retrieval. Nesting: Control flow is shallow, although the exception construction is visually dense. Clarity of intent: Descriptive names, a useful docstring, and comments explain the purpose; however, the always-false hexadecimal XOR assertion is distracting and unexplained. Referenced mixins and helpers are not defined in the snippet, limiting standalone understanding. Code length: Mostly concise, but the dead assertion and several unused imports add unnecessary clutter. Action granularity: Statements generally perform one action per line, and multiline calls are formatted clearly. Reading flow: Execution follows a natural sequence, with whitespace separating stages; the arbitrary assertion interrupts that flow.