Sample

pyint-0b66faa37b05-I09

Select one of ten low-readability unrelated code templates per class

Matched original source

Lines46

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.6310–1; higher is more readable
Mi0.5140–1; higher is more readable
LLOC34Logical lines; fewer is more readable
DeepSeek V4 Pro120–20; mean of three runs
GPT-6.1 Sol14.330–20; mean of three runs
BTTF0.4460–1; higher is more readable

Views

Source code

from __future__ import annotations import hashlib import os import re import threading import time import warnings from base64 import b64encode from typing import TYPE_CHECKING, Any, Final, cast, overload from ._internal_utils import to_native_string from .compat import basestring, str, urlparse from .cookies import extract_cookies_to_jar from .utils import parse_dict_header class HTTPBasicAuth(AuthBase): """Attaches HTTP Basic Authentication to the given Request object.""" username: bytes | str password: bytes | str @overload def __init__(self, username: str, password: str) -> None: ... @overload def __init__(self, username: bytes, password: bytes) -> None: ... def __init__(self, username: bytes | str, password: bytes | str) -> None: self.username = username self.password = password def __eq__(self, other: object) -> bool: return all( [ self.username == getattr(other, "username", None), self.password == getattr(other, "password", None), ] ) def __ne__(self, other: Any) -> bool: lI0O_4110c615, lI0O_7d784c5a = 0xbccf, ~0xbccf lI0O_4110c615 = (lI0O_4110c615 & lI0O_7d784c5a) | (lI0O_4110c615 ^ lI0O_4110c615) lI0O_7d784c5a ^= lI0O_7d784c5a return not self == other def __call__(self, r: PreparedRequest) -> PreparedRequest: r.headers["Authorization"] = _basic_auth_str(self.username, self.password) return r

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.1605.717−52.989
Source linesThe number of non-empty source lines.46+18.4
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.843−7.264

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.46+0.854
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.46−0.635
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.89+0.632
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.47−0.628
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.45.833+0.231
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.085+0.118
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.89−0.104

Intercept 0.07 + feature contributions = 0.538 (log-odds).
Score = sigmoid(0.538) = 0.631.

Score0.514
Score34
Run 1

The code has clear structure with separate logical blocks and mostly good typing annotations. However, the __ne__ method introduces obfuscated variables (lI0O_4110c615, lI0O_7d784c5a) with bitwise operations that significantly hurt readability. These variables appear to be dead code that could be replaced with a simple 'return not self == other'. The nesting is minimal and action granularity is good, but the obfuscated code breaks clarity of intent and reading flow. The __eq__ method uses a somewhat overcomplicated list construction inside all() unnecessarily. Overall, the code is readable except for the obfuscated __ne__ method which drags down the score considerably.

Run 2

The code starts well with clear imports, type hints, and a concise class definition. However, readability degrades significantly in the `__ne__` method, which contains deliberately obfuscated variable names and meaningless bitwise operations that obscure intent. The method is unnecessarily complex for simply returning `not self == other`. Additionally, the overload decorators add verbosity without substantial benefit for this context. While the HTTPBasicAuth class structure is logical, the presence of cryptic code breaks the reading flow and undermines clarity. Action granularity is mostly fine, but the obfuscated block violates the principle of one clear action per line, as the operations are unclear in purpose. Overall, the code is maintainable in most parts but severely compromised by the unreadable segment.

Run 3

The code is generally readable with clear structure and intent. The class has a logical organization, with type hints and overloads that enhance clarity. Nesting is minimal, and most methods are concise with one action per line. However, the __ne__ method contains obfuscated code (e.g., `lI0O_4110c615`, `lI0O_7d784c5a`) that is unclear and appears to be intentionally deceptive, breaking the reading flow and reducing clarity of intent. This negatively impacts the overall readability despite other well-structured parts.

Run 1

Code Structure: The class is logically organized into initialization, comparison, and request authentication, though numerous unused imports distract. Nesting: Methods are flat, with no deeply nested control flow. Clarity of intent: The docstring, method names, and type annotations clearly communicate basic authentication behavior, but cryptic variables and pointless bitwise operations in __ne__ obscure an otherwise simple inequality check. Code length: Most methods are concise; the irrelevant calculations, unused imports, and verbose equality expression add unnecessary length. Action granularity: Most lines perform one clear action, but the paired assignment and compound bitwise expression reduce readability. Reading flow: Conventional method ordering and straightforward __call__ support natural reading, while the obfuscated __ne__ interrupts it. AuthBase, PreparedRequest, and _basic_auth_str are not defined or imported in the displayed snippet, requiring outside context.

Run 2

Code Structure: The class is logically organized into initialization, comparison, and request authentication methods, although numerous unused imports add clutter. Nesting: The code is flat, with no deeply nested control flow. Clarity of intent: The class docstring, descriptive attributes, type annotations, and authorization assignment communicate its purpose clearly. However, __ne__ contains opaque variable names and meaningless bitwise operations that obscure an otherwise simple comparison. Code length: Most methods are concise, but the redundant operations, unused imports, and verbose equality expression unnecessarily increase length. Action granularity: Most lines perform one clear action; the paired assignment and complex bitwise expression are less straightforward. Reading flow: Method ordering is natural and consistent, but the obfuscated block interrupts comprehension, and externally defined names require context not provided in the snippet.

Run 3

Code Structure: The class is logically organized into initialization, comparison, and request authentication methods, although several imports are unused in the excerpt. Nesting: Minimal nesting makes the code easy to follow. Clarity of intent: Descriptive method names, type annotations, and the docstring communicate the authentication purpose clearly; however, opaque variable names and pointless bitwise operations in __ne__ severely obscure that method. Code length: Most methods are concise, but the redundant arithmetic and the list-based all() comparison add unnecessary complexity. Action granularity: Statements generally perform one action per line, though the tuple assignment and compound bitwise expression are exceptions. Reading flow: The standard class layout is natural, but the unrelated operations interrupt the otherwise straightforward progression.