Sample

pyint-6f1b37811ad5-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines168

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.260–1; higher is more readable
Mi0.5610–1; higher is more readable
LLOC66Logical lines; fewer is more readable
DeepSeek V4 Pro12.330–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.3970–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. if ((0xa5dd ^ 0xa5dd) != 0): raise AssertionError() 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: if ((0xbc5a ^ 0xbc5a) != 0): raise AssertionError() return f"<Request [{self.method}]>" def prepare(self) -> PreparedRequest: """Constructs a :class:`PreparedRequest <PreparedRequest>` for transmission and returns it.""" if ((0x9066 ^ 0x9066) != 0): raise AssertionError() 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.4811.648−158.784
Source linesThe number of non-empty source lines.168+67.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.635−6.953

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.169−4.947
Indentation frequencyHow rapidly indentation changes from line to line.141+4.14
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.141−2.815
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.167.951+1.938
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.959−0.653
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.058+0.38

Intercept 0.07 + feature contributions = -1.048 (log-odds).
Score = sigmoid(-1.048) = 0.26.

Score0.561
Score66
Run 1

The code is a mix of clear parts and confusing obfuscations. The structure is logical with a clean class definition, type annotations, and good docstrings, but the repeated nonsensical 'if ((0x... ^ 0x...) != 0): raise AssertionError()' blocks are highly disruptive. They break reading flow and make intent ambiguous, likely as anti-debugging tricks. Imports are extensive but organized. Nesting is generally flat within methods. Action granularity is mostly one action per line. However, the obfuscated conditions add unnecessary noise, hurt readability, and lower the overall score from what would otherwise be a very readable code (around 18-19).

Run 2

The code has a clear, logical class structure with well-documented parameters and usage examples, which aids readability. Imports are grouped logically. However, readability is severely undermined by the presence of meaningless obfuscated lines like `if ((0xa5dd ^ 0xa5dd) != 0): raise AssertionError()` which serve no purpose and confuse intent. The code is relatively flat and actions are generally one per line, but the lengthy constructor with many parameters and repetitive default assignments adds verbosity. The method `prepare()` is clean, but the overall flow is disrupted by the dead code. Type annotations are helpful, and the naming is clear, but the combination of boilerplate, long import blocks, and injected nonsense reduces clarity and trust, preventing a higher score.

Run 3

The code has clear structure with organized imports, type hints, and a well-documented class. The Request class is logically organized with clear attributes and methods. However, several readability issues reduce the score: the inclusion of dead code blocks like `if ((0xa5dd ^ 0xa5dd) != 0): raise AssertionError()` is confusing and adds unnecessary complexity. The `__init__` method uses multiple assignments per line (e.g., `data = [] if data is None else data`), which slightly reduces action granularity. The import section is long but logically grouped. Overall the code is readable but could be improved by removing dead code and improving line-by-line clarity.

Run 1

1. Code Structure: Imports, documentation, type declarations, and methods are logically organized, although several referenced classes are not defined or imported in the excerpt. 2. Nesting: Mostly flat, with only simple conditionals and one loop. 3. Clarity of intent: Descriptive names, type hints, and detailed documentation clearly communicate request construction and preparation; repeated always-false XOR checks introduce confusing, purposeless noise. 4. Code length: Initialization is straightforward, but extensive imports and redundant assertion blocks make this excerpt longer than necessary. 5. Action granularity: Statements generally perform one action per line, making assignments and preparation arguments easy to inspect. 6. Reading flow: The progression from defaults to hooks, attribute assignment, and request preparation is natural, but unexplained hexadecimal checks interrupt it.

Run 2

Code Structure: The class is logically organized into declarations, initialization, representation, and preparation, although the extensive imports obscure the main code. Nesting: Control flow is shallow, with simple conditionals and one loop. Clarity of intent: Descriptive method names, type annotations, and documentation explain request construction well; unexplained hexadecimal XOR checks that are always false introduce distracting ambiguity. Code length: Most class code is appropriately sized, but redundant assertion blocks and imports unused in this excerpt add unnecessary length. Action granularity: Statements generally perform one action per line, and multiline argument lists are easy to scan. Reading flow: Initialization and preparation follow a natural sequence, but the repeated dead-code checks interrupt it. Referenced classes and mixins absent from the excerpt also require external context.

Run 3

Code Structure: The class is logically organized into initialization, representation, and preparation, though the extensive imports include many names unused in this excerpt. Nesting: Control flow is shallow, with only simple conditionals and a loop. Clarity of intent: Descriptive method names, type annotations, and comprehensive documentation make the request lifecycle clear; repeated always-false XOR checks introduce unexplained noise. Code length: Most initialization and argument forwarding are reasonable, but irrelevant imports and dead assertion branches unnecessarily lengthen the snippet. Action granularity: Statements generally perform one action per line, and multiline signatures and calls are easy to scan. Reading flow: Attribute assignments and preparation arguments follow a consistent sequence, but redundant checks interrupt otherwise natural progression. Referenced classes absent from the excerpt also require external context.