Sample

pyint-57dc65f71d9b-I05

Rewrite eligible decimal integer literals in hexadecimal notation

Matched original source

Lines43

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.6780–1; higher is more readable
Mi0.5650–1; higher is more readable
LLOC31Logical lines; fewer is more readable
DeepSeek V4 Pro17.330–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.580–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.43+17.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.628−6.942

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.43+0.75
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.43−0.566
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.44−0.522
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.82+0.519
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.81.955+0.194
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.42.831+0.189
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.086+0.108

Intercept 0.07 + feature contributions = 0.742 (log-odds).
Score = sigmoid(0.742) = 0.678.

Score0.565
Score31
Run 1

The code is well-structured and highly readable. It has a clear class definition with a single responsibility (HTTP Basic Auth), no unnecessary nesting, and type hints that improve clarity. Each method is concise and focused on one action. The reading flow is natural, with imports, class definition, overloaded constructors, equality methods, and the main __call__ method in logical order. Minor deductions: the __eq__ method uses an unnecessary list inside all(), and the __ne__ method could be omitted in Python 3. The overloaded constructor with ellipsis bodies may add slight complexity for readers unfamiliar with typing overloads. Overall, this is clean, maintainable code that clearly expresses its intent.

Run 2

The code is well-structured and readable, with clear separation of class definition, overloads, and methods. Nesting is minimal and action granularity is appropriate, with one logical operation per line. Type hints and docstrings improve clarity. However, the `__eq__` method's use of `all([...])` is slightly verbose; a tuple or generator would suffice. Minor redundancy in overloads adds length but enhances type safety. Overall, the code is maintainable and easy to follow.

Run 3

The code is highly readable. It has a clear structure with a single class definition and logical method organization. Nesting is minimal, with no deeply nested blocks. The intent is clear: the class implements HTTP Basic Authentication for requests. The overload decorators and type hints improve clarity, making the constructor's accepted types explicit. The code is concise, avoiding unnecessary length, and each action is generally on its own line (e.g., assigning attributes, setting headers). Reading flow is natural, with methods following standard class structure (__init__, comparison methods, __call__). The use of `all()` in __eq__ is slightly terse but acceptable. Overall, this code is well-written and maintains strong readability principles.

Run 1

Code Structure: The class is logically organized into annotations, initialization, equality methods, and request authentication, although numerous unused imports clutter the excerpt. Nesting: Methods are flat, with no deeply nested control flow. Clarity of intent: The class name, docstring, type annotations, and Authorization assignment clearly communicate its purpose; externally defined symbols require context. Code length: The implementation is concise overall, though the overloads and all([...]) equality expression add some verbosity. Action granularity: Each statement performs a single clear action. Reading flow: Method ordering is natural and consistent, but minimal spacing around imports and overload declarations slightly reduces visual separation.

Run 2

Code Structure: The class is logically organized into initialization, equality checks, and request authentication, although numerous unused imports clutter the snippet. Nesting: Methods are flat, with only a shallow list expression in __eq__. Clarity of intent: The docstring, descriptive attribute names, and type annotations clearly communicate Basic Authentication behavior; however, AuthBase, PreparedRequest, and _basic_auth_str are not defined or imported in the provided code. Code length: The implementation is concise overall, but the import block and all([...]) equality construction add avoidable verbosity. Action granularity: Each statement performs one clear action, and header assignment is separated from returning the request. Reading flow: Method ordering is natural and consistent, though missing spacing between import groups and tightly packed overload declarations slightly reduce visual readability.

Run 3

Code Structure: The class is logically organized into initialization, comparison, and request modification, although numerous unused imports clutter the snippet. Nesting: Methods are flat, with only a shallow list inside all(). Clarity of intent: The class docstring, descriptive credential attributes, and type annotations clearly communicate its purpose; undefined external names and the abbreviated parameter r slightly reduce standalone clarity. Code length: The implementation is concise, though equality could be expressed more directly and unused imports removed. Action granularity: Each statement performs a single clear action; compact overload declarations remain understandable. Reading flow: Methods follow a natural sequence, with consistent formatting, but crowded imports and limited spacing between overload declarations mildly interrupt scanning.