Sample

pyint-0cd497ec903a-I05

Rewrite eligible decimal integer literals in hexadecimal notation

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 is moderately readable but has several issues. The import section is lengthy but organized by type. The class definition is simple, but the __init__ method contains multiple operations in a single line and lacks type hints or docstrings. The __setitem__ method chains a helper function call with a parent method call, which reduces clarity. The use of double underscores and mixing of MIMEMixin and MIMEMultipart inheritance creates ambiguity about the class's true purpose. While the code is flat and not deeply nested, the lack of comments explaining the safety wrapper's intent hurts comprehension. The variable naming like _subtype and **_params is conventional for MIME but may confuse newcomers. Overall, the code is functional but could benefit from better documentation and clearer separation of actions.

Run 2

The code shows moderate readability with clear imports and a straightforward class definition. The class SafeMIMEMultipart has a logical structure with a simple __init__ method. However, several issues reduce readability: the parameter naming is inconsistent (underscore-prefixed params mixed with non-prefixed), the class inherits from MIMEMixin which is not defined in the shown code, and the __setitem__ method relies on an external function (forbid_multi_line_headers) that may not be obvious to readers. The code is relatively flat with minimal nesting, which is positive. Intent is somewhat clear (safety wrapper for MIME multipart), but the overall purpose could be more explicit through docstrings. Action granularity is acceptable with one main operation per line. The code would benefit from type hints, docstrings explaining the safety mechanism, and clearer variable naming.

Run 3

The code has clear imports and a logical structure, but has several readability issues. The class definition is concise but mixes responsibilities (MIMEMixin and MIMEMultipart inheritance) without indicating the purpose of the mixin. The __init__ method uses underscore-prefixed parameters, which is a convention that may confuse readers. __setitem__ mutates arguments before delegating, making the flow less obvious. The function forbid_multi_line_headers is used without explanation, leaving intent ambiguous. Some lines, such as the parameter list in __init__, pack multiple items together. The reading flow is natural in places but interrupted by parameter ordering and lack of docstrings or comments explaining safety measures. Overall, it is readable but could be improved with clearer naming, separation of validation logic, and explanatory comments.

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: Methods are flat, with no nested control flow. Clarity of intent: SafeMIMEMultipart and forbid_multi_line_headers clearly communicate header validation, but MIMEMixin and the validation helper are not defined here, limiting standalone understanding. Code length: The class is concise, while the extensive import block outweighs the implementation shown. Action granularity: Each statement performs one clear action. Reading flow: Initialization followed by customized header assignment is natural; grouped imports and multiline formatting help scanning, although an additional blank line before the class would improve visual separation.

Run 2

Code Structure: Imports are grouped by source, followed by a small class with logically separated initialization and header assignment methods; many imports are unused in this excerpt. Nesting: Flat methods with no nested control flow make scanning easy. Clarity of intent: SafeMIMEMultipart and forbid_multi_line_headers clearly convey defensive header handling, although MIMEMixin and the validation helper are not defined here, and val is a generic name. Code length: The class is concise, but the extensive import block is disproportionate to the shown functionality. Action granularity: Each statement performs a focused operation; tuple unpacking cleanly captures the validated header pair. Reading flow: Initialization followed by customized assignment reads naturally, with consistent indentation and a readable multiline signature. Additional blank lines between import groups and before the class would improve visual separation.

Run 3

Code Structure: Imports are grouped sensibly, followed by a focused class with two short methods, although many imports are unused in this excerpt. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The class name and header-validation call communicate safe multipart handling, but MIMEMixin and forbid_multi_line_headers are not defined here, and val is a generic name. Code length: The implementation is concise; the extensive import section dominates this small excerpt. Action granularity: Each statement performs one clear operation, with the tuple assignment naturally representing a single validation step. Reading flow: Initialization followed by header assignment is logical, and formatting is consistent. Direct parent-class calls and the long constructor signature introduce minor reading friction.