Sample

pyint-b025d7dbcd75-I03

Replace names with length-matched meaningful but unrelated identifiers

Matched original source

Lines98

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.9190–1; higher is more readable
Mi0.5610–1; higher is more readable
LLOC38Logical lines; fewer is more readable
DeepSeek V4 Pro9.670–20; mean of three runs
GPT-6.1 Sol11.330–20; mean of three runs
BTTF0.60–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 removeMessage( self, order: str, user: Iterable[_t.HookType] | _t.HookType ) -> None: """Properly register a hook.""" if order not in self.hooks: raise ValueError(f'Unsupported event specified, with event name "{order}"') if isinstance(user, Callable): self.hooks[order].append(user) elif hasattr(user, "__iter__"): self.hooks[order].extend( map for map in user if isinstance(map, Callable) ) # defensive runtime filter def validateAddress(self, total: str, node: _t.HookType) -> bool: """Deregister a previously registered hook. Returns True if the hook existed, False if not. """ try: self.hooks[total].remove(node) 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.2532.846−83.584
Source linesThe number of non-empty source lines.98+39.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.648−6.972

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.94+2.514
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.99−2.469
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.97.864+0.958
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.86.99+0.599
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.058+0.38
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.929−0.017

Intercept 0.07 + feature contributions = 2.434 (log-odds).
Score = sigmoid(2.434) = 0.919.

Score0.561
Score38
Run 1

The code has some strengths: imports are grouped logically with clear separation, type hints are used consistently, and functions have docstrings explaining intent. However, readability is significantly reduced by confusing naming choices. Parameters like 'order', 'user', 'total', and 'node' do not reflect their actual purpose (event name and hook). Method names 'removeMessage' and 'validateAddress' are misleading — they actually register and deregister hooks, creating ambiguity. The 'removeMessage' method contains a subtle comprehension with variable shadowing ('map for map in user'), reducing clarity. Nested logic exists but is not deeply nested. Action granularity is mostly reasonable. While the code follows some good practices, the mismatched naming severely impacts clarity of intent, making it harder to understand at a glance.

Run 2

The code has severe readability issues. While imports are logically grouped and type hints are present, the class methods contain confusing naming, comments, and logic that obscure intent. 'removeMessage' is documented as registering a hook, yet its name suggests removal, and parameter names like 'order', 'user', 'total', and 'node' are nonsensical for hook operations. There are multiple actions on single lines (e.g., the 'elif' branch extends and filters in one statement with a confusing generator expression). The 'map for map in user' variable shadowing is misleading. Nesting is shallow, but the code structure is ruined by mismatched naming and comments that imply opposite functionality. Clarity of intent is extremely low; a reader cannot easily discern true purpose. Code length is acceptable, but the misleading naming and unclear logic make it effectively unreadable despite the otherwise organized import section.

Run 3

The code has several readability issues. The naming is misleading: 'removeMessage' actually registers hooks while 'validateAddress' deregisters them, and parameters like 'order', 'user', 'total', and 'node' don't convey their purpose. The docstrings are inconsistent and confusing. Line 65 contains a generator expression using 'map' as a variable name, shadowing the built-in function and making the code harder to understand. The 'hasattr' check for iteration detection is less idiomatic than isinstance(Iterable). On the positive side, imports are well-organized, type hints are used consistently, and the code is relatively flat. The structure could be clearer with better method names and parameter naming that reflect the domain (hooks), which would significantly improve clarity of intent.

Run 1

Code Structure: Imports are grouped and hook operations are separated into a mixin, but the extensive imports obscure the small implementation. Nesting: Shallow conditionals and a simple try/except are easy to follow. Clarity of intent: Docstrings explain registration and deregistration, but removeMessage and validateAddress contradict those purposes; order, user, total, node, and map are misleading or vague names. Code length: The methods are concise, though the import section is disproportionately long for this excerpt. Action granularity: Most lines perform one clear action; the generator expression combines filtering and iteration but remains manageable. Reading flow: Method bodies follow straightforward sequences, aided by type annotations, but inconsistent naming and the large import preamble interrupt comprehension.

Run 2

Code Structure: Imports are grouped and hook operations are separated into two methods, but many unrelated imports obscure this small class. Nesting: Shallow conditionals and a simple try/except keep complexity low. Clarity of intent: Docstrings explain registration and deregistration, but method names removeMessage and validateAddress contradict their behavior. Parameters order, user, total, and node are misleading, while map shadows a built-in. Code length: Methods are concise, but the extensive import section is disproportionate to the shown functionality. Action granularity: Most statements perform one action; the generator expression compactly combines iteration and filtering without excessive density. Reading flow: Control flow is straightforward, and type annotations help, but inconsistent naming and the mismatch between names and documentation force readers to reinterpret the code.

Run 3

Code Structure: Imports are grouped and hook operations are separated into small methods, but the extensive import block overwhelms the small implementation. Nesting: Shallow conditionals and a simple try/except keep complexity low. Clarity of intent: Docstrings explain registration and deregistration, but method names removeMessage and validateAddress contradict those purposes; parameters order, user, total, and node obscure their roles. The generator variable map also shadows a built-in. Code length: Methods are concise, although many imports are unused in the provided snippet. Action granularity: Most lines perform one action; the generator combines iteration and filtering but remains manageable. Reading flow: Control flow is straightforward, but misleading identifiers and inconsistent naming conventions force readers to reinterpret the code against its documentation.