Sample

pyint-cfb73836ae63-I10

Deterministically remove some optional blank lines and bracketed line breaks

Matched original source

Lines70

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.3590–1; higher is more readable
Mi0.050–1; higher is more readable
LLOC44Logical lines; fewer is more readable
DeepSeek V4 Pro12.670–20; mean of three runs
GPT-6.1 Sol14.330–20; mean of three runs
BTTF0.6050–1; higher is more readable

Views

Source code

from collections.abc import Iterable from django.apps import apps from django.contrib import auth from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager from django.contrib.auth.hashers import make_password from django.contrib.contenttypes.models import ContentType from django.core.exceptions import PermissionDenied from django.core.mail import send_mail from django.db import models from django.db.models.manager import EmptyManager from django.utils import timezone from django.utils.translation import gettext_lazy as _ from .validators import UnicodeUsernameValidator class AbstractUser(AbstractBaseUser, PermissionsMixin): """ An abstract base class implementing a fully featured User model with admin-compliant permissions. Username and password are required. Other fields are optional. """ username_validator = UnicodeUsernameValidator() username = models.CharField( _("username"), max_length=150, unique=True, help_text=_( "Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only." ), validators=[username_validator], error_messages={ "unique": _("A user with that username already exists."), }, ) first_name = models.CharField(_("first name"), max_length=150, blank=True) last_name = models.CharField(_("last name"), max_length=150, blank=True) email = models.EmailField(_("email address"), blank=True) is_staff = models.BooleanField( _("staff status"), default=False, help_text=_("Designates whether the user can log into this admin site."), ) is_active = models.BooleanField( _("active"), default=True, help_text=_( "Designates whether this user should be treated as active. " "Unselect this instead of deleting accounts." ), ) date_joined = models.DateTimeField(_("date joined"), default=timezone.now) objects = UserManager() EMAIL_FIELD = "email" USERNAME_FIELD = "username" REQUIRED_FIELDS = ["email"] class Meta: verbose_name = _("user") verbose_name_plural = _("users") abstract = True def clean(self): super().clean() self.email = self.__class__.objects.normalize_email(self.email) def get_full_name(self): """ Return the first_name plus the last_name, with a space in between. """ full_name = "%s %s" % (self.first_name, self.last_name) return full_name.strip() def get_short_name(self): """Return the short name for the user.""" return self.first_name def email_user(self, subject, message, from_email=None, **kwargs): """Send an email to this user.""" send_mail(subject, message, from_email, [self.email], **kwargs)

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.2844.331−93.863
Source linesThe number of non-empty source lines.70+28
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.658−6.987

Intercept 8.87 + feature contributions = -63.98 (log-odds).
Score = sigmoid(-63.98) = 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.125.986−1.671
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.71−1.478
Indentation frequencyHow rapidly indentation changes from line to line.63+1.442
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.125.986+1.228
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.63−1.025
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.69.913+0.567
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.068+0.285

Intercept 0.07 + feature contributions = -0.58 (log-odds).
Score = sigmoid(-0.58) = 0.359.

Score0.05
Score44
Run 1

The code is generally readable, with clear class and method names, and logical organization. However, some formatting issues reduce clarity: inconsistent spacing and line breaks in field definitions (e.g., username, is_staff, is_active) disrupt reading flow. The nesting is flat, and each action is mostly on its own line, but some multiline arguments are awkwardly split. Intent is clear, but minor ambiguities exist due to formatting. Overall, it’s readable but could be improved with consistent formatting and cleaner line breaks.

Run 2

The code is moderately readable. Structure follows Django conventions, but formatting is inconsistent with excessive whitespace in some field definitions (e.g., username, is_staff) and cramped layouts in others. Several lines pack multiple arguments together, violating one-action-per-line and reducing clarity. The class methods are well-named and purposeful, but the class Meta block is cramped between fields and methods, disrupting reading flow. Some long help_text strings are awkwardly wrapped, making them harder to read. The overall organization is logical, but inconsistent spacing and argument formatting significantly impact readability.

Run 3

The code has decent logical organization but suffers from severe formatting inconsistencies that hurt readability. The AbstractUser class is well-structured with clear method separation, but many lines have excessive whitespace, misaligned parameters, and inconsistent indentation, making the code visually chaotic. For example, the username field's help_text has odd spacing and line breaks, and is_staff has parameters scattered across lines. Nesting is flat, which is good, and intent is mostly clear. However, the code length could be reduced with better formatting. Action granularity is generally one action per line, but the formatting makes it hard to follow. Reading flow is disrupted by these inconsistencies. The redundant email cleaning adds unnecessary complexity. Overall, the code could be significantly improved by applying consistent formatting standards (PEP 8) and removing the stray whitespace. The base structure is sound, but presentation undermines readability.

Run 1

Code Structure: The class logically groups model fields, configuration, metadata, and methods, although missing blank lines weaken separation. Nesting: Shallow nesting makes the code easy to follow; nested field arguments remain manageable. Clarity of intent: Descriptive names and docstrings clearly explain the user model and its methods, but undefined PermissionsMixin and UserManager references and unused imports introduce distractions. Code length: The implementation is reasonably concise, though the import list contains unnecessary entries. Action granularity: Methods generally perform one action per line, but several field declarations cram multiple arguments onto a single line. Reading flow: The progression from fields to behavior is natural, but inconsistent spacing, awkward line wrapping, and crowded declarations interrupt scanning.

Run 2

Code Structure: Fields, configuration, metadata, and methods are logically grouped, but unused imports and undefined PermissionsMixin and UserManager references distract. Nesting: Shallow nesting keeps the class easy to navigate. Clarity of intent: Descriptive names, field help text, and method docstrings clearly communicate the user model's purpose. Code length: The implementation is reasonably concise, although the import list adds unnecessary clutter. Action granularity: Methods generally perform one action per line, but several field arguments are crowded onto the same line with irregular spacing. Reading flow: The progression from fields to behavior is natural, yet inconsistent wrapping and missing blank lines between Meta, clean, and get_full_name interrupt scanning.

Run 3

Code Structure: Fields, configuration, metadata, and methods are logically grouped, but missing blank lines weaken separation. Nesting: Shallow nesting makes the class easy to follow; multiline field arguments are visually cluttered rather than deeply nested. Clarity of intent: Descriptive names and docstrings clearly convey a Django user model, although PermissionsMixin and UserManager are undefined in the provided snippet, and several imports are unused. Code length: Methods are concise, but unnecessary imports add noise. Action granularity: Methods generally perform one action per line, while multiple field arguments crowded onto single lines reduce scanability. Reading flow: The progression from fields to methods is natural, but irregular spacing, inconsistent wrapping, and cramped method boundaries interrupt reading.