Sample

pyint-278735450ecf-I05

Rewrite eligible decimal integer literals in hexadecimal notation

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 Pro16.670–20; mean of three runs
GPT-6.1 Sol170–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 generally well-structured and readable. It follows a logical organization with a clear class definition and docstrings that explain the purpose and behavior. Nesting is minimal and the methods are flat. The intent of the MockResponse class is explicitly documented, reducing ambiguity. The code is concise, avoiding unnecessary verbosity while maintaining clarity. Each method performs a single action, and the reading flow is natural. However, there is a minor issue: the `getheaders` method lacks an explicit `return` statement, which could confuse readers about its behavior. Additionally, the numerous imports at the top are not strictly ordered (e.g., `threading` is placed after local imports), slightly reducing readability. Overall, the code is clear and maintainable, but small improvements in import organization and method return clarity would enhance its readability further.

Run 3

The code is generally readable with a clear, focused purpose: wrapping HTTP headers for compatibility with cookiejar. The structure is logical—imports are organized, and the class has a clear docstring explaining its intent. Nesting is minimal and flat, and action granularity is appropriate. However, there are minor issues: the getheaders method is missing a return statement, and unused imports (Cookie, CookieJar, CookiePolicy, etc.) clutter the top. The docstring's informal tone ("...what?") may be intentional but slightly reduces professional clarity. Overall, the code is concise and easy to follow, with only small structural blemishes preventing a higher score.

Run 1

Code Structure: The small wrapper class is logically organized, although numerous unused imports and the misplaced threading import add clutter. Nesting: Methods are flat and straightforward, with no deeply nested logic. Clarity of intent: The class docstring clearly explains the compatibility purpose, and names are descriptive; however, getheaders does not return its delegated result, making its intended behavior less clear. Code length: The implementation is concise, but the import block is disproportionate to the functionality shown. Action granularity: Each statement performs a single action, supporting easy comprehension. Reading flow: The constructor followed by accessor methods creates a natural progression, though import ordering and limited spacing between imports and the class slightly weaken presentation.

Run 2

Code Structure: The class is logically organized, although numerous unused imports and the misplaced threading import clutter the snippet. Nesting: Methods are flat and straightforward, with no complex nesting. Clarity of intent: Descriptive names, type hints, and docstrings explain the response adapter well; however, getheaders does not return the delegated result, making its intended behavior less clear. Code length: The implementation is concise, but the imports are excessive for the code shown. Action granularity: Each statement performs one action, making individual lines easy to follow. Reading flow: The progression from initialization to header access is natural, though inconsistent import grouping and the informal opening docstring slightly interrupt the flow.

Run 3

Code Structure: The class is logically organized into initialization and two small interface methods, but numerous unused imports and inconsistent import grouping add clutter. Nesting: Methods are flat, with no nested control flow. Clarity of intent: Descriptive names, type annotations, and docstrings explain the wrapper's purpose, although the informal introductory wording is distracting. The missing return in getheaders makes its intended behavior uncertain. Code length: The class is concise, but the imports are disproportionately lengthy for this snippet. Action granularity: Each statement performs one action, making individual lines easy to follow. Reading flow: Method order is natural, though import clutter and limited spacing between imports and the class slightly weaken presentation.