Sample

pyint-f3f6521b35ce-I01

Remove comments and docstrings

Matched original source

Lines43

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.3670–1; higher is more readable
Mi0.4230–1; higher is more readable
LLOC31Logical lines; fewer is more readable
DeepSeek V4 Pro130–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.6770–1; higher is more readable

Views

Source code

import email.message import email.policy import mimetypes import warnings from collections import namedtuple from datetime import datetime, timezone from email import charset as Charset from email import generator from email.errors import HeaderParseError from email.header import Header from email.headerregistry import Address, AddressHeader, parser from email.mime.base import MIMEBase from email.mime.message import MIMEMessage from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.utils import formataddr, getaddresses, make_msgid from io import BytesIO, StringIO from pathlib import Path from django.conf import settings from django.core.mail.utils import DNS_NAME from django.utils.deprecation import ( RemovedInDjango70Warning, deprecate_posargs, warn_about_external_use, ) from django.utils.encoding import force_bytes, force_str, punycode from django.utils.timezone import get_current_timezone from .deprecation import ( CONNECTION_ARG_WARNING, FAIL_SILENTLY_ARG_WARNING, report_using_incompatibility, ) class SafeMIMEMultipart(MIMEMixin, MIMEMultipart): def __init__( self, _subtype="mixed", boundary=None, _subparts=None, encoding=None, **_params ): self.encoding = encoding MIMEMultipart.__init__(self, _subtype, boundary, _subparts, **_params) def __setitem__(self, name, val): name, val = forbid_multi_line_headers(name, val, self.encoding) MIMEMultipart.__setitem__(self, name, val)

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.1623.002−53.559
Source linesThe number of non-empty source lines.43+17.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.792−7.188

Intercept 8.87 + feature contributions = -34.677 (log-odds).
Score = sigmoid(-34.677) = 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
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
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.44−0.522
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.06+0.356
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.42.784+0.188
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.86.977−0.019

Intercept 0.07 + feature contributions = -0.547 (log-odds).
Score = sigmoid(-0.547) = 0.367.

Score0.423
Score31
Run 1

The code demonstrates good organization through logical imports and a clear class hierarchy. The SafeMIMEMultipart class extends MIMEMixin and MIMEMultipart with a focused single responsibility. Nesting is minimal—only the __init__ method signature spans multiple lines for readability. Intent is clear: creating a safe multipart MIME class with validation for multi-line headers. The __setitem__ override clearly handles header injection prevention. Code length is appropriate, and action granularity is mostly one action per line, though the multi-line function signatures could be slightly more readable with better formatting. Reading flow is natural, with imports grouped by type (stdlib, Django, local) and methods organized logically. Minor deductions include the somewhat cluttered import section and the multi-line signature that could benefit from more consistent indentation or documentation explaining the 'forbid_multi_line_headers' purpose.

Run 2

The code imports many modules without clear organization or grouping, which reduces readability. The class `SafeMIMEMultipart` is short but inherits from `MIMEMixin` and `MIMEMultipart`; `MIMEMixin` is never defined or imported, so the intent is unclear and the code appears broken. Nesting is minimal, but method overrides lack docstrings or comments explaining why they exist. The `__init__` and `__setitem__` methods are concise but terse—parameter names like `_subtype` and `_params` are not self-explanatory. Action granularity is good; most lines do one thing. However, the overall structure feels fragmented due to missing context and unclear inheritance. The reading flow is interrupted by the need to infer purpose from Django internals without documentation.

Run 3

The code demonstrates good readability due to clear organizational structure, minimal nesting, and direct intent. The imports are logically grouped (standard library, Django dependencies, local modules), and the class definition is straightforward. The __init__ method properly passes parameters to its parent class, maintaining clear action granularity. The __setitem__ override has a single responsibility and includes a descriptive function name (forbid_multi_line_headers) that aids understanding. Minor deductions include: the MIMEMixin import is not shown but presumably exists, the deprecation import ordering could be more alphabetized, and the _params double-asterisk pattern requires some Python knowledge. The code remains concise without unnecessary verbosity. Reading flow is natural, progressing from imports to class definition to method implementations. The overall structure supports easy comprehension of the security-focused modification to standard email handling.

Run 1

Code Structure: Imports precede a compact class with logically separated initialization and header assignment methods, though many imports are unused in this excerpt. Nesting: Minimal nesting makes both methods easy to follow. Clarity of intent: The class name and header-validation call communicate safe MIME handling, but MIMEMixin and forbid_multi_line_headers are not defined in the excerpt. Code length: The class is concise, while the extensive import section outweighs the shown implementation. Action granularity: Each statement performs one clear action. Reading flow: Initialization followed by the header-assignment override is natural; an additional blank line before the class would improve visual separation.

Run 2

Code Structure: Imports precede a compact class with clearly separated initialization and header-setting methods, though many imports are unused in this excerpt. Nesting: Methods are flat, with no nested control flow. Clarity of intent: The class name and header-validation call communicate safe multipart message handling; undefined dependencies such as MIMEMixin and forbid_multi_line_headers require external context. Code length: The implementation is concise, but the extensive import block outweighs the small class shown. Action granularity: Each statement performs one clear action. Reading flow: Initialization followed by header assignment is natural, and formatting is consistent, although additional spacing between import groups and before the class would improve visual organization.

Run 3

Code Structure: Imports are grouped sensibly, and the class has two focused methods, though many imports are unused in this excerpt. Nesting: The methods are flat, with no nested control flow. Clarity of intent: SafeMIMEMultipart and forbid_multi_line_headers clearly suggest header validation, but MIMEMixin and the validation helper are not defined here, limiting standalone understanding. Code length: The class is concise, although the extensive import block outweighs the implementation shown. Action granularity: Statements generally perform one action per line; tuple unpacking naturally captures the validation result. Reading flow: Initialization followed by header assignment handling is logical and easy to follow. Explicit parent-class calls and abbreviated parameter names add minor reading friction.