Sample

pyint-8428e68ce8fa-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines20

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7650–1; higher is more readable
Mi0.2520–1; higher is more readable
LLOC18Logical lines; fewer is more readable
DeepSeek V4 Pro15.330–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.7080–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 HTTPProxyAuth(HTTPBasicAuth): """Attaches HTTP Proxy Authentication to a given Request object.""" def __call__(self, r2: PreparedRequest) -> PreparedRequest: r2.headers["Proxy-Authorization"] = _basic_auth_str(self.username, self.password) return r2

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.535.841−17.683
Source linesThe number of non-empty source lines.20+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.855−7.283

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.89+0.632
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.045+0.502
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.21+0.293
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.19.933−0.131
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.88.952−0.102
Indentation frequencyHow rapidly indentation changes from line to line.20−0.045
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.20−0.038

Intercept 0.07 + feature contributions = 1.179 (log-odds).
Score = sigmoid(1.179) = 0.765.

Score0.252
Score18
Run 1

The code is generally readable with a clear class hierarchy and a focused single-purpose method. It benefits from modern typing annotations and selective imports. The __call__ method is concise and unambiguous. However, readability is slightly reduced by unused imports (hashlib, os, re, threading, time, warnings, b64encode, TYPE_CHECKING, Any, Final, overload, extract_cookies_to_jar, parse_dict_header) which obscure the actual dependencies. The docstring could mention why HTTPBasicAuth is reused instead of composing a new authentication context. Overall structure is logical with minimal nesting and one action per line, but trimming dead imports would improve clarity and maintainability.

Run 2

The code is generally clear and well-structured, with a clean class definition and a concise __call__ method. The imports are organized, though some appear unused (hashlib, os, re, threading, time, warnings, b64encode, urlparse, parse_dict_header), which slightly reduces clarity. The method has a single, obvious purpose: attaching proxy authentication headers. Nesting is minimal, with no deep indentation or conditional complexity. Action granularity is appropriate—one header assignment per line. The reading flow is natural: class docstring, then method logic. However, the score is lowered because several imports are unused, which can confuse readers about dependencies, and the compatibility imports (basestring, str) might be unclear without context. Overall, the code is readable and maintainable, but not exemplary due to the import clutter and minor ambiguity around legacy compatibility.

Run 3

The code is readable due to clean imports, clear class inheritance, and a concise method with explicit intent. However, the evaluation is limited because the snippet is only a small portion of the codebase. The class name and docstring clearly explain its purpose, and the method performs a single action with flat nesting. Some minor issues include the use of non-descriptive parameter name 'r2' (though conventional in requests library), and the call to an undefined function '_basic_auth_str' which could confuse readers without surrounding context. The import list is organized but somewhat lengthy, and several imports (e.g., warnings, threading, hashlib) appear unused in this snippet. While the action granularity and nesting are excellent, the fragmented nature of the code prevents a higher score.

Run 1

Code Structure: A small, focused class cleanly encapsulates proxy authentication, but the numerous unused imports clutter the snippet, and the base class and helper definitions are not shown. Nesting: Minimal nesting makes the code easy to follow. Clarity of intent: The class name, docstring, type annotations, and explicit header assignment clearly communicate its purpose; the parameter name 'r2' is less descriptive than 'request'. Code length: The implementation is concise, though the import section is disproportionately long. Action granularity: Each statement performs one clear action. Reading flow: The method naturally proceeds from setting the authentication header to returning the request, but irrelevant imports distract from that straightforward flow.

Run 2

Code Structure: The class and its single method are logically organized, though numerous unused imports clutter the snippet and referenced dependencies are not shown. Nesting: Minimal nesting makes the code easy to follow. Clarity of intent: The class name, docstring, and Proxy-Authorization header clearly convey proxy authentication; the parameter name r2 is less descriptive. Code length: The implementation is concise, but the import block is disproportionately long for the functionality shown. Action granularity: Each statement performs one clear action. Reading flow: The method naturally sets the authentication header and returns the request, although import clutter and limited spacing between top-level sections slightly disrupt the overall flow.

Run 3

Code Structure: A small, logically organized authentication class, though the many unused imports add clutter and referenced dependencies are not defined in the snippet. Nesting: Minimal, with only the class and method levels. Clarity of intent: The class name, docstring, type annotations, and explicit header assignment clearly communicate proxy authentication; the parameter name 'r2' is less descriptive than 'request'. Code length: The implementation is concise, but the import section is disproportionately long. Action granularity: Each statement performs one clear action. Reading flow: The method naturally proceeds from setting the authentication header to returning the request, although unrelated imports and limited spacing between top-level sections slightly interrupt readability.