Sample

pyint-7e483030b0c6-I10

Deterministically remove some optional blank lines and bracketed line breaks

Matched original source

Lines45

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7210–1; higher is more readable
Mi0.4340–1; higher is more readable
LLOC35Logical lines; fewer is more readable
DeepSeek V4 Pro14.670–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.5790–1; higher is more readable

Views

Source code

from __future__ import annotations import importlib.util import os import sys import typing as t from datetime import datetime from functools import cache from functools import update_wrapper from types import TracebackType import werkzeug.utils from werkzeug.exceptions import abort as _wz_abort from werkzeug.utils import redirect as _wz_redirect from werkzeug.wrappers import Response as BaseResponse from .globals import _cv_app from .globals import app_ctx from .globals import current_app from .globals import request from .globals import session from .signals import message_flashed class _CollectErrors: """A context manager that records and silences an error raised within it. Used to run all teardown functions, then raise any errors afterward. """ def __init__(self) -> None: self.errors: list[BaseException] = [] def __enter__(self) -> None: pass def __exit__( self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None, ) -> bool: if exc_val is not None: self.errors.append(exc_val) return True def raise_any(self, message: str) -> None: """Raise if any errors were collected.""" if self.errors: if sys.version_info >= (3, 11): raise BaseExceptionGroup(message, self.errors) # noqa: F821 else: raise self.errors[0]

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.1363.068−44.981
Source linesThe number of non-empty source lines.45+18
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.515−6.772

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.42+0.716
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.46−0.592
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.83.87+0.549
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.42−0.543
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.053+0.427
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.44.847+0.217
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.83.978+0.108

Intercept 0.07 + feature contributions = 0.951 (log-odds).
Score = sigmoid(0.951) = 0.721.

Score0.434
Score35
Run 1

The code is generally readable and well-structured, with clear imports, a single class definition, and docstrings. It covers error-collection logic logically. However, improvements could make it cleaner. The function signature for __exit__ places multiple parameters and type hints on one line, harming action granularity and readability. The conditional version check for BaseExceptionGroup is slightly awkward, with a 'noqa' comment that breaks flow. Naming is clear, and the code length is concise. Overall, it’s readable but would benefit from splitting long lines and slightly simplifying the version-specific logic.

Run 2

The code is generally readable with clear imports, type hints, and a focused single-class design. The docstring explains the context manager's purpose well. However, readability is hampered by overly long import lines (e.g., `from werkzeug.exceptions import abort as _wz_abort`), collapsed function signatures (e.g., `__exit__` parameters on one physical line), and inconsistent spacing within the `__exit__` method. The `raise_any` method uses a conditional check for Python version which adds minor complexity. Overall structure is logical and nesting is flat, but action granularity and reading flow suffer from formatting inconsistencies and packed lines.

Run 3

The code has good structure with a single class and clear methods. Imports are organized, though somewhat lengthy. The class has a clear docstring explaining its purpose. The __exit__ method has odd formatting with misaligned parameters and the exc_type parameter is unused, which slightly hurts readability. Nesting is minimal and acceptable. The raise_any method is clear in intent, handling version differences cleanly. Action granularity is mostly appropriate, though parameter alignment in __exit__ could be improved. The code is concise and avoids unnecessary verbosity. The main readability issues are the formatting inconsistency in __exit__ and the unused exc_type parameter, which creates minor confusion.

Run 1

Code Structure: The context manager is logically organized into initialization, entry, exit, and error reporting, but numerous unused imports distract from the class. Nesting: Shallow overall; the nested version check in raise_any is easy to follow. Clarity of intent: The class docstring, method names, and type annotations clearly explain error collection and deferred raising. Code length: The implementation is concise, although the import block is disproportionately long for this snippet. Action granularity: Statements generally perform one action per line, but two parameters share an awkwardly spaced line in __exit__. Reading flow: Methods follow the context-manager lifecycle naturally, but missing blank lines between imports, the class, and some methods weaken visual separation.

Run 2

Code Structure: The context-manager class logically separates initialization, entry, exit, and error propagation, but numerous unused imports and inconsistent blank lines add clutter. Nesting: Shallow overall, with only two conditional levels in raise_any. Clarity of intent: Descriptive method names, type annotations, and docstrings clearly explain collecting, suppressing, and later raising errors. Code length: The implementation is concise, although the imports are excessive for this snippet. Action granularity: Most lines perform one action; placing two parameters on the same awkwardly spaced line reduces scanability. Reading flow: Methods follow the natural context-manager lifecycle, but cramped spacing between definitions and poorly formatted parameters interrupt otherwise straightforward reading.

Run 3

Code Structure: The class logically groups error collection and deferred raising, but numerous unused imports clutter the snippet. Nesting: Methods are mostly flat; raise_any has only modest conditional nesting. Clarity of intent: The class docstring, descriptive method names, and type annotations clearly explain its purpose, though unconditional exception suppression requires careful reading. Code length: The implementation is concise, but the import block is disproportionate to the functionality shown. Action granularity: Statements generally perform one action per line; placing two parameters on the same oddly spaced line reduces scanability. Reading flow: Methods follow a natural context-manager lifecycle, ending with deferred error handling. Missing blank lines between imports, the class, and some methods, plus inconsistent parameter formatting, interrupt otherwise straightforward reading.