Sample

pyint-90e41ea55cce-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines21

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.810–1; higher is more readable
Mi0.2160–1; higher is more readable
LLOC16Logical lines; fewer is more readable
DeepSeek V4 Pro16.330–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.6210–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, *arg: Any, **kwa: Any) -> None: """Initialize RequestException with `request` and `response` objects.""" res: Response | None = kwa.pop("response", None) self.response = res self.request = kwa.pop("request", None) if res is not None and not self.request and hasattr(res, "request"): self.request = res.request super().__init__(*arg, **kwa)

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.743.088−24.522
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.74−7.111

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

Feature contributions

FeatureValueContribution
(log-odds)
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.72.864+0.371
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.80+0.277
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.068+0.276
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.815−0.119
Indentation frequencyHow rapidly indentation changes from line to line.19−0.08

Intercept 0.07 + feature contributions = 1.451 (log-odds).
Score = sigmoid(1.451) = 0.81.

Score0.216
Score16
Run 1

The code is well-structured and readable. It has a clear class definition with a focused purpose. Nesting is minimal, with only one conditional block. Intent is explicit through the docstrings and type hints. Code length is concise and appropriate, avoiding unnecessary verbosity. Each line performs a single clear action, particularly evident in the __init__ method's step-by-step processing. The reading flow is natural—arguments are extracted, the response/request relationship is established, and then the parent initializer is called. Type hints and the use of kwa.pop('response', None) and kwa.pop('request', None) make the data flow transparent. Minor deductions could come from slightly dense conditional on the request/response relationship and reliance on an undefined Response/Request type at the global scope (assuming they are imported elsewhere via TYPE_CHECKING), but this doesn't significantly hinder comprehension. Overall, this is clean, maintainable code.

Run 2

The code demonstrates solid readability through clear structure and intent. The class is logically organized with relevant type hints and succinct documentation. Nesting is minimal, with only one conditional during initialization. Action granularity is good, with mostly one action per line. The reading flow is natural, moving from attribute declarations to initialization logic. The conditional line `if res is not None and not self.request and hasattr(res, 'request')` is slightly long but still readable. The `response` and `request` attributes use modern Python 3.10+ union type syntax without importing Optional, which is clear if the project supports it. The import of JSONDecodeError as CompatJSONDecodeError is not used in this snippet, which slightly violates conciseness and clarity, as unused imports can confuse readers. Overall, the code is concise and well-designed.

Run 3

The code is generally readable with a clear class definition and sensible docstrings. It has a flat structure with minimal nesting, and each action is on its own line. Type hints improve clarity. However, it loses points for vague parameter names (*arg, **kwa) and slightly cryptic logic around populating the request from the response. The conditional checking for request and response is compact but could be clearer with an intermediate variable. Overall, the code is concise and well-organized, but the ambiguous naming and condensed conditional slightly reduce readability.

Run 1

Code Structure: Imports, class documentation, attribute annotations, and initialization are logically organized, though TYPE_CHECKING and exception aliases are unused in this snippet. Nesting: A single conditional keeps nesting shallow. Clarity of intent: The constructor clearly captures request and response objects and derives the request from the response when needed; abbreviated names such as arg, kwa, and res slightly reduce clarity. Code length: Compact without unnecessary implementation detail. Action granularity: Each statement performs one primary action. Reading flow: Initialization progresses naturally from extracting arguments to setting attributes, applying a fallback, and initializing the superclass. Minor weaknesses include the vague class docstring, limited spacing around top-level definitions, and type names whose definitions or imports are not shown.

Run 2

Code Structure: Imports, class documentation, annotations, and initialization are logically organized, though several imports are unused in this snippet. Nesting: A single conditional keeps nesting shallow. Clarity of intent: The initializer clearly associates request and response objects with an exception, but abbreviated names such as arg, kwa, and res reduce clarity; the class docstring is also vague. Code length: Compact and appropriately sized, with little unnecessary code. Action granularity: Each line performs one primary action, making assignments and initialization easy to follow. Reading flow: The sequence from extracting the response to deriving the request and initializing the superclass is natural. Additional spacing between imports and the class would improve visual separation.

Run 3

Code Structure: Imports, class documentation, type annotations, and initialization are logically organized, though several imports are unused in this snippet. Nesting: A single conditional keeps nesting shallow. Clarity of intent: The initializer clearly stores request and response objects and derives a request from the response when needed. However, abbreviated names such as arg, kwa, and res reduce clarity, and the class docstring is vague. Code length: The implementation is concise without unnecessary complexity. Action granularity: Each line performs one primary action, making state changes easy to follow. Reading flow: Initialization proceeds naturally from extracting the response to assigning the request, applying a fallback, and initializing the superclass. Additional spacing between imports and the class would improve visual separation.