Sample

pyint-c56fd7e49e6f-I01

Remove comments and docstrings

Matched original source

Lines61

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7660–1; higher is more readable
Mi0.3180–1; higher is more readable
LLOC34Logical lines; fewer is more readable
DeepSeek V4 Pro14.670–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.4330–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): 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: 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.1897.39−62.614
Source linesThe number of non-empty source lines.61+24.4
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.582−6.873

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.61+1.373
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.62−1.159
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
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.72.919+0.577
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.60.878+0.441
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.067+0.288

Intercept 0.07 + feature contributions = 1.183 (log-odds).
Score = sigmoid(1.183) = 0.766.

Score0.318
Score34
Run 1

The code is generally readable with clear structure and intent. The class has a single responsibility (building test environ), methods are logically organized, and the type hints improve clarity. The constructor handles URL construction in a sequential manner with good line breaks. However, the complex boolean assertion at the start is difficult to parse at first glance — it mixes logical operators and parentheses in a way that obscures intent. The conditional branching for base_url logic, while not deeply nested, contains dense string formatting that requires careful reading. Action granularity is mostly good, with each logical step on its own line. The assert condition and base_url construction are the main readability hurdles. Overall, the code benefits from clear naming, type annotations, and proper use of modern Python features, but the assertion logic and dense conditional could benefit from extraction or intermediate variables.

Run 2

The code is generally readable but has some issues. The `__init__` method starts with a complex logical assertion combining multiple conditions with `and`/`or` and a comparison to `bool()`, making intent unclear at first glance. The `if base_url is None:` block then handles URL construction with moderate nesting, but the logic is somewhat tangled: variables like `app_root`, `http_host`, and `url_scheme` are mutated and reassigned in ways that require close reading. The `json_dumps` method is trivial and clear. Naming and imports are appropriate, and the class structure is logical. However, the assertion and URL-building logic could be simplified or broken into smaller, well-named helper methods to improve clarity and reduce cognitive load.

Run 3

The code is moderately readable but has notable issues. Structure is logical, with clear class and method organization, and imports are grouped well. However, the constructor contains a deeply nested conditional block with complex boolean logic in the assertion and multiple conditional branches that obscure intent. The base_url construction string concatenation is dense and hard to parse at a glance. Action granularity is mixed: some lines combine multiple operations (e.g., f-string with conditional expressions, assertion with multi-line boolean expression), while others are appropriately single-purpose. Reading flow is disrupted by the assertion complexity and the absence of explanatory comments for non-obvious logic. Positive aspects include type hints, descriptive parameter names, and reasonable use of blank lines. Overall, the code is functional but would benefit from simplifying the conditional logic, extracting the base_url construction into a helper method, and clarifying the assertion condition with intermediate variables or comments.

Run 1

Code Structure: Imports, a focused class, and two methods provide logical organization. Nesting: Mostly shallow, with a few manageable conditionals inside base URL construction. Clarity of intent: Descriptive names and type annotations make URL configuration and JSON serialization understandable, but the compound assertion is difficult to parse and lacks explanatory context. Code length: Concise overall, with little unnecessary logic, though empty whitespace adds visual noise. Action granularity: Statements generally perform one action per line; the assertion compresses several checks into one expression. Reading flow: Initialization proceeds naturally from validation through URL construction to superclass initialization. Minor distractions include inconsistent import grouping and the unexplained Flask type reference.

Run 2

Code Structure: Imports and a focused class organize URL construction and JSON serialization logically. Nesting: Conditional nesting is moderate and manageable, though most initialization occurs inside one outer branch. Clarity of intent: Descriptive names and type annotations clarify behavior, but the compound assertion is difficult to parse, and missing documentation leaves URL precedence rules implicit. Code length: The implementation is concise without substantial duplication; stray blank lines add minor clutter. Action granularity: Most lines perform one action, with sensible multiline formatting for signatures and expressions. Reading flow: Initialization progresses naturally from validation to configuration, URL assembly, and superclass initialization. The dense assertion and the unexplained Flask annotation slightly interrupt comprehension.

Run 3

Code Structure: Imports and methods are logically organized, with initialization separated from JSON serialization. Nesting: Mostly shallow, although base URL construction contains several nested conditionals. Clarity of intent: Descriptive names and type annotations explain URL configuration well, but the compound assertion is difficult to parse and lacks explanatory documentation. Code length: Concise overall, with little redundant logic; stray blank lines add minor clutter. Action granularity: Most lines perform one operation, while the assertion combines multiple validation conditions. Reading flow: Configuration lookup, URL parsing, path adjustment, and superclass initialization follow a natural sequence. Readability would improve with a simpler validation expression and a brief explanation of URL precedence.