Sample

pyint-b74d42aa3796-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines49

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7410–1; higher is more readable
Mi0.3840–1; higher is more readable
LLOC35Logical lines; fewer is more readable
DeepSeek V4 Pro17.670–20; mean of three runs
GPT-6.1 Sol17.330–20; mean of three runs
BTTF0.6210–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.49+19.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.517−6.776

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.46+0.854
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.50−0.734
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.46−0.635
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.053+0.427
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.94+0.406
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.73.88+0.388
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.48.846+0.273

Intercept 0.07 + feature contributions = 1.049 (log-odds).
Score = sigmoid(1.049) = 0.741.

Score0.384
Score35
Run 1

The code is highly readable. It has a clear, single-purpose class with a docstring explaining its role. Imports are logically grouped from stdlib to third-party to local. Nesting is minimal, with only one conditional block in raise_any and a version check inside it. Intent is explicit through descriptive names like _CollectErrors, raise_any, and message_flashed. The code is concise without being terse, and each significant action (appending an error, raising) sits on its own line. Reading flow is natural, following a standard class structure: init, enter, exit, helper method. Type hints are used consistently. The only minor deduction is that the `__enter__` method is a no-op with `pass`, which adds a tiny bit of boilerplate, but it is required for context manager protocol and clearly intentional.

Run 2

The code is well-structured with clear separation of imports, a single cohesive class, and logical method organization. Nesting is minimal, with no deeply nested blocks. Intent is clearly communicated through descriptive naming and a concise docstring explaining the context manager's purpose. Code length is appropriate—no unnecessary verbosity. Each action is on its own line, maintaining clarity. Reading flow is natural, with the class definition and methods ordered intuitively. Minor deductions for the conditional version check and the slightly redundant __enter__ method, but overall the code is highly readable and maintainable.

Run 3

The code is well-structured with clear separation of imports, class definition, and methods. Nesting is minimal (one level in __exit__ and raise_any). Intent is clear: a context manager that collects and silences errors for later. Length is concise with no unnecessary code. Action granularity is generally one action per line, though the __exit__ method could be slightly more compact. Reading flow is natural, with logical progression from initialization to error handling. Minor deductions: the version check in raise_any introduces a slight complexity and the empty __enter__ method could be omitted (though it's explicit). Overall highly readable.

Run 1

Code Structure: The context manager is logically organized into initialization, entry, exit, and deferred error reporting, although many imports are unused in this snippet. Nesting: Control flow is shallow, with only two levels in raise_any. Clarity of intent: The class docstring, descriptive method names, and type annotations clearly explain error collection and deferred raising; unconditional suppression in __exit__ is consistent with that purpose. Code length: The implementation is concise, though the import block is disproportionately long relative to the class. Action granularity: Each line generally performs one action, making behavior easy to follow. Reading flow: Methods appear in a natural lifecycle order, and whitespace separates operations cleanly. Minor drawbacks include limited spacing between imports and the class and a compatibility branch that adds slight cognitive overhead.

Run 2

Code Structure: The class cleanly separates initialization, context-manager behavior, and deferred error raising, although many imports are unused in this snippet. Nesting: Mostly flat, with only modest nesting in raise_any. Clarity of intent: Descriptive names, type annotations, and docstrings clearly explain error collection and suppression; returning True unconditionally deserves some attention. Code length: The implementation is concise, but the extensive import block adds distraction relative to the small class. Action granularity: Each line generally performs one action, making behavior easy to follow. Reading flow: Methods appear in a natural lifecycle order, from initialization through entry, exit, and reporting collected errors. Overall, the code is highly readable, with minor clutter and a version-dependent exception-handling branch.

Run 3

Code Structure: The context manager is logically organized into initialization, entry, exit, and error reporting, though many imports are unused in this excerpt. Nesting: Shallow overall, with only a small nested conditional in raise_any. Clarity of intent: Descriptive names, type annotations, and docstrings clearly explain error collection and deferred raising; always returning True may require familiarity with context managers. Code length: The class is concise, but the extensive import list adds clutter relative to its size. Action granularity: Each line performs a single clear action, with no compressed statements. Reading flow: Methods follow the natural context-manager lifecycle, and spacing supports scanning. The Python-version fallback is straightforward, although its behavior of raising only the first collected error could be documented more explicitly.