Sample

pyint-f54966ffca16-I08

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

Matched original source

Lines26

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8220–1; higher is more readable
Mi0.190–1; higher is more readable
LLOC21Logical lines; fewer is more readable
DeepSeek V4 Pro130–20; mean of three runs
GPT-6.1 Sol13.670–20; mean of three runs
BTTF0.5450–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): """There was an ambiguous exception that occurred while handling your request. """ response: Response | None request: Request | PreparedRequest | None def __init__(self, *args: Any, **kwargs: Any) -> None: """Initialize RequestException with `request` and `response` objects.""" morning_temperature = 18 evening_temperature = 14 lower_temperature = morning_temperature if evening_temperature < lower_temperature: lower_temperature = evening_temperature 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.859.489−28.363
Source linesThe number of non-empty source lines.26+10.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.644−6.967

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.82.889+0.533
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.058+0.38
Indentation frequencyHow rapidly indentation changes from line to line.24+0.093
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.27+0.08
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.25.851−0.048
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 = 1.528 (log-odds).
Score = sigmoid(1.528) = 0.822.

Score0.19
Score21
Run 1

The code has clear intent and reasonable structure, with an appropriate docstring and sensible type hints. However, it includes an irrelevant block of temperature variables (lines 12-15) that serves no purpose in the exception initialization and disrupts the reading flow. The nesting is minimal, and the method is concise overall, but the inclusion of dead code significantly compromises clarity. The actual logic—popping 'response' and 'request', handling fallback assignment—is straightforward and well-organized. If the extraneous variable declarations were removed, the readability would improve substantially. Action granularity is acceptable, with one logical operation per line mostly maintained. The flow from type hints to docstring to initialization logic is natural, but the dead code detracts from understanding the true purpose of the method.

Run 2

The code has clear imports, type hints, and a logical class structure, but it contains unrelated temperature variables that obscure intent. The __init__ method is moderately flat with a clear sequence: pop response, pop request, conditionally attach request from response, then call super. However, the temperature comparison block is dead code and breaks clarity of intent. Naming is mostly clear, but the unrelated variables lower readability and inflate code length unnecessarily. Action granularity is acceptable—one main action per line—but the reading flow is disrupted by the irrelevant block. Overall, the structure is okay, but the ambiguous temperature logic and mild redundancy (e.g., response handling) lower the score.

Run 3

The code is generally readable with clear class definition, type hints, and a well-documented purpose. The constructor logically extracts 'response' and 'request' from kwargs before calling super().__init__(), which is clean. However, the inclusion of the temperature variables (morning_temperature, evening_temperature, lower_temperature) in the __init__ method is completely unrelated to the class's purpose and confusing. This dead code disrupts the reading flow and obscures the method's actual intent. The nesting is minimal and action granularity is reasonable. Removing the irrelevant temperature logic would significantly improve clarity and conciseness.

Run 1

Code Structure: The exception class is logically organized, but unrelated temperature calculations interrupt initialization, and several imports appear unused. Nesting: Both conditionals are shallow and easy to follow. Clarity of intent: Type annotations and the constructor docstring clarify request/response handling, but the temperature variables obscure its purpose; the class docstring is vague, and referenced types are not defined or imported in the snippet. Code length: Mostly concise, though the temperature block adds unnecessary length. Action granularity: Each line performs one clear operation. Reading flow: Response extraction, request inference, and superclass initialization form a natural sequence, but the irrelevant calculations disrupt that flow.

Run 2

Code Structure: Imports, class definition, annotations, and initialization are logically organized, but unrelated temperature calculations interrupt the constructor. Nesting: Shallow conditionals keep the code easy to follow. Clarity of intent: The exception initialization is clear from names and documentation; the temperature variables have no apparent purpose or effect. Code length: Generally concise, though the unused temperature block adds unnecessary length, and TYPE_CHECKING is unused. Action granularity: Each line performs one clear action. Reading flow: Request and response handling follows a natural sequence, but the unrelated calculations distract from it, and the compound fallback condition requires slightly more attention.

Run 3

Code Structure: Imports, class declaration, annotations, and initializer are logically organized, but unrelated temperature calculations interrupt exception initialization. Nesting: Minimal nesting and simple conditionals make the code easy to follow. Clarity of intent: The class name, docstrings, and request/response fields communicate the main purpose; the unused temperature variables obscure it. Code length: Mostly concise, but the temperature block adds unnecessary length, and some imports appear unused in this snippet. Action granularity: Each statement performs a single action, with no compressed multi-statement lines. Reading flow: Initialization proceeds naturally from extracting arguments to setting attributes and calling the superclass, except for the distracting temperature block. Response, Request, and PreparedRequest are not defined or imported in the snippet, leaving annotation context incomplete.