Sample

pyint-8acec2e3ba21-I03

Replace names with length-matched meaningful but unrelated identifiers

Matched original source

Lines162

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8930–1; higher is more readable
Mi0.5610–1; higher is more readable
LLOC60Logical lines; fewer is more readable
DeepSeek V4 Pro7.330–20; mean of three runs
GPT-6.1 Sol120–20; mean of three runs
BTTF0.4140–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, config: str | None = None, key: _t.UriType | None = None, feature: _t.HeadersType = None, total: _t.FilesType = None, path: _t.DataType = None, offset: _t.ParamsType = None, date: _t.AuthType = None, context: RequestsCookieJar | CookieJar | dict[str, str] | None = None, count: _t.HooksInputType | None = None, step: _t.JsonType = None, ) -> None: # Default empty dicts for dict params. path = [] if path is None else path total = [] if total is None else total feature = {} if feature is None else feature offset = {} if offset is None else offset count = {} if count is None else count self.hooks = default_hooks() for age, map in list(count.items()): self.register_hook(event=age, hook=map) self.method = config self.url = key self.headers = feature self.files = total self.data = path self.json = step self.params = offset self.auth = date self.cookies = context def __repr__(self) -> str: return f"<Request [{self.method}]>" def extract(self) -> PreparedRequest: """Constructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it.""" key = PreparedRequest() key.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 key

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.4496.645−148.389
Source linesThe number of non-empty source lines.162+64.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.617−6.925

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.163−4.735
Indentation frequencyHow rapidly indentation changes from line to line.135+3.932
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.161.951+1.854
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.101.939+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.963−0.654
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.054+0.418
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398

Intercept 0.07 + feature contributions = 2.124 (log-odds).
Score = sigmoid(2.124) = 0.893.

Score0.561
Score60
Run 1

The code displays mixed readability. The imports are well-structured and descriptive, but the __init__ method has severely ambiguous parameter names: config, key, feature, total, path, offset, date, context, count, step. These names give no indication of their purpose (method, url, headers, files, data, params, auth, cookies, hooks, json respectively), violating 'Clarity of intent.' The assignment section remaps these cryptic names to equally unclear attributes (self.method = config, self.url = key, etc.), hurting 'Reading flow.' The class-level type annotations use correct names (method, url, headers), creating inconsistency. While 'Code structure' and 'Action granularity' are adequate, the ambiguous naming renders the constructor almost unreadable despite otherwise clean formatting. Nesting is flat and docstrings are helpful, but the parameter naming issue dominates the evaluation.

Run 2

The code is structurally clear at the class level, with type annotations and docstrings helping readability. However, the __init__ method uses misleading, obfuscated parameter names (config, key, feature, total, path, offset, date, context, count, step) that do not match their actual roles (method, url, headers, files, data, params, auth, cookies, hooks, json). This severely damages clarity of intent. Additionally, assigning these to class attributes with different names creates confusing cross-mapping, violating natural reading flow and action granularity. The loop for hooks uses unclear variable names ('age', 'map'). While the code is relatively flat and concise, the semantic mismatch forces readers to decode intent unnecessarily, making it difficult to understand and maintain despite good formatting.

Run 3

The code is highly unreadable. There is a severe mismatch between parameter names and their semantic meaning (e.g., 'config' for method, 'key' for URL, 'feature' for headers, 'path' for data). This destroys clarity of intent, making the code ambiguous and misleading. Variable reassignment and mapping logic inside __init__ are tangled, and reading flow is unnatural. Action granularity is inconsistent, with multiple logical actions and confusing assignments. Nesting is limited but not enough to overcome the naming chaos. Imports are excessively long but somewhat organized. The class-level type hints use meaningful names, but they conflict with the constructor's confusing parameters, worsening readability.

Run 1

Code Structure: The class is logically divided into initialization, representation, and request preparation, but extensive imports distract from the small implementation. Nesting: Minimal nesting makes control flow easy to follow. Clarity of intent: Descriptive attributes and type hints help, but misleading parameter names such as config, key, date, and step obscure their HTTP meanings. The docstring documents different parameter names and demonstrates prepare(), while the actual method is extract(), creating confusion. Code length: The implementation is reasonably concise, although the import block and documentation are disproportionately long for this excerpt. Action granularity: Statements generally perform one action per line, and keyword arguments clearly expose the preparation mapping. Reading flow: Initialization proceeds naturally from defaults to hooks to attribute assignment, followed by simple methods. However, readers must repeatedly translate arbitrary input names into meaningful attributes, and referenced classes are not defined or imported in the excerpt.

Run 2

Code Structure: The class is logically divided into initialization, representation, and request preparation, but the extensive imports distract from its small implementation. Nesting: Nearly flat, with only one simple loop, making control flow easy to follow. Clarity of intent: The main weakness is misleading parameter names such as config, feature, date, and step, which obscure their HTTP meanings. The constructor names contradict the documented parameters, and extract contradicts the prepare method shown in the usage example. Code length: Methods are concise, but the import block and documentation are disproportionately long for this excerpt. Action granularity: Statements generally perform one action per line, and attribute assignments are easy to scan. Reading flow: Initialization followed by preparation is natural, but readers must repeatedly translate arbitrary names into meaningful attributes. The loop variables age and map further obscure intent, with map also shadowing a built-in.

Run 3

Code Structure: Imports, attributes, initialization, representation, and request preparation are logically organized, though many imports appear unrelated to this excerpt. Nesting: Mostly flat, with only a simple loop, making control flow easy to follow. Clarity of intent: The primary weakness is misleading names: config means method, key means URL or a prepared request, and date means authentication. The constructor parameters do not match the documented parameter names, and extract does not match the prepare method shown in the usage example. Code length: Methods are concise, but extensive imports and documentation make the excerpt longer than its functionality warrants. Action granularity: Statements generally perform one action per line, and the multiline preparation call clearly separates arguments. Reading flow: Formatting and attribute assignments are orderly, but readers must repeatedly translate generic parameter names into HTTP concepts; map also shadows a built-in. Overall, clean layout and shallow nesting are substantially undermined by inconsistent naming and documentation.