Sample

pyint-00108635d51b-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines88

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.5690–1; higher is more readable
Mi0.5080–1; higher is more readable
LLOC36Logical lines; fewer is more readable
DeepSeek V4 Pro16.330–20; mean of three runs
GPT-6.1 Sol14.670–20; mean of three runs
BTTF0.4580–1; higher is more readable

Views

Source code

from __future__ import annotations import os.path import socket # noqa: F401 import typing import warnings from typing import Any from urllib3.exceptions import ( ClosedPoolError, ConnectTimeoutError, LocationValueError, MaxRetryError, NewConnectionError, ProtocolError, ReadTimeoutError, ResponseError, ) from urllib3.exceptions import HTTPError as _HTTPError from urllib3.exceptions import InvalidHeader as _InvalidHeader from urllib3.exceptions import ProxyError as _ProxyError from urllib3.exceptions import SSLError as _SSLError from urllib3.poolmanager import PoolManager, proxy_from_url from urllib3.util import Timeout as TimeoutSauce from urllib3.util import parse_url from urllib3.util.retry import Retry from .auth import _basic_auth_str from .compat import basestring, urlparse from .cookies import extract_cookies_to_jar from .exceptions import ( ConnectionError, ConnectTimeout, InvalidHeader, InvalidProxyURL, InvalidSchema, InvalidURL, ProxyError, ReadTimeout, RetryError, SSLError, ) from .models import Response from .structures import CaseInsensitiveDict from .utils import ( DEFAULT_CA_BUNDLE_PATH, get_auth_from_url, get_encoding_from_headers, prepend_scheme_if_needed, select_proxy, urldefragauth, ) from ._types import is_prepared as _is_prepared class BaseAdapter: """The Base Transport Adapter""" def __init__(self) -> None: super().__init__() def send( self, request: PreparedRequest, stream: bool = False, timeout: _t.TimeoutType = None, verify: _t.VerifyType = True, cert: _t.CertType = None, proxies: dict[str, str] | None = None, ) -> Response: """Sends PreparedRequest object. Returns Response object. :param request: The :class:`PreparedRequest <PreparedRequest>` being sent. :param stream: (optional) Whether to stream the request content. :param timeout: (optional) How long to wait for the server to send data before giving up, as a float, or a :ref:`(connect timeout, read timeout) <timeouts>` tuple. :type timeout: float or tuple :param verify: (optional) Either a boolean, in which case it controls whether we verify the server's TLS certificate, or a string, in which case it must be a path to a CA bundle to use :param cert: (optional) Any user-provided SSL certificate to be trusted. :param proxies: (optional) The proxies dictionary to apply to the request. """ raise NotImplementedError def close(self) -> None: """Cleans up adapter specific items.""" remaining_steps = 3 while remaining_steps > 0: remaining_steps -= 1 raise NotImplementedError

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.1916.47−63.244
Source linesThe number of non-empty source lines.88+35.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.631−6.946

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.89−2.115
Indentation frequencyHow rapidly indentation changes from line to line.74+1.822
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.74−1.277
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.87.948+0.82
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.94.944+0.727
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.037+0.584
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.94.921−0.355

Intercept 0.07 + feature contributions = 0.277 (log-odds).
Score = sigmoid(0.277) = 0.569.

Score0.508
Score36
Run 1

The code is generally highly readable with clear imports, consistent type hints, and descriptive method documentation. Structure is logical, nesting is minimal, and intent is explicit. Minor issues include a redundant `socket` import and a meaningless `while` loop in `close()`, which slightly detracts from clarity. Overall, it's clean, well-organized, and easy to follow.

Run 2

The code is well-structured with clear imports and a simple class definition. It follows good practices like using type hints, docstrings, and future annotations. The nesting is minimal, and intent is clear for a base adapter class. However, the close() method contains a pointless while loop that serves no purpose, which hurts clarity and action granularity. Reading flow is natural due to logical grouping of imports, but the unused while loop and imported socket module with noqa comment suggest minor code cleanliness issues. Overall, the code is readable but has a few unnecessary elements that could be cleaned up.

Run 3

The code is well-structured with organized imports, clear type hints, and good docstrings. The BaseAdapter class has a clean, flat design. Intent is clear. However, there is a suspicious meaningless loop in close() that detracts from readability. Some import ordering could be slightly improved (nested imports before top-level). The send() method has a reasonable number of parameters with clear documentation. Overall the code is quite readable despite the odd loop in close() and minor import ordering issues.

Run 1

Code Structure: Imports and adapter methods are logically organized, but many imports are unused in this snippet, and referenced annotation names are not visibly defined. Nesting: Very shallow, with only one simple loop. Clarity of intent: The abstract adapter interface and send parameters are well documented; however, the countdown in close has no apparent purpose and conflicts with its cleanup description. Code length: The extensive imports and parameter documentation outweigh the minimal implementation, while the constructor and countdown add unnecessary code. Action granularity: Statements consistently perform one action per line. Reading flow: Conventional formatting and descriptive method names make the interface easy to follow, but import clutter and the unexplained loop interrupt an otherwise natural progression.

Run 2

Code Structure: Imports and the adapter interface are logically organized, but the large import block overwhelms the small class and includes many unused names. Nesting: Very shallow; only a simple loop introduces nesting. Clarity of intent: Descriptive method names, type annotations, and the send docstring clearly communicate the interface. However, PreparedRequest and _t are undefined in the snippet, and the pointless countdown in close obscures its purpose. Code length: The interface is concise, but unused imports, a trivial constructor, and the countdown add unnecessary length. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: The class progresses naturally from initialization to sending and cleanup, although excessive imports and inconsistent spacing between sections interrupt the flow.

Run 3

Code Structure: Imports and adapter methods are logically grouped, but many imports are unused in this snippet, creating clutter. Nesting: Mostly flat, with only a simple loop. Clarity of intent: The base adapter interface and send parameters are well documented, but PreparedRequest and _t are not defined or imported here, and the countdown in close has no apparent purpose. Code length: The extensive imports and parameter documentation outweigh the small implementation; the redundant initializer and countdown add unnecessary length. Action granularity: Statements generally perform one action per line. Reading flow: Conventional formatting and descriptive method names support natural reading, but import volume, unresolved annotation names, and the unexplained loop interrupt it.