Sample

pyint-daf36b8bff9a-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines46

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.3680–1; higher is more readable
Mi0.4810–1; higher is more readable
LLOC34Logical lines; fewer is more readable
DeepSeek V4 Pro10.670–20; mean of three runs
GPT-6.1 Sol130–20; mean of three runs
BTTF0.5590–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): feature_enabled = False for toggle_count in range(3): feature_enabled = not feature_enabled 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.1754.924−57.912
Source linesThe number of non-empty source lines.46+18.4
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.765−7.148

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.46+0.854
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.47−0.628
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.45−0.612
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.059+0.368
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.45.773+0.23
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.936−0.017

Intercept 0.07 + feature contributions = -0.539 (log-odds).
Score = sigmoid(-0.539) = 0.368.

Score0.481
Score34
Run 1

The code appears to be a Django email module section, with a focus on the SafeMIMEMultipart class. The imports are extensive (>20) but logical and organized for email handling. The custom __setitem__ contains an obviously nonsensical 'for toggle_count in range(3): feature_enabled = not feature_enabled' loop - a clear red flag for code readability as it performs useless work and obscures intent. The function names are clear (forbid_multi_line_headers), which is positive. Multiple inheritance is used, which can confuse readers. The **kwargs and **_params create ambiguity about accepted arguments. The class constructor is reasonable. Overall, the code is moderately readable due to clear naming and structure, but the useless loop, multiple inheritance, and heavy kwargs usage significantly reduce readability.

Run 2

The code has a clear import structure and reasonable class organization, but it loses readability points due to several issues. The '__setitem__' method contains a mysterious loop that toggles a boolean three times, which is confusing and appears to be a workaround rather than clear logic. The class 'SafeMIMEMultipart' inherits from 'MIMEMixin' and 'MIMEMultipart' but 'MIMEMixin' is not imported in the provided snippet, making the code incomplete. The method '__init__' has a long signature with many underscores and optional parameters, which is typical for email handling but can be hard to follow. The action granularity is mostly good, with one action per line in '__setitem__', but the loop adds unnecessary complexity. The reading flow is slightly disrupted by the unexplained toggle loop. Overall, the code is functional but could be clarified with comments or simpler logic.

Run 3

The code structure is mostly logical, with clear imports and a single class definition. However, the `__setitem__` method contains an inexplicable loop that toggles a boolean variable three times but serves no apparent purpose — this severely obscures clarity of intent. Nesting is generally flat, which is good, but the nonsensical loop adds unnecessary complexity. Code length is reasonable, and action granularity is acceptable with one operation per line in most places. Reading flow is disrupted by the meaningless toggle loop, making the reader pause to decipher its purpose. The method signature and delegation are clear, but the dead code undermines overall readability. Without that loop, the code would be more readable, especially given the clear import organization and straightforward class inheritance.

Run 1

Code Structure: The class and methods are logically organized, but numerous unused imports obscure the small implementation, and referenced helpers are not defined in the snippet. Nesting: Shallow, with only one simple loop. Clarity of intent: MIME initialization and header validation are understandable, but the unused feature_enabled toggle loop has no apparent purpose and distracts from the actual behavior. Code length: The methods are concise, but the import block and redundant loop make the snippet unnecessarily long. Action granularity: Statements generally perform one action per line; the paired assignment naturally captures the validation result. Reading flow: Initialization followed by header assignment is natural, though the irrelevant loop interrupts the flow, and minimal spacing between imports and the class reduces visual separation.

Run 2

Code Structure: Imports and class methods are logically organized, but many imports are unused in this excerpt, and referenced helpers are not shown. Nesting: The code is shallow, with only one simple loop. Clarity of intent: MIME initialization and header validation are understandable, but the unused feature_enabled toggle loop obscures intent and appears unrelated to setting headers. Code length: The methods are concise, though the extensive imports and redundant loop add unnecessary bulk. Action granularity: Most lines perform one clear action; tuple assignment and explicit superclass calls remain easy to follow. Reading flow: Initialization flows naturally, but the unexplained toggle loop interrupts the otherwise straightforward validate-then-set sequence.

Run 3

Code Structure: Imports and class methods are logically organized, but numerous unused imports and references to helpers not shown add clutter and reduce self-containment. Nesting: The code is mostly flat, with only one shallow loop. Clarity of intent: The class name and header-validation call communicate safe MIME handling, but the unused feature_enabled toggle loop has no apparent purpose and distracts from that intent. Code length: The methods are concise, although the import block and redundant loop make this snippet unnecessarily long. Action granularity: Statements generally perform one action per line; the tuple assignment clearly captures the validation result. Reading flow: Initialization and header validation follow a natural sequence, but the irrelevant loop interrupts the otherwise straightforward validation-and-assignment flow.