Sample

pyint-824ff40ea0ea-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines62

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.6710–1; higher is more readable
Mi0.6250–1; higher is more readable
LLOC25Logical lines; fewer is more readable
DeepSeek V4 Pro130–20; mean of three runs
GPT-6.1 Sol14.330–20; mean of three runs
BTTF0.4510–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(self, que=None): """Get the object this request displays.""" yea = self.get_year() mon = self.get_month() day2 = self.get_day() dat = _date_from_string( yea, self.get_year_format(), mon, self.get_month_format(), day2, self.get_day_format(), ) # Use a custom queryset if provided qs2 = self.get_queryset() if que is None else que if not self.get_allow_future() and dat > datetime.date.today(): raise Http404( _( "Future %(verbose_name_plural)s not available because " "%(class_name)s.allow_future is False." ) % { "verbose_name_plural": qs2.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 = self._make_single_date_lookup(dat) qs2 = qs2.filter(**lookup) return super().get_object(queryset=qs2)

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.1680.564−55.459
Source linesThe number of non-empty source lines.62+24.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.512−6.768

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.62−1.159
Indentation frequencyHow rapidly indentation changes from line to line.53+1.096
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.53−0.795
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.84.873+0.565
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.61.953+0.456
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.84.937+0.068

Intercept 0.07 + feature contributions = 0.715 (log-odds).
Score = sigmoid(0.715) = 0.671.

Score0.625
Score25
Run 1

The code has a reasonable logical structure with imports neatly organized, a clear class docstring, and a single get() method that follows a linear flow. However, readability suffers from several issues: abbreviated variable names ('yea', 'mon', 'day2', 'dat', 'qs2') obscure intent; the method signature uses 'que' instead of the conventional 'queryset'; and the get_object/queryset interaction is slightly confusing since this is a detail view. The nesting is relatively flat, which is good, but the long error message construction breaks the reading flow and adds visual noise. Action granularity is mostly one action per line, though some lines could be clearer. Overall, the code is functional but would benefit from more descriptive variable names and slightly better clarity around the date parsing and queryset filtering steps.

Run 2

The code violates multiple readability criteria. The structure is convoluted, with the date parsing logic embedded inside the get method and relying on a helper function. The method is overloaded with multiple responsibilities - fetching user parameters, validation, and filtering. This creates multiple levels of nesting and deep indentation. The variable naming is cryptic (que, qs2, yea, mon, day2, dat), obscuring intent rather than clarifying it. The action granularity is broken with multiple statements chained in single expressions. The reading flow is disrupted by the need to constantly decode abbreviated names. While the docstring provides some context, the method implementation itself does not follow it cleanly. There is unnecessary verbosity in the error message construction but also unexplained abbreviations elsewhere. The code is longer than needed, with parameter passing (que) and intermediate variables that add noise rather than clarity.

Run 3

The code is generally readable but has some naming inconsistencies that reduce clarity. The structure is logical: imports are organized, the class hierarchy is clear, and the get() method follows a coherent flow. Nesting is minimal with only one conditional block. However, abbreviated variable names like 'yea', 'mon', 'day2', 'dat', and 'qs2' obscure intent, forcing readers to mentally decode their meanings. The parameter 'que' is also unclear (likely 'queryset' but truncated). Action granularity is good, with most operations on separate lines. The reading flow is natural, from URL parameter extraction to date validation to queryset filtering. The docstring and comments provide helpful context. Overall, the logic is understandable but the naming choices prevent a higher score — using full, descriptive variable names would significantly improve readability.

Run 1

Code Structure: The method follows a logical sequence: parse the date, choose a queryset, reject disallowed future dates, filter, and retrieve the object. Unused imports and mixins/helpers not defined in the snippet add contextual overhead. Nesting: Shallow, with only one conditional block, making control flow easy to follow. Clarity of intent: The docstring and comments explain the purpose, but abbreviated names such as yea, mon, day2, dat, que, and qs2 obscure meaning. Naming the method get while returning get_object also makes its role less obvious in a view class. Code length: Mostly concise, although imports and verbose exception formatting increase visual length. Action granularity: Statements generally perform one action each, and multiline calls are clearly formatted. Reading flow: Processing proceeds naturally from input extraction to retrieval, but inconsistent variable naming and reliance on external framework behavior interrupt readability.

Run 2

Code Structure: The method follows a logical sequence: parse the date, select a queryset, validate future-date access, filter, and retrieve the object. Several unused imports add clutter. Nesting: Mostly flat, with one conditional and no deeply nested control flow. Clarity of intent: The docstring and comments explain the purpose, but abbreviated names such as que, yea, mon, dat, and qs2 reduce clarity. Naming the method get while returning get_object also makes its role as a view handler less intuitive. Code length: Reasonably concise; multiline formatting improves readability, although the imports are excessive for this snippet. Action granularity: Each statement performs a distinct action, and the conditional queryset assignment is simple enough to follow. Reading flow: Execution proceeds naturally, with helpful spacing and comments, but undefined mixins and helper functions require external context.

Run 3

Code Structure: Logically organized into date extraction, queryset selection, future-date validation, filtering, and object retrieval. Nesting: Shallow, with only one conditional block; multiline calls do not add control-flow complexity. Clarity of intent: The class docstring and comments explain the purpose, but abbreviated names such as que, yea, mon, dat, and qs2 weaken clarity. The get method returning an object rather than a response is also surprising in a view. Code length: Reasonably concise, although several imports are unused in this snippet and the error construction occupies substantial space. Action granularity: Most statements perform one clear action, with a straightforward conditional expression for queryset selection. Reading flow: The sequence is natural and easy to follow, but undefined mixins and helper functions require external context, and inconsistent variable naming interrupts readability.