Sample

pyint-37930a586fe4-I10

Deterministically remove some optional blank lines and bracketed line breaks

Matched original source

Lines74

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.630–1; higher is more readable
Mi0.0520–1; higher is more readable
LLOC36Logical lines; fewer is more readable
DeepSeek V4 Pro9.330–20; mean of three runs
GPT-6.1 Sol140–20; mean of three runs
BTTF0.4130–1; higher is more readable

Views

Source code

from __future__ import annotations import importlib.metadata import typing as t from contextlib import contextmanager from contextlib import ExitStack from copy import copy from types import TracebackType from urllib.parse import urlsplit import werkzeug.test from click.testing import CliRunner from click.testing import Result from werkzeug.test import Client from werkzeug.wrappers import Request as BaseRequest from .cli import ScriptInfo from .sessions import SessionMixin class EnvironBuilder(werkzeug.test.EnvironBuilder): """An :class:`~werkzeug.test.EnvironBuilder`, that takes defaults from the application. :param app: The Flask application to configure the environment from. :param path: URL path being requested. :param base_url: Base URL where the app is being served, which ``path`` is relative to. If not given, built from :data:`PREFERRED_URL_SCHEME`, ``subdomain``, :data:`SERVER_NAME`, and :data:`APPLICATION_ROOT`. :param subdomain: Subdomain name to append to :data:`SERVER_NAME`. :param url_scheme: Scheme to use instead of :data:`PREFERRED_URL_SCHEME`. :param json: If given, this is serialized as JSON and passed as ``data``. Also defaults ``content_type`` to ``application/json``. :param args: other positional arguments passed to :class:`~werkzeug.test.EnvironBuilder`. :param kwargs: other keyword arguments passed to :class:`~werkzeug.test.EnvironBuilder`. """ def __init__( self, app: Flask, path: str = "/", base_url: str | None = None, subdomain: str | None = None, url_scheme: str | None = None, *args: t.Any, **kwargs: t.Any, ) -> None: assert not (base_url or subdomain or url_scheme) or ( base_url is not None ) != bool(subdomain or url_scheme), ( 'Cannot pass "subdomain" or "url_scheme" with "base_url".' ) if base_url is None: http_host = app.config.get("SERVER_NAME") or "localhost" app_root = app.config["APPLICATION_ROOT"] if subdomain: http_host = f"{subdomain}.{http_host}" if url_scheme is None: url_scheme = app.config["PREFERRED_URL_SCHEME"] url = urlsplit(path) base_url = ( f"{url.scheme or url_scheme}://{url.netloc or http_host}" f"/{app_root.lstrip('/')}" ) path = url.path if url.query: path = f"{path}?{url.query}" self.app = app super().__init__(path, base_url, *args, **kwargs) def json_dumps(self, obj: t.Any, **kwargs: t.Any) -> str: """Serialize ``obj`` to a JSON-formatted string. The serialization will be configured according to the config associated with this EnvironBuilder's ``app``. """ return self.app.json.dumps(obj, **kwargs)

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.1919.799−63.353
Source linesThe number of non-empty source lines.74+29.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.723−7.085

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

Feature contributions

FeatureValueContribution
(log-odds)
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.129.96−1.839
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.75−1.619
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.129.987+1.293
Indentation frequencyHow rapidly indentation changes from line to line.52+1.061
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.73.847+0.622
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.041+0.548
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398

Intercept 0.07 + feature contributions = 0.534 (log-odds).
Score = sigmoid(0.534) = 0.63.

Score0.052
Score36
Run 1

The code suffers from severe readability issues. The `__init__` method is over 20 lines long with a complex assert statement that combines multiple conditions, making the logic difficult to follow. String concatenation and f-strings are broken across multiple lines in confusing ways, with odd indentation (e.g., `f"/{app_root.lstrip('/')}"` followed by `)` on the same line). Nested conditionals and the boolean assertion create a tangled flow. While the docstring is somewhat helpful, the implementation lacks clear separation of concerns — argument validation, URL construction, and super() call are all mixed together. Action granularity is poor, with multiple operations crammed into single lines. The reading flow is interrupted by awkward line breaks and alignment issues. Some positives exist: type hints are used, imports are clean, and the method has a clear purpose. However, the overall execution makes the code difficult to scan and understand at a glance.

Run 2

The code is moderately readable. The class docstring is clear and helpful, and the overall structure makes sense. However, several issues reduce readability: the `__init__` signature has odd spacing and alignment, making parameter scanning difficult. The `assert` statement is logically dense and confusing, requiring careful parsing to understand the condition. Some lines contain multiple actions or long expressions (base_url construction), but they are not overly complex. The import block is slightly disorganized, mixing standard library, third-party, and local imports without clear grouping. Nesting is acceptable, but the assert condition is difficult to follow. Intent is mostly clear except for that assertion. Code length is reasonable, but the formatting is inconsistent. Overall, it is readable but with noticeable friction in key areas.

Run 3

The code suffers from serious readability issues. Imports are cluttered and unorganized with multiple multiline breaks, but the main problem is inconsistent formatting and alignment. The __init__ method signature is sprawling with bizarre spacing around parameters (e.g., 'app: Flask,' vs 'path: str = "/",' vs 'subdomain: str | None = None,'). The assert statement mixes complex boolean logic with string formatting in a single line that is nearly impossible to parse, violating action granularity. The 'base_url' construction has broken string concatenation across lines with odd indentation, making the URL assembly very hard to follow. Some comments and docstrings are detailed (positive), but the actual code layout negates that clarity. There is moderate nesting (two if-blocks), acceptable, but the line length and alignment make even simple logic look tangled. The class body itself is short, but the implementation style is unnecessarily confusing. While intent is partially clear from docstrings, the structural formatting is inconsistent enough to impact comprehension significantly. Score: 8/20.

Run 1

Code Structure: Imports, a focused class, and two methods provide logical organization, but missing blank lines weaken visual separation. Nesting: Control flow is shallow, with straightforward conditionals inside one main branch. Clarity of intent: Descriptive names, type annotations, and detailed docstrings explain environment construction and JSON serialization; the compound assertion is harder to interpret. Code length: Implementation is reasonably concise, although documentation occupies much of the snippet. Action granularity: Most statements perform one action, but multiple parameters crowded onto single lines and adjacent f-strings with excessive spacing impede scanning. Reading flow: Initialization proceeds naturally from defaults to URL parsing and superclass initialization, but inconsistent whitespace and compressed formatting interrupt that flow.

Run 2

Code Structure: The class logically separates environment initialization from JSON serialization, but unused imports and cramped spacing add clutter. Nesting: Control flow remains shallow, with straightforward conditionals inside one main branch. Clarity of intent: Descriptive names, type annotations, and documentation clearly explain the purpose, although the compound assertion is difficult to parse and Flask is not imported in the snippet. Code length: The implementation is reasonably concise; the lengthy docstring provides useful context, while unnecessary imports reduce focus. Action granularity: Most statements perform one action per line, but multiple parameters share lines and the adjacent URL-building strings are awkwardly compressed. Reading flow: Initialization proceeds naturally from defaults to URL construction to superclass initialization, but inconsistent whitespace and missing separation around imports, class declarations, and methods interrupt scanning.

Run 3

Code Structure: The class logically separates environment initialization from JSON serialization, but numerous unused imports and cramped spacing reduce organization. Nesting: Control flow is shallow, with only a few nested conditionals. Clarity of intent: Descriptive names, type annotations, and docstrings explain the purpose well; however, the compound assertion is difficult to parse, and Flask is not imported in the excerpt. Code length: The implementation is reasonably concise, although imports and documentation dominate this small example. Action granularity: Most statements perform one action, but multiple parameters and adjacent string expressions crowded onto single lines hinder scanning. Reading flow: Initialization progresses naturally from configuration defaults to URL construction and superclass initialization, but inconsistent whitespace and missing separation between imports, class, and methods interrupt readability.