Sample

pyint-f7df5b81b056-I13

Lower every eligible synchronous for loop to a while loop

Matched original source

Lines27

Scores

MethodScoreScale
Posnett0.0070–1; higher is more readable
Dorn0.8460–1; higher is more readable
Mi0.4010–1; higher is more readable
LLOC13Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.7270–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 JSONDecodeError(InvalidJSONError, CompatJSONDecodeError): """Couldn't decode the text into json""" def __init__(self, *args: Any, **kwargs: Any) -> None: """ Construct the JSONDecodeError instance first with all args. Then use it's args to construct the IOError so that the json specific args aren't used as IOError specific args and the error message from JSONDecodeError is preserved. """ CompatJSONDecodeError.__init__(self, *args) InvalidJSONError.__init__(self, *self.args, **kwargs) def __reduce__(self) -> tuple[Any, ...] | str: """ The __reduce__ method called when pickling the object must be the one from the JSONDecodeError (be it json/simplejson) as it expects all the arguments for instantiation, not just one like the IOError, and the MRO would by default call the __reduce__ method from the IOError due to the inheritance order. """ return CompatJSONDecodeError.__reduce__(self)

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.533.839−17.617
Source linesThe number of non-empty source lines.27+10.8
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.69−7.034

Intercept 8.87 + feature contributions = -4.981 (log-odds).
Score = sigmoid(-4.981) = 0.007.

Feature contributions

FeatureValueContribution
(log-odds)
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.71.964+0.617
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.039+0.559
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.61.857+0.194
Indentation frequencyHow rapidly indentation changes from line to line.16−0.184
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.26.849−0.035

Intercept 0.07 + feature contributions = 1.7 (log-odds).
Score = sigmoid(1.7) = 0.846.

Score0.401
Score13
Run 1

The code is well-structured with clear class definition, logical MRO handling, and explicit intent through docstrings. It maintains flat nesting, concise methods, and one action per line. Minor readability trade-offs include slightly complex inheritance (necessary for the use case) and somewhat dense docstrings, but overall it is highly readable and maintainable.

Run 2

The code is well-structured and readable. It clearly defines a custom exception class with logical inheritance, and the docstrings explain the non-obvious reasoning behind the constructor and __reduce__ method, which significantly improves clarity of intent. Nesting is minimal, action granularity is appropriate, and the code is concise without being overly terse. The reading flow is natural, moving from imports to class definition and then methods. Minor points deducted for the slight complexity of multiple inheritance and the somewhat dense docstring text, but overall the code is easy to follow and understand.

Run 3

The code is well-structured with clear class hierarchy and purpose. Each method has a single responsibility and is documented with docstrings explaining non-obvious behavior. Nesting is flat, and the reading flow is natural—init, then reduce. The explicit MRO-related comments and deliberate call ordering show clarity of intent. Line length and action granularity are reasonable, with one logical operation per line. Minor deductions: the long docstring explanation in __init__ is slightly verbose for a relatively simple constructor, and the __reduce__ return type annotation (`tuple[Any, ...] | str`) is unusual. Overall, highly readable with only marginal verbosity in documentation.

Run 1

Code Structure: A focused class with logically separated initialization and pickling methods; unused imports and the undefined-in-snippet InvalidJSONError reduce self-containment. Nesting: Flat methods with no nested control flow make scanning easy. Clarity of intent: Descriptive names and docstrings explain the subtle multiple-inheritance behavior, though understanding it requires familiarity with exception arguments, MRO, and pickling. Code length: Implementation is concise; explanatory docstrings are useful but slightly verbose and contain minor wording errors. Action granularity: Each executable line performs one clear action. Reading flow: Imports, class declaration, constructor, and serialization method follow a natural sequence, with explicit base-class calls making execution order easy to trace.

Run 2

Code Structure: A focused exception class cleanly separates initialization from pickling behavior, though InvalidJSONError is not defined or imported in the snippet and two imports are unused. Nesting: Minimal nesting makes both methods easy to scan. Clarity of intent: Descriptive names, type annotations, and docstrings explain the otherwise subtle multiple-inheritance behavior; minor grammatical issues reduce polish. Code length: Implementation is concise, although documentation is comparatively lengthy. Action granularity: Each statement performs one clear action. Reading flow: Imports, class declaration, constructor, and serialization method follow a natural order, but understanding the inheritance details requires familiarity with exception initialization and Python's method resolution order.

Run 3

Code Structure: Imports and a focused exception class are logically organized, though InvalidJSONError is not defined or imported in the snippet and two imports are unused. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: Type annotations and docstrings clearly explain initialization order and pickling behavior, although understanding multiple inheritance and MRO requires some expertise. Code length: Implementation is concise; the explanatory docstrings are somewhat verbose but justify non-obvious behavior. Action granularity: Each statement performs one clear action. Reading flow: Initialization followed by serialization support creates a natural progression, with explicit parent calls making the execution order apparent.