Sample

pyint-d0ea7d89a5bc-I10

Deterministically remove some optional blank lines and bracketed line breaks

Matched original source

Lines39

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.3650–1; higher is more readable
Mi0.1490–1; higher is more readable
LLOC31Logical lines; fewer is more readable
DeepSeek V4 Pro9.670–20; mean of three runs
GPT-6.1 Sol140–20; mean of three runs
BTTF0.5270–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: 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.1423.286−46.968
Source linesThe number of non-empty source lines.39+15.6
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.935

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

Feature contributions

FeatureValueContribution
(log-odds)
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.132.975−1.967
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.133+1.341
Indentation frequencyHow rapidly indentation changes from line to line.39+0.612
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.39−0.474
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.40−0.38
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.38.843+0.133
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.086+0.109

Intercept 0.07 + feature contributions = -0.555 (log-odds).
Score = sigmoid(-0.555) = 0.365.

Score0.149
Score31
Run 1

The code has a clear purpose and mostly follows standard class structure, but suffers from several readability issues. The __eq__ method has poor formatting with awkward indentation and unnecessary line breaks that disrupt reading flow. The __init__ method uses overloads followed by a concrete implementation, which is good for type clarity but adds length. Multiple methods are packed together without blank lines between them, violating PEP 8 spacing conventions and making the class feel cramped. The __call__ method is clear and concise, but the overall structure lacks consistent spacing between method definitions. Variable names are descriptive, and type hints improve clarity. However, the formatting inconsistencies—especially in __eq__—create visual noise that obscures intent. The code would benefit from proper spacing, cleaned-up __eq__ formatting, and more consistent organization.

Run 2

The code shows some good practices like type hints, overloads, and a clear class purpose, but it suffers from significant readability issues. The __eq__ method has bizarre spacing and inconsistent alignment, making it visually confusing and hard to parse. Multiple methods are crammed together without blank lines between them, violating PEP 8 and disrupting the reading flow. The nested all() call with a list containing oddly formatted expressions adds unnecessary complexity. While the overall structure is logical and the class is concise, the inconsistent formatting and lack of visual separation between methods make the code feel tangled and unpolished. The intent is mostly clear but the execution undermines readability.

Run 3

The code has several readability issues. The __eq__ method has awkward formatting with excessive whitespace and misaligned elements, making it difficult to parse visually. The overload decorators add complexity without clear immediate benefit. Type hints are inconsistent in style and placement. Some imports appear unused or overly broad. The class structure is logical but the methods lack consistent spacing and organization. The reading flow is interrupted by the poorly formatted comparison method. While the code is functional, the formatting inconsistencies, unnecessary line breaks in some places, and tight spacing in others reduce overall readability. The intent of most methods is clear, but presentation undermines comprehension.

Run 1

Code Structure: The class logically groups initialization, equality, and request authentication, but numerous unused imports and missing spacing between methods add clutter. Nesting: Very shallow, making control flow easy to follow. Clarity of intent: The docstring, method names, and type annotations clearly communicate Basic Authentication behavior; referenced types and helpers are not defined in the snippet. Code length: The class is concise, although the import block is disproportionately large and equality checking uses an unnecessarily elaborate all/list construction. Action granularity: Most lines perform one action, but both equality comparisons share a crowded line. Reading flow: Methods follow a natural sequence, yet inconsistent whitespace and awkward formatting in __eq__ interrupt scanning.

Run 2

Code Structure: The class logically groups initialization, comparison, and request authentication, but inconsistent method spacing and numerous unused imports add clutter. Nesting: Minimal nesting makes the code easy to follow. Clarity of intent: The class docstring, descriptive attribute names, and type annotations clearly communicate its purpose; AuthBase, PreparedRequest, and _basic_auth_str are not defined in the excerpt, limiting standalone understanding. Code length: Methods are concise, although the all() expression is unnecessarily elaborate for two comparisons. Action granularity: Most lines perform one action, but both equality comparisons are awkwardly placed on the same line. Reading flow: Method order is natural, but irregular whitespace in __eq__ and missing blank lines between some methods interrupt scanning.

Run 3

Code Structure: The class logically groups initialization, equality checks, and request authentication, but unused imports and inconsistent method spacing add clutter. Nesting: Minimal nesting makes the code easy to follow. Clarity of intent: The class docstring, descriptive names, and type annotations communicate its purpose well, although AuthBase, PreparedRequest, and _basic_auth_str are not defined or imported in the snippet. Code length: Methods are concise, but the import list is disproportionate to the shown functionality, and the equality implementation could be simpler. Action granularity: Most lines perform one action, but both equality comparisons share an awkwardly formatted line. Reading flow: The methods follow a natural sequence, yet irregular whitespace, missing blank lines between methods, and malformed-looking alignment in __eq__ interrupt scanning.