Sample

pyint-1ece281e545a-I05

Rewrite eligible decimal integer literals in hexadecimal notation

Matched original source

Lines24

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.580–1; higher is more readable
Mi0.4430–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro150–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.7430–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 PermissionManager(models.Manager): use_in_migrations = True def get_by_natural_key(self, codename, app_label, model): return self.get( codename=codename, content_type=ContentType.objects.db_manager(self.db).get_by_natural_key( app_label, model ), )

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.901.892−29.762
Source linesThe number of non-empty source lines.24+9.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.562−6.843

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.058+0.383
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.25+0.151
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+0.107
Indentation frequencyHow rapidly indentation changes from line to line.24+0.093
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.23.906−0.076

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

Score0.443
Score17
Run 1

The code demonstrates good readability. Structure is logical: imports are grouped, and the class has a clear purpose. Nesting is minimal—only one nested call inside `get_by_natural_key`, which is necessary and clearly formatted. Intent is clear: the manager retrieves a permission by its natural key components. Code length is concise; no extra methods or comments are needed. Action granularity is appropriate: one meaningful action per line, with keyword arguments kept on separate lines for clarity. Reading flow is natural—signature, return, and nested call follow a top-to-bottom order. Minor deductions: unused imports (`auth`, `AbstractBaseUser`, etc.) could confuse readers, and the `use_in_migrations = True` line lacks context for novices, but these are minor. Overall, the code is well-structured and easy to follow.

Run 2

The code demonstrates good readability with clean imports, clear class naming, and a single well-defined method. The PermissionManager class is logically structured with a clear purpose. The get_by_natural_key method shows good action granularity with one main operation, though the nested ContentType lookup creates slight complexity. Nesting is acceptable (2 levels deep). The reading flow is natural - imports, class definition, then method. Variable names are descriptive (codename, app_label, model). Code length is concise. Minor deductions: the nested db_manager call could be extracted for clarity, and the use_in_migrations attribute could benefit from a comment explaining its purpose. Overall, the intent is clear and the structure follows Django conventions well.

Run 3

The code demonstrates good formatting and clear import organization, but has several readability issues. Naming conventions are inconsistent: 'PermissionManager' is misleading as it manages permissions but is named conventionally for Django's pattern. The method 'get_by_natural_key' has clear intent but creates a deeply nested call within its return statement, reducing readability. The code length is appropriate for its purpose, and each action is logically separated. However, the nesting within the return line obscures the flow—it requires mental unpacking to understand the ContentType lookup. Overall, the code is functional and reasonably structured, but the nested return call and ambiguous class name reduce clarity.

Run 1

Code Structure: Imports and the manager class are logically organized, though most imports are unused in this snippet. Nesting: Shallow class and method nesting; the nested lookup remains easy to follow. Clarity of intent: Descriptive names clearly communicate fetching a permission by its natural key. Code length: The method is concise, but the extensive import list adds unnecessary bulk to the shown code. Action granularity: The return expression combines two related database lookups, with multiline formatting making their relationship clear. Reading flow: The code progresses naturally from imports to class configuration to lookup behavior; an additional blank line before the class would improve visual separation.

Run 2

Code Structure: Imports precede a clearly defined manager class and its focused method, although many imports are unused in this snippet. Nesting: Shallow class/method nesting; the nested lookup adds only modest complexity. Clarity of intent: Descriptive names make the natural-key permission lookup understandable, though familiarity with Django helps. Code length: The method is concise, but the extensive import list is disproportionate to the shown functionality. Action granularity: Each statement serves a single purpose; embedding the content-type lookup inside the permission lookup slightly increases cognitive load. Reading flow: Consistent indentation and multiline argument formatting support a natural top-to-bottom reading flow. An additional blank line before the class would improve conventional formatting.

Run 3

Code Structure: Imports and a focused manager class are logically organized, though many imports are unused in this snippet. Nesting: Shallow class and method nesting; the nested lookup remains easy to follow. Clarity of intent: Descriptive names make the natural-key permission lookup clear, although understanding the database-manager chain requires Django familiarity. Code length: The method is concise, but the extensive import list adds unnecessary length for the code shown. Action granularity: The return expression combines two related lookups, with clear multiline formatting separating their arguments. Reading flow: The method reads naturally from permission identifiers to content-type resolution; an extra blank line before the class would improve conventional formatting.