Sample

pyint-27d6e0ad930b-I08

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

Matched original source

Lines23

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7640–1; higher is more readable
Mi0.2010–1; higher is more readable
LLOC21Logical lines; fewer is more readable
DeepSeek V4 Pro5.670–20; mean of three runs
GPT-6.1 Sol14.330–20; mean of three runs
BTTF0.4740–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, r: PreparedRequest) -> PreparedRequest: running_total = 0 for current_number in range(1, 6): running_total += current_number r.headers["Proxy-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.652.381−21.529
Source linesThe number of non-empty source lines.23+9.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.782−7.173

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.88+0.615
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.048+0.474
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.24+0.187
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.22.921−0.089
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.22−0.084
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.87.917−0.059
Indentation frequencyHow rapidly indentation changes from line to line.23+0.058

Intercept 0.07 + feature contributions = 1.172 (log-odds).
Score = sigmoid(1.172) = 0.764.

Score0.201
Score21
Run 1

The code has a clear structure with imports and a single class, but it contains a major readability issue: an irrelevant loop at the start of the __call__ method that sums numbers 1 to 5, which serves no purpose in the method's intended functionality. This dead code obscures the method's clear intent of setting the Proxy-Authorization header. The nesting is flat, and the action granularity is good, but the unnecessary loop makes the code longer than needed and disrupts the reading flow. The class docstring is helpful, but the method lacks a docstring explaining its action. Overall, the code is readable in terms of layout and simplicity but is confused by the inclusion of meaningless logic, which drops its clarity and conciseness significantly.

Run 2

The code is nearly unreadable due to a severe violation of clarity of intent. The core purpose of `__call__` is to attach proxy authentication headers, but it contains an irrelevant loop that sums numbers from 1 to 5, which serves no purpose and is never used. This breaks the principle of action granularity, adding multiple unrelated actions within a single method. The reading flow is disrupted because the meaningless loop sits between the method definition and the actual authentication logic. While the code structure is superficially flat (good nesting) and uses clean imports, the 7-line block of dead code makes the method unnecessarily long and deeply confusing. The intent is ambiguous at best; a reader must waste time trying to understand why the loop exists. To improve readability, the loop should be completely removed, leaving only the single meaningful line that sets the header. The present version fails to maintain one action per logical step and obscures an otherwise simple authorization process.

Run 3

The code contains a major readability problem: an irrelevant loop that sums numbers 1 through 5 into 'running_total' is inserted inside __call__. This variable is never used afterward, making the purpose of the loop ambiguous and misleading. The actual intended action—setting the Proxy-Authorization header—is buried after the loop, disrupting reading flow and clarity of intent. The structure is illogical because unrelated logic is mixed with the class's stated purpose. Action granularity is poor: the loop performs multiple operations (assignment, iteration, accumulation) in a single block without meaningful context. While the overall code length is short, this unnecessary addition makes it longer and confusing. Nesting is minimal, but the presence of dead code drastically reduces readability. The helper function _basic_auth_str and the class docstring are clear, but they are overshadowed by the nonsensical loop.

Run 1

Code Structure: The class and method are logically organized, but numerous unused imports and an unrelated summation loop add clutter. Nesting: Shallow nesting makes the method easy to scan. Clarity of intent: The class name, docstring, and Proxy-Authorization assignment clearly communicate proxy authentication; however, the unused running_total obscures the method's focus, and referenced authentication helpers and types are not defined or imported in this snippet. Code length: The authentication logic is concise, but the imports and redundant loop unnecessarily lengthen the code. Action granularity: Each statement performs one action, with no compressed multi-action lines. Reading flow: The header assignment followed by returning the request is natural, but the irrelevant loop interrupts that flow, and minimal spacing between imports and the class weakens visual separation.

Run 2

Code Structure: The class and method are logically organized, but numerous unused imports and an unrelated calculation add clutter. Nesting: Only one shallow loop makes the code easy to scan. Clarity of intent: The class name, docstring, and authorization header assignment clearly convey proxy authentication; however, the unused running_total calculation obscures that purpose, and referenced authentication helpers are not defined in the snippet. Code length: The functional method is short, but the imports and redundant loop make the snippet unnecessarily long. Action granularity: Each statement performs one action, with no compressed compound statements. Reading flow: The main operation and return follow naturally, but the irrelevant loop interrupts the authentication logic, and additional spacing between imports and the class would improve readability.

Run 3

Code Structure: The class and method are logically organized, but numerous unused imports and an unrelated calculation add clutter. Nesting: Only one shallow loop appears, keeping the code easy to scan. Clarity of intent: The class name, docstring, and authorization-header assignment clearly communicate proxy authentication; however, the unused running_total calculation obscures that purpose, and HTTPBasicAuth, PreparedRequest, and _basic_auth_str are not defined or imported in the snippet. Code length: The authentication logic is concise, but the imports and pointless loop unnecessarily extend the code. Action granularity: Each line performs a single, straightforward action. Reading flow: The method follows a simple sequence and returns the modified request naturally, although the unrelated calculation interrupts the flow before the essential header assignment.