Sample

pyint-2eb29e8c542c-I05

Rewrite eligible decimal integer literals in hexadecimal notation

Matched original source

Lines83

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.5890–1; higher is more readable
Mi0.6320–1; higher is more readable
LLOC44Logical lines; fewer is more readable
DeepSeek V4 Pro17.670–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.5980–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=0x96, 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=0x96, blank=True) last_name = models.CharField(_("last name"), max_length=0x96, 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.83+33.2
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.675−7.012

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.84−1.938
Indentation frequencyHow rapidly indentation changes from line to line.76+1.892
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.76−1.323
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.82.906+0.749
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.82.024+0.519
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.068+0.284
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.83.976+0.108

Intercept 0.07 + feature contributions = 0.361 (log-odds).
Score = sigmoid(0.361) = 0.589.

Score0.632
Score44
Run 1

The code is well-structured, with clear separation of imports, class definition, field declarations, and methods. It follows Django model conventions, making intent obvious to experienced developers. Nesting is minimal and readability is high. However, a few issues prevent a higher score: use of hexadecimal max_length (0x96) is less intuitive than 150, the UserManager reference is undefined in the snippet, and some methods like clean() rely on implicit class behavior. Minor inconsistencies in docstring style also slightly affect flow. Overall, it is concise and maintainable.

Run 2

The code is highly readable. It follows a logical structure: imports, class definition, field declarations, Meta class, and methods. Nesting is minimal—only field definitions use multi-line patterns, which is standard for Django models. The intent is clear: it defines an abstract user model with standard fields and methods. Code length is appropriate; each field and method is concise and necessary. Action granularity is excellent, with one logical action per line or block. Reading flow is natural, from imports to class definition to fields to methods, matching typical Django conventions. Minor deductions for using `0x96` instead of `150` (slightly less clear) and the lack of type hints, but overall it's very clean and maintainable.

Run 3

The code demonstrates excellent readability. It follows Django model conventions with clear separation of imports, class definition, fields, Meta, and methods. Fields are logically grouped and consistently formatted. The use of gettext_lazy, meaningful help_text, and validators makes intent explicit. Methods are short, focused, and self-documenting with appropriate docstrings. Nesting is minimal. One minor readability concern is the use of hexadecimal values (0x96) instead of plain integers for max_length, which may be less intuitive to some developers. Overall, the code is well-structured, flat, concise, and follows a natural reading flow.

Run 1

Code Structure: Fields, manager, configuration, metadata, and methods are logically grouped, although numerous unused imports add clutter and PermissionsMixin and UserManager lack visible definitions or imports. Nesting: Shallow nesting and straightforward methods make the code easy to scan. Clarity of intent: Descriptive names, docstrings, and field help text communicate purpose clearly; hexadecimal max_length values obscure the familiar limit of 150. Code length: Appropriately concise for a Django model, with some unnecessary import overhead. Action granularity: Statements generally perform one action each, and multiline field declarations improve readability. Reading flow: The progression from model fields to configuration and behavior is natural, with consistent formatting and spacing.

Run 2

Code Structure: Fields, configuration, metadata, and methods are logically grouped, although PermissionsMixin and UserManager are not defined or imported in the snippet. Nesting: Shallow nesting and straightforward methods make the code easy to scan. Clarity of intent: Descriptive names, docstrings, and field help text explain the model well; hexadecimal max_length values obscure the otherwise simple limit of 150. Code length: Mostly concise, with useful multiline formatting, but numerous unused imports add clutter. Action granularity: Statements generally perform one action per line, and field declarations are neatly separated. Reading flow: The progression from model fields to settings and behavior is natural, with consistent indentation and spacing.

Run 3

Code Structure: Fields, manager, configuration, metadata, and methods are logically grouped, although PermissionsMixin and UserManager are not defined or imported in the snippet. Nesting: Shallow nesting makes the class easy to follow; multiline field declarations remain clear. Clarity of intent: Descriptive names, docstrings, and help text explain the model well, but hexadecimal max_length values obscure the straightforward limit of 150. Code length: Appropriate for a declarative Django model, though several unused imports add clutter. Action granularity: Statements generally perform one action each, and field options are neatly separated. Reading flow: The progression from model fields to configuration and behavior is natural, with consistent formatting and short methods.