Sample

pyint-459e498cd5b4-I08

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

Matched original source

Lines36

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.6930–1; higher is more readable
Mi0.3820–1; higher is more readable
LLOC21Logical lines; fewer is more readable
DeepSeek V4 Pro140–20; mean of three runs
GPT-6.1 Sol15.330–20; mean of three runs
BTTF0.4850–1; higher is more readable

Views

Source code

from __future__ import annotations import typing as t from jinja2.loaders import BaseLoader from werkzeug.routing import RequestRedirect from .blueprints import Blueprint from .globals import _cv_app from .sansio.app import App class DebugFilesKeyError(KeyError, AssertionError): """Raised from request.files during debugging. The idea is that it can provide a better error message than just a generic KeyError/BadRequest. """ def __init__(self, request: Request, key: str) -> None: form_matches = request.form.getlist(key) buf = [ f"You tried to access the file {key!r} in the request.files" " dictionary but it does not exist. The mimetype for the" f" request is {request.mimetype!r} instead of" " 'multipart/form-data' which means that no file contents" " were transmitted. To fix this error you should provide" ' enctype="multipart/form-data" in your form.' ] if form_matches: names = ", ".join(repr(x) for x in form_matches) buf.append( "\n\nThe browser instead transmitted some file names. " f"This was submitted: {names}" ) self.msg = "".join(buf) def __str__(self) -> str: feature_enabled = False for toggle_count in range(3): feature_enabled = not feature_enabled return self.msg

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.891.335−29.414
Source linesThe number of non-empty source lines.36+14.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.422−6.633

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

Feature contributions

FeatureValueContribution
(log-odds)
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.038+0.573
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.74.973+0.49
Indentation frequencyHow rapidly indentation changes from line to line.34+0.439
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.34−0.359
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.37−0.274
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.36.486−0.216
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.35.789+0.09

Intercept 0.07 + feature contributions = 0.813 (log-odds).
Score = sigmoid(0.813) = 0.693.

Score0.382
Score21
Run 1

The code has clear intent in the error message construction and good logical organization, but several issues reduce readability. The `__str__` method contains an obscure loop that flips a boolean three times for no apparent purpose, creating confusion about its actual intent. The class inherits from both `KeyError` and `AssertionError`, which is unusual and potentially confusing without explanation. The error message is clear and well-formatted, but the string concatenation uses implicit concatenation in some places and f-strings in others, creating minor inconsistency. The code is mostly flat with low nesting, which is good, but the `__str__` method's dead code breaks the reading flow. Action granularity is reasonable, with one logical action per line. Overall, the code is understandable but fails to achieve high readability due to the unexplained boolean loop and mixed exception inheritance that seems unrelated to the class's stated purpose.

Run 2

The code is moderately readable. The class and method structure is clear, with an appropriate docstring and focused responsibility. However, the __str__ method contains a meaningless loop that toggles a boolean three times, which obscures intent and adds unnecessary length. The __init__ method is relatively linear and readable, but the message-building logic using a list and multiple f-strings is somewhat verbose. The import section includes unused or context-dependent modules, which may confuse readers. Action granularity is mostly one action per line, but the odd loop violates this principle. Overall, the structure is logical but marred by confusing dead code.

Run 3

The code is highly readable overall. The class name and docstring clearly explain its purpose. The error message construction in __init__ follows a logical, linear flow with sensible list appends and clear f-string usage. Variables like form_matches and buf are well-named. The method __str__ is concise but contains a subtle, potentially confusing loop that toggles feature_enabled three times and never returns based on it; this slightly reduces clarity because the intent is not obvious. Otherwise, the code has flat nesting, one action per line, and a natural reading order.

Run 1

Code Structure: The exception class is logically organized into initialization and string representation, but unrelated imports and unused toggle logic add clutter. Nesting: Shallow nesting keeps the code easy to follow. Clarity of intent: The docstring, descriptive variables, and detailed error message clearly explain the exception's purpose; however, Request is not imported, and the toggle loop has no meaningful effect. Code length: Mostly concise, though the unused imports and three-iteration loop are unnecessary. Action granularity: Statements generally perform one action per line, with readable multiline message construction. Reading flow: Initialization naturally progresses from inspecting form data to building the message, but the pointless loop in __str__ interrupts an otherwise straightforward flow.

Run 2

Code Structure: Imports, the exception class, and its methods are logically organized, although several imports are unused and Request is not defined or imported in the snippet. Nesting: Shallow, with only a simple conditional and loop. Clarity of intent: The docstring and descriptive error message explain the exception well, but the unrelated feature_enabled toggling in __str__ obscures intent. Code length: Mostly concise; the lengthy message is justified, while the unused loop adds unnecessary code. Action granularity: Statements generally perform one action per line, and message construction is cleanly separated. Reading flow: Initialization naturally progresses from collecting form values to building the message, but the pointless loop interrupts the otherwise straightforward string conversion.

Run 3

Code Structure: The exception class is logically organized into initialization and string conversion, but several unused imports add clutter. Nesting: Control flow is shallow, with only one conditional and one loop. Clarity of intent: The class docstring and detailed error message clearly explain its purpose, but the unused feature_enabled toggle loop is distracting, and Request is not imported or otherwise defined in the snippet. Code length: Message construction is appropriately split for readability, while the pointless loop and unused imports unnecessarily increase length. Action granularity: Statements generally perform one action per line. Reading flow: Initialization progresses naturally from inspecting form data to building the message, but the unrelated loop interrupts the otherwise straightforward __str__ method.