Sample

pyint-3d7012350085-I01

Remove comments and docstrings

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 Pro16.330–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 strong readability with a clear, logical structure. Import statements are appropriately organized from standard library to Django modules to local imports. The class definition is concise with a clear single responsibility. The get_by_natural_key method shows good action granularity, with one parameter per line in the get() call. Nesting is minimal—only one level in the method, and the content_type lookup is cleanly formatted. While slightly long in the get_by_natural_key method, the line breaks maintain readability. The code is idiomatic Django, making intent clear to developers familiar with the framework. Minor improvements could include adding a docstring to explain the manager's purpose, which would enhance clarity for newcomers to the codebase.

Run 2

The code is highly readable due to its clean imports, clear class definition, and logical structure. The `PermissionManager` class is concise, with a single well-named method that performs one logical action. The method uses descriptive keyword arguments, and the nested `get_by_natural_key` call is broken onto multiple lines for clarity. The line length is well-managed, and the return statement is straightforward. Minor deductions: the import block is slightly long and could be reorganized, and the nested call could be extracted to a variable for even better readability. Overall, the code demonstrates strong clarity of intent, flat nesting, and excellent granularity.

Run 3

The code is generally readable with clear logical organization: imports are grouped sensibly, and the class definition is straightforward. The PermissionManager class has a clear purpose and the get_by_natural_key method is reasonably concise. However, the nesting in the return statement is somewhat deep: the get() call wraps a db_manager() call inside get_by_natural_key(), which slightly impedes the reading flow. The action granularity is mostly one action per line, but the nested call could be split for clarity. The intent is evident, and the code length is appropriate. Overall, it is readable but could be improved by reducing nesting.

Run 1

1. Code Structure: Imports precede a focused manager class, providing clear organization, though many imports are unused in this snippet. 2. Nesting: The method has no nested control flow; nested method calls add only modest visual complexity. 3. Clarity of intent: Descriptive class, method, and parameter names clearly convey retrieval of a permission by its natural key. 4. Code length: The implementation is concise, but the extensive import block outweighs the small amount of functional code. 5. Action granularity: The single return expression performs a related lookup and retrieval, with multiline formatting keeping arguments readable. 6. Reading flow: The code progresses naturally from imports to class configuration to its method. An additional blank line before the top-level class would improve conventional Python formatting.

Run 2

Code Structure: Imports and the manager class are logically organized, though many imports are unused in this snippet. Nesting: Shallow structure, with only a nested lookup inside the return expression. Clarity of intent: Descriptive class, method, and parameter names make the natural-key lookup easy to understand, assuming familiarity with Django. Code length: The method is concise, but the extensive import list adds unnecessary length relative to the shown functionality. Action granularity: Statements are cleanly separated; the nested lookup combines two related retrieval operations without becoming difficult to follow. Reading flow: Consistent indentation and multiline formatting support natural reading, although an additional blank line before the top-level class would improve conventional Python formatting.

Run 3

Code Structure: Imports and a small manager class are logically organized, though many imports are unused in this snippet. Nesting: Shallow method structure; the nested lookup is straightforward. Clarity of intent: Descriptive class, method, and parameter names clearly express retrieving a permission by its natural key. Code length: The implementation is concise, but the extensive import list adds unnecessary reading overhead. Action granularity: Each import occupies its own line, and the return expression combines two closely related database lookups without becoming crowded. Reading flow: Consistent indentation and multiline formatting make the lookup easy to follow; separating import groups and adding another blank line before the class would improve visual organization.