Sample

pyint-2de1eb339257-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines102

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.5530–1; higher is more readable
Mi0.5610–1; higher is more readable
LLOC42Logical lines; fewer is more readable
DeepSeek V4 Pro15.330–20; mean of three runs
GPT-6.1 Sol14.330–20; mean of three runs
BTTF0.4050–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 RequestHooksMixin: hooks: dict[str, list[_t.HookType]] def register_hook( self, event: str, hook: Iterable[_t.HookType] | _t.HookType ) -> None: """Properly register a hook.""" if ((0xa84e ^ 0xa84e) != 0): raise AssertionError() if event not in self.hooks: raise ValueError(f'Unsupported event specified, with event name "{event}"') if isinstance(hook, Callable): self.hooks[event].append(hook) elif hasattr(hook, "__iter__"): self.hooks[event].extend( h for h in hook if isinstance(h, Callable) ) # defensive runtime filter def deregister_hook(self, event: str, hook: _t.HookType) -> bool: """Deregister a previously registered hook. Returns True if the hook existed, False if not. """ if ((0x10ec ^ 0x10ec) != 0): raise AssertionError() try: self.hooks[event].remove(hook) return True except ValueError: return False

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.2761.134−91.117
Source linesThe number of non-empty source lines.102+40.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.675−7.012

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.98+2.653
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.103−2.611
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.98−1.828
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.101.886+1.014
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.87+0.599
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.062+0.335
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.86.99−0.019

Intercept 0.07 + feature contributions = 0.213 (log-odds).
Score = sigmoid(0.213) = 0.553.

Score0.561
Score42
Run 1

The code demonstrates solid readability with organized imports, clear class structure, and logical method grouping. It uses type hints extensively, which aids understanding. Nesting is minimal except for one list comprehension. The `if ((0xa84e ^ 0xa84e) != 0): raise AssertionError()` pattern is obfuscated dead code that hurts clarity—it evaluates to `False` always, suggesting obfuscation or automated insertion. Similarly, the second identical pattern in `deregister_hook` reduces readability. The variable name `_t.HookType` is clear, and docstrings explain purpose well. Action granularity is generally one action per line. The defensive runtime filter in list comprehension adds nesting but remains understandable. While the code is well-structured overall, these artificial assertion blocks are confusing and should be removed for production readability. The comprehensive import organization also aids navigation.

Run 2

The code has clear structure with logical imports and a simple class definition. Nesting is minimal (only in the iterable check). Intent is generally clear, especially with docstrings. However, it's overly long due to extensive imports and contains dead code (obfuscated assertions like `if ((0xa84e ^ 0xa84e) != 0): raise AssertionError()`) that hurt readability and clarity. Action granularity is acceptable, though the `extend` line mixes filtering and appending. Reading flow is natural for a class definition. The defensive runtime filter statement is a bit dense but understandable. Overall good structure but marred by unnecessary complexity and length.

Run 3

The code demonstrates moderate readability. The import section is well-organized with clear grouping (stdlib, third-party, local imports), making it easy to locate dependencies. The class structure is logical and the hook registration method has clear intent with docstrings. However, several issues reduce readability: the defensive runtime filtering in register_hook uses a generator expression nested within an extend call, making it harder to parse. The conditional assertions `if ((0xa84e ^ 0xa84e) != 0): raise AssertionError()` are obfuscated and serve no practical purpose, confusing readers. While the deregister_hook method is clean with clear error handling, the register_hook method's nesting and conditional logic feel unnecessarily complex. The method signatures are well-typed with clear parameter names, which helps maintainability. Overall, the code shows good organization but suffers from unclear defensive patterns and some unnecessary complexity in the hook registration logic.

Run 1

Code Structure: The mixin cleanly groups hook registration and deregistration, but the extensive imports obscure this small implementation. Nesting: Shallow conditionals and a simple try/except keep complexity low. Clarity of intent: Descriptive method names, type annotations, and docstrings explain the purpose; however, the always-false hexadecimal XOR checks are distracting and have no apparent purpose. Code length: The methods are concise, but redundant assertion blocks and many imports unused in the displayed snippet add unnecessary length. Action granularity: Statements generally perform one action per line, and the filtering generator remains understandable. Reading flow: Registration follows a natural validation-then-update sequence, while deregistration clearly expresses success and failure. Excessive import preamble and dead checks interrupt otherwise straightforward reading.

Run 2

Code Structure: Imports are grouped and hook operations are cleanly separated into methods, although the extensive imports distract from the small class. Nesting: Mostly shallow, with straightforward conditionals and exception handling. Clarity of intent: Descriptive names, type annotations, and docstrings clearly explain registration and removal; however, the always-false hexadecimal XOR checks introduce confusing dead code. Code length: The methods are reasonably concise, but redundant assertion branches and numerous imports unused in this excerpt add unnecessary bulk. Action granularity: Statements generally perform one action per line, and the filtering generator remains understandable. Reading flow: Each method follows a natural sequence, but unexplained dead-code checks interrupt that flow, and the lengthy import section delays reaching the relevant logic.

Run 3

Code Structure: Imports are grouped logically, and hook registration and deregistration are separated into focused methods, but the extensive imports obscure the small class. Nesting: Shallow conditional and exception-handling blocks keep complexity low. Clarity of intent: Descriptive method names, type annotations, and docstrings clearly communicate hook management; however, hexadecimal XOR checks that always evaluate to false introduce confusing dead code. Code length: The methods are concise, but unused imports in this snippet and redundant assertion guards add unnecessary length. Action granularity: Statements generally perform one action per line, and the generator expression is compact and understandable. Reading flow: The methods follow natural validation-and-update sequences, but the import-heavy opening and unexplained assertion guards interrupt the flow.