Sample

pyint-a204bdcfa83a-I09

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

Matched original source

Lines167

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.2670–1; higher is more readable
Mi0.5610–1; higher is more readable
LLOC65Logical lines; fewer is more readable
DeepSeek V4 Pro160–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.470–1; higher is more readable

Views

Source code

from __future__ import annotations import datetime import encodings.idna # noqa: F401 from collections.abc import Callable, Generator, Iterable, Iterator, Mapping from io import UnsupportedOperation from typing import ( TYPE_CHECKING, Any, Final, Literal, cast, overload, ) from urllib3.exceptions import ( DecodeError, LocationParseError, ProtocolError, ReadTimeoutError, SSLError, ) from urllib3.fields import RequestField from urllib3.filepost import encode_multipart_formdata from urllib3.util import parse_url from . import _types as _t from ._internal_utils import to_native_string, unicode_is_ascii from .auth import HTTPBasicAuth from .compat import ( JSONDecodeError, basestring, builtin_str, chardet, cookielib, urlencode, urlsplit, urlunparse, ) from .compat import json as complexjson from .cookies import ( _copy_cookie_jar, cookiejar_from_dict, get_cookie_header, ) from .exceptions import ( ChunkedEncodingError, ConnectionError, ContentDecodingError, HTTPError, InvalidJSONError, InvalidURL, MissingSchema, StreamConsumedError, ) from .exceptions import JSONDecodeError as RequestsJSONDecodeError from .exceptions import SSLError as RequestsSSLError from .hooks import default_hooks from .status_codes import codes from .structures import CaseInsensitiveDict from .utils import ( check_header_validity, get_auth_from_url, guess_filename, guess_json_utf, iter_slices, parse_header_links, requote_uri, stream_decode_response_unicode, super_len, to_key_val_list, ) class Request(RequestHooksMixin): """A user-created :class:`Request <Request>` object. Used to prepare a :class:`PreparedRequest <PreparedRequest>`, which is sent to the server. :param method: HTTP method to use. :param url: URL to send. :param headers: dictionary of headers to send. :param files: dictionary of {filename: fileobject} files to multipart upload. :param data: the body to attach to the request. If a dictionary or list of tuples ``[(key, value)]`` is provided, form-encoding will take place. :param json: json for the body to attach to the request (if files or data is not specified). :param params: URL parameters to append to the URL. If a dictionary or list of tuples ``[(key, value)]`` is provided, form-encoding will take place. :param auth: Auth handler or (user, pass) tuple. :param cookies: dictionary or CookieJar of cookies to attach to this request. :param hooks: dictionary of callback hooks, for internal usage. Usage:: >>> import requests >>> req = requests.Request('GET', 'https://httpbin.org/get') >>> req.prepare() <PreparedRequest [GET]> """ hooks: dict[str, list[_t.HookType]] method: str | None url: _t.UriType | None headers: Mapping[str, str | bytes] files: _t.FilesType data: _t.DataType json: _t.JsonType params: _t.ParamsType auth: _t.AuthType cookies: RequestsCookieJar | CookieJar | dict[str, str] | None def __init__( self, method: str | None = None, url: _t.UriType | None = None, headers: _t.HeadersType = None, files: _t.FilesType = None, data: _t.DataType = None, params: _t.ParamsType = None, auth: _t.AuthType = None, cookies: RequestsCookieJar | CookieJar | dict[str, str] | None = None, hooks: _t.HooksInputType | None = None, json: _t.JsonType = None, ) -> None: # Default empty dicts for dict params. data = [] if data is None else data files = [] if files is None else files headers = {} if headers is None else headers params = {} if params is None else params hooks = {} if hooks is None else hooks self.hooks = default_hooks() for k, v in list(hooks.items()): self.register_hook(event=k, hook=v) self.method = method self.url = url self.headers = headers self.files = files self.data = data self.json = json self.params = params self.auth = auth self.cookies = cookies def __repr__(self) -> str: lI0O_b7667c3b, lI0O_e279fbef = 0, 0 while lI0O_e279fbef < 2: lI0O_b7667c3b ^= (lI0O_e279fbef << 1) ^ 0xe lI0O_e279fbef += 1 lI0O_b7667c3b ^= lI0O_b7667c3b return f"<Request [{self.method}]>" def prepare(self) -> PreparedRequest: """Constructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it.""" p = PreparedRequest() p.prepare( method=self.method, url=self.url, headers=self.headers, files=self.files, data=self.data, json=self.json, params=self.params, auth=self.auth, cookies=self.cookies, hooks=self.hooks, ) return p

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.4705.03−155.266
Source linesThe number of non-empty source lines.167+66.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.678−7.017

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.168−4.912
Indentation frequencyHow rapidly indentation changes from line to line.140+4.105
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.140−2.792
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.166.932+1.924
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.101.929+0.84
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.101.964−0.654
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.055+0.406

Intercept 0.07 + feature contributions = -1.012 (log-odds).
Score = sigmoid(-1.012) = 0.267.

Score0.561
Score65
Run 1

The code is generally well-structured with clear type annotations and docstrings. However, the `__repr__` method contains obfuscated, meaningless variable names (`lI0O_b7667c3b`, `lI0O_e279fbef`) and dead logic that performs pointless operations, severely reducing clarity of intent and reading flow. The imports and class definition are organized, but this obfuscation pulls the readability score down.

Run 2

The code demonstrates strong readability overall. The class structure is logical, with a clear docstring explaining purpose and parameters, and type annotations enhance clarity. The __init__ method uses sensible defaults and is flat, with minimal nesting. The __repr__ method contains obfuscated variables (lI0O_b7667c3b, lI0O_e279fbef) with an unnecessary loop that reduces clarity and could be simplified to a direct return statement. Imports are well-organized but somewhat extensive, which is typical for compatibility layers. Action granularity is good, with one logical action per line. The reading flow is natural for a request preparation class. The main readability issue is the confusing __repr__ implementation that appears intentionally obfuscated, contradicting the otherwise clean code style.

Run 3

The code is generally readable with clear structure and intent. Class and method definitions are logical, type hints are used extensively, and docstrings explain purpose. The __init__ method is flat with one action per line for defaults and attribute assignments. However, the __repr__ method contains obfuscated variable names (lI0O_b7667c3b) and a pointless loop that reduces clarity. Imports are extensive and organized but add length. Overall nesting is minimal, reading flow is natural, and action granularity is appropriate except in the obfuscated section.

Run 1

Code Structure: The class is logically divided into initialization, representation, and preparation, though many imports are unused in this excerpt. Nesting: Mostly flat, with only simple loops. Clarity of intent: Descriptive attributes, type annotations, and documentation make request construction clear; however, __repr__ contains meaningless bitwise operations and opaque variable names that obscure an otherwise trivial method. Code length: Most implementation is concise, but the extensive import block and pointless __repr__ loop add unnecessary length. Action granularity: Statements generally perform one action per line, except the paired variable initialization in __repr__. Reading flow: Initialization and preparation follow a natural sequence, but the irrelevant computation interrupts that flow. Overall, readable and well documented, with a conspicuous pocket of obfuscation.

Run 2

Code Structure: The class is logically organized into initialization, representation, and preparation, although the extensive imports obscure its focus. Nesting: Mostly flat, with only simple loops, making control flow easy to follow. Clarity of intent: Descriptive attributes, type annotations, and thorough documentation explain request construction well. However, cryptic variables and pointless bitwise operations in __repr__ introduce deliberate ambiguity. Code length: Most class code is appropriate, but the import block and redundant __repr__ calculations add distracting bulk. Action granularity: Statements generally perform one action per line; the combined assignment in __repr__ is a minor exception. Reading flow: Initialization and preparation proceed naturally, while the unrelated computation in __repr__ interrupts an otherwise straightforward flow.

Run 3

Code Structure: The class is logically organized into documented attributes, initialization, representation, and preparation, although the extensive import block distracts from the small implementation. Nesting: Control flow is shallow, with only simple loops. Clarity of intent: Descriptive names, type annotations, and the class docstring clearly explain request construction; however, __repr__ contains meaningless arithmetic and opaque variable names that obscure an otherwise trivial method. Code length: Most implementation is concise, but the unrelated-looking imports and redundant __repr__ loop add unnecessary length. Action granularity: Statements generally perform one action per line, apart from a paired assignment. Reading flow: Initialization and preparation follow a natural sequence, but the obfuscated block interrupts that flow and forces readers to verify that it has no effect on the returned representation.