Sample

pyint-bf9d2692ae36-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines21

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7990–1; higher is more readable
Mi0.2040–1; higher is more readable
LLOC16Logical lines; fewer is more readable
DeepSeek V4 Pro16.330–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.6240–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.""" 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.739.345−24.398
Source linesThe number of non-empty source lines.21+8.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.726−7.09

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.82.227+0.522
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.065+0.307
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.22+0.257
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.20.805−0.119
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 = 1.378 (log-odds).
Score = sigmoid(1.378) = 0.799.

Score0.204
Score16
Run 1

The code is highly readable with clear structure and purpose. It follows standard Python conventions with proper imports, type hints, and docstrings. The class hierarchy is logical (inherits from IOError), and the constructor clearly handles optional 'response' and 'request' parameters. Nesting is minimal (one conditional block), and the conditional logic is straightforward. Each action is on its own line, maintaining good granularity. The reading flow is natural - from argument parsing to attribute assignment to fallback logic. Minor deductions: the conditional could be slightly more explicit with parentheses for clarity, and the attribute annotations could use a comment explaining the None default. Otherwise, the code is concise, well-organized, and easy to follow.

Run 2

The code demonstrates good readability with clear structure and purpose. The class definition is straightforward, with a docstring explaining the exception's purpose. Type hints are used appropriately (TYPE_CHECKING, Any, Response, PreparedRequest), enhancing clarity. The __init__ method is concise, with each action on separate lines, making it easy to follow. The nesting is minimal—only one conditional with a compound condition, which slightly increases cognitive load but remains understandable. The logic of extracting 'response' and 'request' from kwargs, then setting self.request from response.request if needed, is clear. The imports are organized, though TYPE_CHECKING is imported but not used in visible code, which could be cleaned up. Overall, the code follows good practices but could benefit from minor refinements like breaking the compound condition into separate checks or adding comments for non-obvious logic.

Run 3

The code is highly readable. It has a clear, logical structure with a single, well-defined class. Nesting is minimal—only a single conditional block inside __init__, which is flat and easy to follow. Intent is explicitly stated in the docstring and type annotations, making the purpose unambiguous. The code is concise, avoiding unnecessary verbosity while including meaningful comments. Each line performs a single logical action, enhancing granularity. The reading flow is natural: imports, class definition, attributes, then a straightforward initializer that progressively handles arguments and fallback logic. Minor deductions are for the conditional block that contains two related actions (setting self.request and super().__init__) on separate lines but could be slightly more explicit about why the fallback exists, and the use of *args/**kwargs slightly reduces immediate signature clarity compared to explicit parameters.

Run 1

Code Structure: Imports, class documentation, attribute annotations, and initialization are logically organized, although several imports are unused in this snippet. Nesting: A single conditional keeps nesting shallow. Clarity of intent: Descriptive names and the initializer docstring clearly convey how request and response context are attached; the class docstring is vague, and referenced types are not defined or imported here. Code length: Compact, with no unnecessary implementation complexity. Action granularity: Each statement performs one main action; the compound condition remains understandable. Reading flow: Initialization progresses naturally from extracting context to inferring the request and calling the superclass, with conventional formatting.

Run 2

Code Structure: Imports, class documentation, annotations, and initialization are logically organized. Nesting: A single conditional keeps the implementation flat and easy to follow. Clarity of intent: Descriptive names and the initializer docstring clearly explain how request and response information is stored, although the class docstring is vague and referenced types are not defined or imported in this snippet. Code length: The implementation is concise, but several imports are unused here. Action granularity: Each statement performs one primary action; the compound conditional remains readable. Reading flow: Initialization proceeds naturally from extracting the response to assigning attributes, inferring a request, and initializing the superclass. Additional spacing between imports and the class would improve visual separation.

Run 3

Code Structure: Imports, class documentation, attribute annotations, and initialization are logically organized. Nesting: Only one conditional keeps the implementation flat and easy to follow. Clarity of intent: Descriptive names, type hints, and the initializer docstring clarify how request and response are stored; the class docstring is somewhat vague. Code length: The implementation is concise, although several imports are unused in this snippet. Action granularity: Each statement performs a single clear action. Reading flow: Initialization proceeds naturally from extracting response, to assigning attributes, to inferring a request, and finally initializing the parent class. Minor readability limitations include Response, Request, and PreparedRequest not being defined or imported in the snippet, and a compound conditional that takes slightly more effort to parse.