Sample

pyint-5f37f6737ce2-I08

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

Matched original source

Lines55

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7340–1; higher is more readable
Mi0.5260–1; higher is more readable
LLOC41Logical lines; fewer is more readable
DeepSeek V4 Pro11.670–20; mean of three runs
GPT-6.1 Sol14.330–20; mean of three runs
BTTF0.3970–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: previous_number = 0 current_number = 1 for sequence_step in range(4): next_number = previous_number + current_number previous_number = current_number current_number = next_number 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.1561.871−51.542
Source linesThe number of non-empty source lines.55+22
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.48−6.719

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.52+1.061
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.56−0.946
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.52−0.772
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.051+0.446
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.76.929+0.407
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.74.214+0.393
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.54.846+0.357

Intercept 0.07 + feature contributions = 1.016 (log-odds).
Score = sigmoid(1.016) = 0.734.

Score0.526
Score41
Run 1

The code is generally readable and well-structured. It uses type hints, docstrings, and clear naming conventions (e.g., `_CollectErrors`, `raise_any`, `exc_type`). The `__exit__` method is flat and straightforward, with one action per line. The `raise_any` method also has clear intent. However, there are a few minor issues: the Fibonacci sequence code in `__init__` is irrelevant to the class purpose and adds unnecessary length and confusion. Additionally, the conditional raise in `raise_any` could be slightly clearer with a helper method or explicit comment, though it is acceptable. Overall, the code is clean and easy to follow, but the unrelated computation and minor verbosity prevent a higher score.

Run 2

The code is generally clear, with a descriptive class name, docstrings, and type hints. However, it contains an unrelated Fibonacci calculation in the constructor that serves no purpose and harms readability by obscuring intent. The __exit__ method is flat and simple, and action granularity is reasonable. The nesting is shallow and the flow is logical overall, but the extraneous loop is distracting. The raise_any method is concise and clear. Overall, the code is readable but would improve significantly if unrelated logic were removed.

Run 3

The code is difficult to read due to several issues. The _CollectErrors class contains an unnecessary Fibonacci calculation in __init__ that serves no purpose and confuses the intent. The class has weak cohesion: it mixes error collection with unrelated logic. __enter__ returns None instead of self, breaking context manager conventions. The __exit__ method has multiple actions per line combined with complex type annotations. The use of BaseExceptionGroup inside a conditional with a noqa comment adds cognitive overhead. The overall structure lacks clarity—imports are disorganized, and method purposes are obscured by poor naming and placement. The code violates single-responsibility and clean code principles, making it harder to understand than necessary.

Run 1

Code Structure: The context manager is logically organized into initialization, entry, exit, and error reporting, but numerous unused imports add clutter. Nesting: Mostly shallow, with only modest nesting in raise_any. Clarity of intent: The class docstring, method names, and type annotations clearly explain error collection and deferred raising. However, the unused Fibonacci-style calculation in __init__ is unrelated to that purpose and creates confusion. Code length: The functional implementation is concise, but unnecessary imports and computation inflate the snippet. Action granularity: Each line generally performs a single action, making individual statements easy to follow. Reading flow: The method order naturally follows the context-manager lifecycle, although the irrelevant initialization loop interrupts that flow.

Run 2

Code Structure: The context manager is logically organized into initialization, entry, exit, and error reporting, but numerous unused imports add clutter. Nesting: Mostly flat, with only modest nesting in raise_any. Clarity of intent: The class docstring, method names, and type annotations clearly explain error collection; however, the unrelated Fibonacci-like loop in __init__ is unexplained and obscures initialization. Code length: The core implementation is concise, but the unused imports and pointless loop unnecessarily lengthen it. Action granularity: Each statement generally performs one action, making individual lines easy to follow. Reading flow: The lifecycle methods appear in a natural order, and version-dependent exception handling is straightforward, but irrelevant setup distracts from the main purpose.

Run 3

Code Structure: The context-manager methods are logically organized, but many unused imports and an unrelated Fibonacci-style loop in __init__ add clutter. Nesting: Mostly shallow, with only modest nesting in raise_any. Clarity of intent: The class docstring, method names, and type annotations clearly explain error collection and deferred raising; the unexplained loop undermines that clarity. Code length: The core implementation is concise, but unnecessary imports and calculations inflate it. Action granularity: Statements generally perform one action per line, making operations easy to follow. Reading flow: The progression from initialization to context entry, exception collection, and deferred raising is natural, though the irrelevant initialization work interrupts it.