Sample

pyint-ef3feb38ab65-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines23

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7860–1; higher is more readable
Mi0.190–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro13.330–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.6180–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 not (response is not None and not self.request and hasattr(response, "request")): pass else: 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.780.96−25.772
Source linesThe number of non-empty source lines.23+9.2
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.676−7.013

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.91.958+0.679
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.066+0.299
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.92−0.232
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.24+0.187
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.22.753−0.092
Indentation frequencyHow rapidly indentation changes from line to line.21−0.011

Intercept 0.07 + feature contributions = 1.299 (log-odds).
Score = sigmoid(1.299) = 0.786.

Score0.19
Score17
Run 1

The code has clear type annotations and class-level attributes, but several issues reduce readability. The if/else condition is unnecessarily complex and lacks clarity - 'if not (response is not None and not self.request and hasattr(response, 'request'))' is convoluted. The empty 'pass' branch followed by 'else' is an anti-pattern that could be simplified to a positive if-statement. The exception hierarchy is clear, and the docstring is helpful, but the conditional logic obscures the intent. The code is relatively flat and concise, but the action granularity suffers from the compressed conditional expression. Overall structure is logical with good typing, but the conditional could be replaced with 'if response and not self.request and hasattr(response, 'request'): self.request = response.request' for better readability.

Run 2

The code is understandable but has readability issues. Structure is logical with clear class definition and type hints. However, the conditional logic in __init__ is convoluted: the condition 'not (response is not None and not self.request and hasattr(response, "request"))' with pass/else branches inverts the natural reading order - the meaningful action happens in the else block. This creates unnecessary nesting depth and obscures intent. The logic could be flattened by checking the positive condition directly (if response and not self.request and hasattr(response, 'request'): self.request = response.request). Action granularity is mostly one action per line, but the multi-part condition violates this. Reading flow is disrupted by the inverted condition. Length is acceptable, docstrings are helpful. Overall, the code works but the conditional structure needs simplification for better clarity.

Run 3

The code is generally readable with clear class naming, type hints, and docstrings. The __init__ method has concerning logic: a conditional with a pass statement and an else block that reverses the natural reading order — this creates unnecessary cognitive load. The condition itself (`response is not None and not self.request and hasattr(response, 'request')`) is complex but named variables would help. Action granularity is mostly one-per-line, and structure is logical. The nesting is shallow, which is good, but the if/else with pass could simply be inverted: `if response and not self.request and hasattr(...): self.request = response.request`. This would flatten the logic and improve flow. Overall the code is clean and maintainable, with the main issue being the awkward conditional structure.

Run 1

Code Structure: Imports, class attributes, and initialization are logically organized, though TYPE_CHECKING and exception aliases are unused in this snippet. Nesting: Shallow, but the negated conditional with an empty pass branch adds needless complexity. Clarity of intent: Descriptive names, type annotations, and the initializer docstring clarify exception setup; the class docstring is vague, and Request, PreparedRequest, and Response are not defined or imported here. Code length: Mostly concise, but the pass/else construct could be replaced with a direct positive condition. Action granularity: Each statement performs a distinct action, making assignments and initialization easy to track. Reading flow: Generally natural, progressing from response extraction to request assignment and superclass initialization, but the inverted conditional interrupts that flow.

Run 2

Code Structure: Imports, class attributes, and initialization are logically organized, though unused imports add clutter. Nesting: Shallow overall, but the negated condition with an empty pass branch creates unnecessary control flow. Clarity of intent: Type annotations and the initializer docstring clarify the stored objects; the compound negative condition and vague class docstring reduce clarity. Code length: Mostly concise, but a direct positive conditional would eliminate the pass and else lines. Action granularity: Each statement performs one clear action, with no packed statements. Reading flow: Initialization proceeds naturally from extracting arguments to setting attributes and calling the superclass, but the inverted conditional interrupts that flow.

Run 3

Code Structure: Imports, exception class, annotations, and initializer are logically organized. Nesting: Shallow, but the empty if branch and else introduce unnecessary branching. Clarity of intent: The initializer docstring and descriptive names clarify the purpose, while the negated compound condition makes request inference harder to understand. Code length: Mostly concise, though the pass branch, unused imports, and redundant local annotation add clutter. Action granularity: Each statement performs one clear action. Reading flow: Initialization proceeds naturally from extracting arguments to setting attributes and invoking the superclass, but the inverted conditional interrupts that flow; a direct positive condition would be easier to read.