Sample

pyint-55727f5ff42c-I10

Deterministically remove some optional blank lines and bracketed line breaks

Matched original source

Lines39

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.310–1; higher is more readable
Mi0.3730–1; higher is more readable
LLOC31Logical lines; fewer is more readable
DeepSeek V4 Pro10.330–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.660–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.39+15.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.787−7.18

Intercept 8.87 + feature contributions = -36.269 (log-odds).
Score = sigmoid(-36.269) = 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.39+0.612
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.39−0.474
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.40−0.38
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.06+0.357
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.94−0.316
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.38.884+0.134

Intercept 0.07 + feature contributions = -0.802 (log-odds).
Score = sigmoid(-0.802) = 0.31.

Score0.373
Score31
Run 1

The code shows some readability but has several issues. Imports are mostly organized but include odd spacing in the deprecation import block and a trailing space in the __init__ signature. The SafeMIMEMultipart class has reasonable structure with clear inheritance and straightforward __init__ and __setitem__ methods. However, the __init__ method's parameter formatting is inconsistent—misaligned spacing and the `**_params` parameter lacks a space before it, reducing clarity. The docstring is missing, making intent less explicit. The __setitem__ method is concise, but the helper function `forbid_multi_line_headers` and `MIMEMixin` are not defined in this snippet, creating ambiguity about functionality. Nesting is flat and action granularity is good. Overall, the code is functional but suffers from formatting inconsistencies and missing context, placing it slightly above average.

Run 2

The code imports are excessive and disorganized, with mixed formatting and unnecessary imports (e.g., Charset, HeaderParseError, Header, Address, AddressHeader, parser, MIMEBase, MIMEMessage, MIMEText, BytesIO, StringIO, Path, DNS_NAME, get_current_timezone, warn_about_external_use). This suggests tangled structure and poor clarity of intent. The deprecation import block is heavily misaligned with inconsistent indentation and a trailing comma, hurting readability. The SafeMIMEMultipart class has no clear reason to combine MIMEMixin and MIMEMultipart, and its __init__ has odd parameter formatting (misaligned closing parenthesis, trailing spaces) that obscures intent. Nesting is shallow, which is good, and actions are mostly one per line, but the overall flow feels cluttered due to import noise and formatting issues. Code length is inflated by unused or contextually unrelated imports. Reading flow is impaired by the deprecation multiline import and inconsistent alignment. While the class itself is simple, the surrounding code and dependencies make it hard to see the purpose.

Run 3

The code shows some organizational strengths but suffers from formatting inconsistencies and unclear intent. Imports are logically grouped but have irregular spacing and alignment issues (e.g., the deprecation import block). The class implementation is brief, and nesting is minimal, which is positive. However, the constructor parameter alignment is inconsistent, making it harder to parse visually. Action granularity is reasonable—each line performs one logical operation—but the reading flow is disrupted by odd whitespace and parameter formatting. The class inherits from MIMEMixin which is not shown, reducing clarity of intent for someone reviewing this file in isolation. The use of `**_params` and `_subtype` with leading underscores suggests internal conventions but isn't self-explanatory. Overall, the code is functional but would benefit from consistent formatting, better alignment, and clearer separation of concerns in the import section to improve readability.

Run 1

Code Structure: Imports precede a small, logically organized class, although the many imports distract from the limited functionality shown. Nesting: Methods are flat and easy to follow. Clarity of intent: The class name and header-validation call clearly indicate safer MIME handling; however, MIMEMixin and forbid_multi_line_headers are not defined or imported in the snippet, reducing self-contained clarity. Code length: The implementation is concise, but the extensive import section is disproportionate to the displayed code. Action granularity: Each statement performs one clear action. Reading flow: Constructor setup followed by header assignment handling is natural, but irregular spacing, awkward import formatting, and the misplaced closing parenthesis in the constructor signature disrupt scanning.

Run 2

Code Structure: Imports precede a small, logically organized class, although many imports are unused in this excerpt and dependencies such as MIMEMixin are not shown. Nesting: Minimal nesting makes both methods easy to follow. Clarity of intent: The class name and header-validation call convey safe multipart handling, though abbreviated parameter names and missing context slightly reduce clarity. Code length: Methods are concise, but the extensive import block overwhelms the small implementation. Action granularity: Each statement performs one clear action. Reading flow: Method execution reads naturally, but inconsistent spacing, awkward multiline formatting in the deprecation import and constructor signature, and limited separation between imports and the class disrupt scanning.

Run 3

Code Structure: Imports precede a small, logically organized class, though many imports are unused in this snippet and dependency definitions are absent. Nesting: Methods are flat and easy to follow. Clarity of intent: The class name and header-validation call clearly convey safer MIME handling, although MIMEMixin and forbid_multi_line_headers require external context. Code length: Methods are concise, but the extensive import list outweighs the shown implementation. Action granularity: Each statement performs one clear action on its own line. Reading flow: Initialization followed by header assignment is natural, but inconsistent spacing and awkward wrapping in the deprecation import and constructor signature interrupt scanning.