Sample

pyint-ce08f1222318-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines162

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8920–1; higher is more readable
Mi0.5610–1; higher is more readable
LLOC60Logical lines; fewer is more readable
DeepSeek V4 Pro7.670–20; mean of three runs
GPT-6.1 Sol13.670–20; mean of three runs
BTTF0.4160–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, met: str | None = None, url2: _t.UriType | None = None, hea: _t.HeadersType = None, fil: _t.FilesType = None, dat: _t.DataType = None, par: _t.ParamsType = None, aut: _t.AuthType = None, coo: RequestsCookieJar | CookieJar | dict[str, str] | None = None, hoo: _t.HooksInputType | None = None, jso: _t.JsonType = None, ) -> None: # Default empty dicts for dict params. dat = [] if dat is None else dat fil = [] if fil is None else fil hea = {} if hea is None else hea par = {} if par is None else par hoo = {} if hoo is None else hoo self.hooks = default_hooks() for k2, v2 in list(hoo.items()): self.register_hook(event=k2, hook=v2) self.method = met self.url = url2 self.headers = hea self.files = fil self.data = dat self.json = jso self.params = par self.auth = aut self.cookies = coo def __repr__(self) -> str: return f"<Request [{self.method}]>" def pre(self) -> PreparedRequest: """Constructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it.""" p2 = PreparedRequest() p2.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 p2

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.4502.379−148.578
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.624−6.936

Intercept 8.87 + feature contributions = -81.844 (log-odds).
Score = sigmoid(-81.844) = 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.961+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.926−0.652
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.055+0.408
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398

Intercept 0.07 + feature contributions = 2.116 (log-odds).
Score = sigmoid(2.116) = 0.892.

Score0.561
Score60
Run 1

The code is a mix of clear structure and severely obfuscated naming. The imports are logically grouped and the class docstring is excellent, but the parameter names in '__init__' (met, url2, hea, fil, dat, par, aut, coo, hoo, jso) are ambiguous and break clarity of intent. The use of suffix '2' (e.g., url2, p2, k2, v2) further obscures meaning, suggesting renaming artifacts. Nesting is generally flat and action granularity is mostly one action per line, which aids readability. However, abbreviations like 'pre' instead of 'prepare' and shortened type annotations reduce clarity. The mixed naming style—full names for type hints but truncated names for variables—creates confusion. Overall structure is professional, but the naming significantly harms readability and maintainability.

Run 2

The code has some readable aspects, such as good type hints, clear imports, and a well-documented class. However, it is severely undermined by poor naming conventions and inconsistent style. Critical parameters and local variables are abbreviated to near-meaningless names (e.g., 'met', 'url2', 'hea', 'fil', 'dat', 'par', 'aut', 'coo', 'hoo', 'jso', 'k2', 'v2', 'p2'), making the logic hard to follow and forcing the reader to constantly map abbreviations to their intended meanings. The class attributes retain full names, but the constructor and methods do not, creating a confusing mismatch. Additionally, the method name 'pre' is ambiguous, and the overall action granularity and reading flow suffer from the lack of descriptive identifiers. While the structure is flat and imports are organized, the unclear intent and poor naming significantly lower readability.

Run 3

The code is largely unreadable due to poor naming conventions and unclear intent. Parameters in `__init__` use cryptic abbreviations like `met`, `url2`, `hea`, `fil`, `dat`, `par`, `aut`, `coo`, `hoo`, and `jso`, which obscure meaning. The `pre` method and variables `p2`, `k2`, `v2` are ambiguous. Imports are extensive and somewhat disorganized, making the top of the file noisy. The class docstring is helpful, but the implementation does not match its clarity. Structure and nesting are acceptable, but readability is severely reduced by the unnecessary renaming of clear parameters to short, non-descriptive alternatives. Action granularity is mostly one action per line, but the unnatural flow and unclear references hinder comprehension. Overall, the code appears intentionally obfuscated rather than optimized for readability.

Run 1

Code Structure: The class is logically organized into documentation, annotations, initialization, representation, and request preparation, but the extensive import block distracts from the small implementation. Nesting: Minimal nesting makes control flow easy to follow. Clarity of intent: Descriptive attributes, type hints, and documentation help, but abbreviated parameters such as met, hea, and jso and names like p2 obscure meaning. The method pre also conflicts with the documented prepare usage, and documented parameter names do not match the constructor. Code length: The implementation is concise, though imports and documentation dominate the snippet. Action granularity: Statements generally perform one action per line, with clear assignments and readable multiline calls. Reading flow: Initialization and preparation follow a natural sequence, but inconsistent naming and base classes or types not defined or imported in the snippet interrupt comprehension.

Run 2

Code Structure: The class is logically organized into documentation, attributes, initialization, representation, and request preparation, although the extensive imports obscure its focus. Nesting: Control flow is shallow, with only one simple loop. Clarity of intent: Type annotations, descriptive attributes, and documentation help, but abbreviated parameters such as met, hea, and jso and names like pre and p2 reduce clarity. Documentation refers to prepare() and descriptive parameter names that do not match the implementation. Code length: The methods are concise, but many imports are unused in this snippet and the documentation is disproportionately long. Action granularity: Statements generally perform one action per line, and multiline arguments are easy to scan. Reading flow: Initialization and preparation follow a natural sequence, but inconsistent naming and dependencies not defined or imported in the snippet interrupt comprehension.

Run 3

Code Structure: The class is logically organized into attributes, initialization, representation, and request preparation, though the extensive imports obscure the small implementation. Nesting: Minimal nesting makes control flow easy to follow. Clarity of intent: Type annotations, descriptive instance attributes, and documentation clarify the purpose, but abbreviated parameters such as met, hea, and jso, temporary names like p2, and the method name pre reduce clarity. Documentation refers to prepare() and full parameter names that do not match the implementation, creating confusion. Code length: Methods are concise, but the import block and documentation are disproportionately large for this excerpt. Action granularity: Statements generally perform one action per line, with straightforward assignments and initialization. Reading flow: Initialization proceeds naturally from defaults to hooks to attributes, followed by preparation; however, missing definitions for referenced classes in the excerpt and inconsistent naming interrupt comprehension.