Sample

pyint-f1a8bc187542-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines35

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8230–1; higher is more readable
Mi0.3880–1; higher is more readable
LLOC19Logical lines; fewer is more readable
DeepSeek V4 Pro15.330–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.5530–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 not (form_matches): pass else: 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: 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.827.453−27.306
Source linesThe number of non-empty source lines.35+14
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.41−6.615

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

Feature contributions

FeatureValueContribution
(log-odds)
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.039+0.564
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.917+0.492
Indentation frequencyHow rapidly indentation changes from line to line.33+0.404
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.36−0.238
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.35.417−0.233
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.34.895+0.078

Intercept 0.07 + feature contributions = 1.535 (log-odds).
Score = sigmoid(1.535) = 0.823.

Score0.388
Score19
Run 1

The code is generally readable with clear structure and intent. The class has a focused purpose and the error message construction is logical. However, there are a few issues: the empty if/else block with 'pass' adds unnecessary nesting and could be improved; the message string concatenation across multiple f-strings and literals is slightly awkward; and the type hint for `request: Request` is not imported, which would break at runtime. The code is relatively flat and concise, with one logical action per line mostly maintained. The reading flow is natural, though the conditional could be restructured for clarity. Overall, it's clear but has minor structural inefficiencies.

Run 2

The code is generally readable with a clear purpose and logical structure. The class has a focused responsibility — providing a better error message — and the message-building logic is straightforward. Nesting is minimal, with only a single if/else block. Clarity is aided by descriptive variable names (e.g., form_matches, buf) and an informative docstring. However, the `if not (form_matches): pass else:` pattern is awkward and needlessly verbose; a simple `if form_matches:` would be clearer and shorter. The line length for the f-string is long, slightly hurting readability. Action granularity is mostly one action per line, but the long string concatenation across lines could be split more cleanly. Overall, the code is readable but could be improved with minor refactoring to eliminate the empty branch and improve string construction.

Run 3

The code has a clear purpose and is generally readable, but it has some unnecessary constructs that reduce clarity. The class name and docstring are helpful. Structure is logical, and nesting is shallow—only one if/else block with a redundant 'pass' branch, which could be inverted for better flow. The 'if not (form_matches): pass else: ...' pattern is awkward and hurts reading flow. Action granularity is mostly fine, though list-building in __init__ is slightly verbose. The imported types (App, Blueprint, BaseLoader) are unused and add noise. The error message construction is clear but could benefit from a direct multiline string instead of incremental appends. Overall, the code is understandable but has small style issues that prevent it from being highly readable.

Run 1

Code Structure: The exception class is logically organized, with message construction in __init__ and rendering in __str__, although unused imports add clutter. Nesting: Nesting is shallow, but the empty if branch followed by else is unnecessarily awkward; a direct if form_matches would be clearer. Clarity of intent: The descriptive class name, docstring, and detailed error message make the purpose clear. The Request annotation lacks a visible import, and names like buf are somewhat generic. Code length: The implementation is reasonably concise, though unnecessary imports and the pass branch lengthen it without benefit. Action granularity: Each statement performs a distinct action; the multiline strings appropriately represent a single message. Reading flow: Initialization, optional message expansion, and final assembly follow a natural sequence, slightly disrupted by the inverted conditional and sparse spacing around top-level definitions.

Run 2

Code Structure: The exception class is logically organized, with initialization separated from string conversion, although several imports are unused and Request is not visibly imported. Nesting: Shallow nesting makes the code easy to follow, but the empty if branch and substantive else branch are needlessly awkward. Clarity of intent: The descriptive class name, docstring, and explicit error message clearly communicate its debugging purpose; buf is less descriptive than message_parts. Code length: Reasonably concise, though the pass branch and redundant parentheses could be removed. Action granularity: Statements generally perform one action each, and the long message is split into readable lines. Reading flow: Construction proceeds naturally from request data to explanatory message to stored output, but replacing if not (form_matches): pass with if form_matches: would improve flow.

Run 3

Code Structure: The exception class is logically organized, with message construction in the initializer and rendering in __str__, although several unused imports add clutter. Nesting: Shallow nesting makes the code easy to follow, but the empty if branch and else are unnecessarily awkward. Clarity of intent: The class name, docstring, and descriptive error message clearly convey its debugging purpose; the Request annotation lacks a visible import. Code length: Mostly concise, though the no-op branch and unnecessary parentheses could be replaced with a direct if form_matches condition. Action granularity: Statements generally perform one action each, and multiline string formatting remains readable. Reading flow: Message initialization, optional details, and final assignment follow a natural sequence, slightly disrupted by the pass branch and generic variable name buf.