Sample

pyint-c5faab6220db-I13

Lower every eligible synchronous for loop to a while loop

Matched original source

Lines20

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7690–1; higher is more readable
Mi0.2480–1; higher is more readable
LLOC18Logical lines; fewer is more readable
DeepSeek V4 Pro13.670–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.6970–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: 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.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.835−7.253

Intercept 8.87 + feature contributions = -8.066 (log-odds).
Score = sigmoid(-8.066) = 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.046+0.5
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.876−0.132
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.952−0.06
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.202 (log-odds).
Score = sigmoid(1.202) = 0.769.

Score0.248
Score18
Run 1

The code is well-structured with clear imports, type hints, and a single, focused class. It uses modern Python features like `from __future__ import annotations` and explicit typing, which improves clarity. The class inherits from a presumably well-defined `HTTPBasicAuth` and overrides `__call__` concisely. Nesting is minimal, with only one method and one conditional-free line inside it. The purpose is unambiguous: attach proxy authentication headers. However, some imported modules (`hashlib`, `os`, `re`, `threading`, etc.) are not used in the visible snippet, which slightly reduces perceived cleanliness. The action granularity is appropriate—each line performs one logical step. Reading flow is natural, aided by the docstring and consistent naming. Overall, very readable despite minor unused imports.

Run 2

The code is well-structured with clear imports, a single class definition, and a straightforward method override. The intent of HTTPProxyAuth is immediately obvious from the class name and docstring. Nesting is minimal, and the method performs one logical action. However, the __call__ method combines header assignment and returning the request on adjacent lines, which slightly reduces action granularity. Some imports like Final, cast, and overload appear unused, adding unnecessary length. Overall the code is readable, but could be cleaner with minor refinements.

Run 3

The code shows a relatively clear class structure with a single purpose (HTTP proxy authentication), but suffers from excessive unused imports and mixed abstraction levels. The import block is cluttered with many modules not obviously used in this snippet (hashlib, os, re, threading, time, warnings, b64encode, TYPE_CHECKING, Any, Final, cast, overload, to_native_string, basestring, urlparse, extract_cookies_to_jar, parse_dict_header), which obscures actual dependencies and intent. The class itself is flat, concise, and has clear action granularity — one header assignment per line — but the docstring is generic and does not clarify how this differs from HTTPBasicAuth beyond the header name. The `_basic_auth_str` helper is referenced but not defined here, creating ambiguity about its implementation. While the method is readable in isolation, the surrounding import noise and missing context reduce overall clarity and maintainability, making the code appear poorly organized despite the simple logic.

Run 1

Code Structure: The class and its method are logically organized, but the numerous unused imports clutter this short snippet, and the base class and authentication helper are not defined or imported here. Nesting: Minimal nesting makes the implementation easy to follow. Clarity of intent: The class name, docstring, and explicit Proxy-Authorization header clearly communicate its purpose, although the parameter name 'r' is terse. 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 flows naturally from setting the authentication header to returning the request; import clutter and limited spacing between top-level elements slightly reduce readability.

Run 2

Code Structure: A focused class with a single, logically organized method, although numerous unrelated imports clutter the snippet. Nesting: Minimal nesting makes the implementation easy to follow. Clarity of intent: The class name, docstring, and Proxy-Authorization header clearly communicate its purpose; however, HTTPBasicAuth, PreparedRequest, and _basic_auth_str are not defined or imported in the shown code. Code length: The implementation is concise, but the unused imports add unnecessary length. Action granularity: Each statement performs one clear action. Reading flow: The method flows naturally from setting the authentication header to returning the request, though the import block distracts from the otherwise straightforward implementation.

Run 3

Code Structure: A focused class and short method provide logical organization, although numerous unused imports add clutter. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The class name, docstring, method annotation, and explicit Proxy-Authorization assignment clearly communicate its purpose; HTTPBasicAuth, PreparedRequest, and _basic_auth_str are not defined or imported in the snippet, reducing self-contained clarity. Code length: The implementation is concise, but the import section is disproportionately long. Action granularity: Each statement performs one clear action. Reading flow: Setting the authentication header and returning the request follows a natural sequence, though missing separation between import groups and limited spacing before the class slightly weaken presentation.