Sample

pyint-ec6345afcc3b-I10

Deterministically remove some optional blank lines and bracketed line breaks

Matched original source

Lines51

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.1770–1; higher is more readable
Mi0.0380–1; higher is more readable
LLOC25Logical lines; fewer is more readable
DeepSeek V4 Pro12.330–20; mean of three runs
GPT-6.1 Sol14.670–20; mean of three runs
BTTF0.5230–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.""" 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.1668.406−55.057
Source linesThe number of non-empty source lines.51+20.4
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.496−6.744

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

Feature contributions

FeatureValueContribution
(log-odds)
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.175.981−3.789
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.176+2.035
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.51−0.769
Indentation frequencyHow rapidly indentation changes from line to line.43+0.75
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.43−0.566
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.053+0.43
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.50.96+0.302

Intercept 0.07 + feature contributions = -1.536 (log-odds).
Score = sigmoid(-1.536) = 0.177.

Score0.038
Score25
Run 1

The code has decent logical structure with clear sectioning and helpful comments, but readability is hampered by inconsistent formatting and misaligned indentation. The nested conditional within get_object adds moderate complexity but remains manageable. Intent is mostly clear, especially with comments explaining the date filtering logic. However, the oddly spaced function calls and string interpolation blocks disrupt reading flow and appear disorganized. The code length is appropriate for its purpose, but some lines contain multiple actions or awkward line breaks that violate one-action-per-line principle. The imported view classes are wrapped unnecessarily across multiple lines, and the error message construction has strange spacing. Overall, the code is functional and understandable but needs formatting cleanup and whitespace normalization to improve readability.

Run 2

The code has a clear purpose and follows Django patterns, but suffers from readability issues. The imports are oddly formatted with excessive whitespace and mixed line breaks. The get_object method is long and combines multiple responsibilities (date parsing, queryset filtering, error handling). The _date_from_string call has awkward, inconsistent parameter alignment, and the Http404 exception is deeply nested with confusing string formatting and alignment. While the overall structure is logical, the excessive spacing and misaligned formatting disrupt the natural reading flow.

Run 3

The code is generally structured and readable, but several formatting issues and over-compressed lines hurt clarity. Imports are logically organized, although some have awkward spacing. The class and method have clear purposes and docstrings. Nesting is shallow, with only one conditional block. However, 'action granularity' and 'reading flow' suffer significantly: the `_date_from_string` call, the `raise Http404` block, and the translation string formatting are all cramped onto single lines with odd indentation. This makes the code harder to scan and debug. The `qs` reassignment pattern is clear, but the `if queryset is None` logic, while concise, slightly reduces clarity. Overall, the code is understandable but would benefit from line breaks and better spacing to improve readability.

Run 1

Code Structure: The class and method are logically organized around parsing a date, validating it, filtering a queryset, and retrieving an object. Nesting: Shallow nesting keeps the main control path easy to follow, though the exception construction is visually cluttered. Clarity of intent: Descriptive method names, a useful docstring, and comments explain the purpose; external mixins and helpers require additional context. Code length: The implementation is reasonably concise, with some verbose error formatting and comments. Action granularity: Most statements perform one action, but two date arguments share a line and compressed import formatting reduces scanability. Reading flow: The processing sequence is natural, but inconsistent spacing, crowded parentheses, and poorly aligned dictionary entries interrupt reading.

Run 2

Code Structure: The class and method are logically organized, separating date extraction, future-date validation, queryset filtering, and object retrieval. Nesting: Control flow is shallow, with only one conditional, although the exception expression is visually cumbersome. Clarity of intent: Descriptive method names, a useful docstring, and explanatory comments make the purpose clear; helper functions and mixins require external context. Code length: The implementation is reasonably concise, though some comments repeat what the code already conveys. Action granularity: Most statements perform one action, but crowded argument and formatting lines undermine visual separation. Reading flow: Execution follows a natural sequence, but inconsistent spacing, compressed imports, and misaligned arguments interrupt scanning.

Run 3

Code Structure: The class and method are logically organized around retrieving an object for a requested date, although several dependencies are not defined in the snippet. Nesting: Control flow is shallow, with only one conditional; the multiline exception construction adds visual complexity. Clarity of intent: Descriptive method names, a useful docstring, and explanatory comments make the purpose clear. Code length: The implementation is reasonably concise, though the exception formatting and some comments are verbose. Action granularity: Most lines perform one action, but inconsistent formatting places multiple arguments and closing delimiters on the same line. Reading flow: Execution proceeds naturally from date extraction to validation, filtering, and retrieval. Irregular spacing in imports, date arguments, and the error message significantly interrupts scanning.