Sample

pyint-2ce58e6823cd-I01

Remove comments and docstrings

Matched original source

Lines19

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.4820–1; higher is more readable
Mi0.2650–1; higher is more readable
LLOC14Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.5810–1; higher is more readable

Views

Source code

from __future__ import annotations from typing import TYPE_CHECKING, Any from urllib3.exceptions import HTTPError as BaseHTTPError from .compat import JSONDecodeError as CompatJSONDecodeError class RequestException(IOError): response: Response | None request: Request | PreparedRequest | None def __init__(self, *args: Any, **kwargs: Any) -> None: response: Response | None = kwargs.pop("response", None) self.response = response self.request = kwargs.pop("request", None) if response is not None and not self.request and hasattr(response, "request"): self.request = response.request super().__init__(*args, **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.720.46−23.775
Source linesThe number of non-empty source lines.19+7.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.658−6.988

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.20+0.328
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.18.759−0.148
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.082+0.142
Indentation frequencyHow rapidly indentation changes from line to line.19−0.08
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.86+0.023

Intercept 0.07 + feature contributions = -0.071 (log-odds).
Score = sigmoid(-0.071) = 0.482.

Score0.265
Score14
Run 1

The code is generally clear and well-structured, with a logical class definition and type hints that improve readability. The constructor is concise and handles response/request assignment appropriately. However, there is a minor inconsistency: an unnecessary blank line after the class definition and the use of `response: Response | None` as a local variable shadowing the class attribute annotation could cause slight confusion. The conditional check and attribute assignment are somewhat compact but still follow one action per line. The import order and use of `__future__` annotations are good practices. Overall, the code is readable but could be slightly improved by removing the stray blank line and clarifying the local variable usage.

Run 2

The code is highly readable. It has a clear, logical structure with minimal nesting and a straightforward exception class definition. Type annotations and the use of `from __future__ import annotations` improve clarity for modern Python. The `__init__` method is concise, with one logical action per line: popping the response, assigning it, popping the request, and conditionally inferring the request from the response. The reading flow is natural — setup, member assignment, fallback logic, then super().__init__. Although the blank class body and minor whitespace anomalies (extra lines after the class definition) slightly detract, the overall intent, organization, and use of type hints make it very easy to follow. The code avoids unnecessary complexity and keeps responsibilities clear.

Run 3

The code is moderately readable but has some issues. Structure is logical but incomplete (missing necessary imports for Response, Request, PreparedRequest types). Nesting is flat, which is good. Intent is clear - defining a request exception class - but the implementation feels unfinished without proper type imports. Code length is concise and appropriate. Action granularity is generally one action per line, though the conditional on lines 15-16 contains multiple logical operations. Reading flow is natural with initialization parameters flowing to super(). The blank line after class definition and docstring absence slightly reduce clarity. Type annotations are present but TYPE_CHECKING import suggests incomplete typing setup. Overall, the code is understandable but would benefit from complete imports and a class docstring.

Run 1

Code Structure: Imports, class attributes, and initialization are logically organized, though TYPE_CHECKING and the exception aliases are unused in this snippet. Nesting: A single conditional keeps nesting shallow. Clarity of intent: The constructor clearly stores response and request context, deriving the request from the response when needed; however, Response, Request, and PreparedRequest are not defined or imported here, and no docstring explains the exception's purpose. Code length: The implementation is concise, with only some unnecessary blank lines. Action granularity: Each statement performs one clear action. Reading flow: Initialization proceeds naturally from extracting arguments to setting attributes, applying a fallback, and initializing the superclass.

Run 2

Code Structure: Imports, class attributes, and initialization are logically organized, though TYPE_CHECKING and the exception aliases are unused in this snippet. Nesting: Only one conditional keeps the code shallow and easy to follow. Clarity of intent: Descriptive names and type annotations clearly convey an exception carrying response and request metadata; however, Response, Request, and PreparedRequest are not defined or imported here, and the truthiness check for self.request is less explicit than checking for None. Code length: The implementation is concise, but excessive blank lines add visual noise. Action granularity: Each statement performs a single clear action, while the compound condition remains manageable. Reading flow: Initialization proceeds naturally from extracting metadata to inferring the request and initializing the parent exception.

Run 3

Code Structure: Imports, class attributes, and initialization are logically organized. Nesting: Only one shallow conditional keeps complexity low. Clarity of intent: Descriptive names and type annotations clearly communicate exception initialization and request inference, although absent documentation and externally defined annotation types leave some context implicit. Code length: The implementation is concise, but unused imports and excess blank lines add clutter. Action granularity: Each statement performs a focused action; the compound conditional is manageable. Reading flow: Initialization proceeds naturally from extracting the response to assigning the request, applying a fallback, and initializing the parent exception.