Sample

pyint-c6afe0507d92-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines31

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.850–1; higher is more readable
Mi0.6550–1; higher is more readable
LLOC20Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol16.670–20; mean of three runs
BTTF0.7530–1; higher is more readable

Views

Source code

from __future__ import annotations import calendar import copy import time from collections.abc import Iterator, MutableMapping from http.cookiejar import Cookie, CookieJar, CookiePolicy from typing import TYPE_CHECKING, Any, TypeVar, overload from ._internal_utils import to_native_string from ._types import is_prepared as _is_prepared from .compat import Morsel, cookielib, urlparse, urlunparse import threading class MockResponse: """Wraps a `httplib.HTTPMessage` to mimic a `urllib.addinfourl`. ...what? Basically, expose the parsed HTTP headers from the server response the way `http.cookiejar` expects to see them. """ def __init__(self, headers: Any) -> None: """Make a MockResponse for `cookiejar` to read. :param headers: a httplib.HTTPMessage or analogous carrying the headers """ self._headers = headers def info(self) -> Any: return self._headers def getheaders(self, name: str) -> Any: self._headers.getheaders(name)

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.676.419−22.322
Source linesThe number of non-empty source lines.31+12.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.7−7.049

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

Feature contributions

FeatureValueContribution
(log-odds)
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.041+0.539
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.74.219+0.393
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.78.938+0.322
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.32−0.097
Indentation frequencyHow rapidly indentation changes from line to line.24+0.093
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.30.738+0.02

Intercept 0.07 + feature contributions = 1.738 (log-odds).
Score = sigmoid(1.738) = 0.85.

Score0.655
Score20
Run 1

The code is well-structured, with clear imports and a focused class definition. Nesting is minimal, and the class and method responsibilities are unambiguous. The docstrings are helpful and explain non-obvious behavior, improving clarity. The code is concise, with no unnecessary length or repetition. Action granularity is appropriate—each line performs a single logical step. Reading flow is natural, from imports to class definition and methods. Minor issues include a missing return statement in `getheaders`, which could reduce clarity, and the slightly informal tone in the docstring ('...what?'), but these do not significantly harm readability. Overall, this is highly readable code.

Run 2

The code is well-structured and readable. It has a clear purpose, encapsulated in a single class with a focused responsibility. The nesting is minimal and logic is flat. The use of type hints and future annotations improves clarity. The docstrings explain the unusual behavior of the MockResponse class, which aids intent. Each method is short and does one thing, and the code avoids unnecessary length. The only minor deductions are due to the slightly vague 'Any' typing and an unused method (getheaders has no return statement), which slightly obscures precision, but overall the code is clean, concise, and easy to follow.

Run 3

The code is generally clear and well-structured. The single class 'MockResponse' has a clear purpose and is logically organized with its components (constructor, info, getheaders). The nesting level is flat with only one level of indentation in methods. There is one action per line, which is good for readability. However, the 'getheaders' method has a critical issue: it calls `self._headers.getheaders(name)` but fails to return the result. This creates ambiguity in intent and breaks the method's purpose, as the caller would never receive the headers. Apart from this bug, the reading flow is natural and the code length is concise. The docstrings are helpful, but the confusing pattern in the class docstring could be clearer. Overall, the code is readable but the missing return statement prevents a higher score.

Run 1

Code Structure: The small wrapper class is logically organized, although numerous unused imports and the misplaced threading import clutter this excerpt. Nesting: Methods are flat, with no nested control flow. Clarity of intent: The class and constructor docstrings explain the compatibility purpose, and names are descriptive; however, getheaders calls the underlying method without returning its result, making its intended behavior less clear. Code length: The implementation is concise, but imports are disproportionate to the functionality shown. Action granularity: Each executable line performs a single action. Reading flow: The progression from initialization to header access is natural, though import ordering and the informal opening docstring slightly interrupt an otherwise straightforward presentation.

Run 2

Code Structure: The small wrapper class is logically organized, but numerous unused imports and the misplaced threading import add clutter. Nesting: Methods are flat, with no complex branching or deep nesting. Clarity of intent: Class and constructor docstrings explain the adapter's purpose, and names are descriptive; however, the informal '...what?' wording distracts, and getheaders calls the underlying method without returning its result, making its intended behavior unclear. Code length: The implementation is concise, although imports occupy disproportionate space. Action granularity: Each executable line performs a single action. Reading flow: The constructor followed by accessor methods is natural, but inconsistent import grouping and limited spacing between imports and the class slightly weaken presentation.

Run 3

Code Structure: The small wrapper class is logically organized, but numerous unused imports and the misplaced threading import add clutter. Nesting: Methods are flat, with no complex branching. Clarity of intent: The class docstring explains its compatibility purpose, and method names are recognizable; however, Any annotations provide little detail, and getheaders omits a return, making its intended behavior unclear. Code length: The implementation is concise, although imports dominate the snippet and some documentation is informal or repetitive. Action granularity: Each executable line performs a single action. Reading flow: Constructor followed by accessors is natural, but inconsistent import grouping and limited spacing between imports and the class slightly disrupt readability.