Sample

pyint-6aca69356e3a-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines19

Scores

MethodScoreScale
Posnett0.010–1; higher is more readable
Dorn0.8730–1; higher is more readable
Mi0.4970–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.6880–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 AuthBase: """Base class that all auth implementations derive from""" def __call__(self, r: PreparedRequest) -> PreparedRequest: raise NotImplementedError("Auth hooks must be callable.")

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.422.873−13.955
Source linesThe number of non-empty source lines.19+7.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.708−7.062

Intercept 8.87 + feature contributions = -4.547 (log-odds).
Score = sigmoid(-4.547) = 0.01.

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.64.7+0.925
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.035+0.6
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.20+0.328
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.65+0.244
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.18.894−0.146
Indentation frequencyHow rapidly indentation changes from line to line.19−0.08
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.19−0.015

Intercept 0.07 + feature contributions = 1.927 (log-odds).
Score = sigmoid(1.927) = 0.873.

Score0.497
Score17
Run 1

The code is highly readable. It begins with clear future import and standard imports, organized logically (standard library, then local modules). Constants like `Final` are properly imported. The `AuthBase` class has a clear docstring and a single, focused method with a descriptive parameter type hint and return type. Nesting is non-existent, action granularity is one action per line, and overall structure is flat. The only minor deduction is that some imported names (e.g., `overload`, `cast`, `Any`) are not used in the shown code, which slightly reduces clarity of intent for a reviewer seeing only this fragment.

Run 2

The code is well-structured and highly readable. It demonstrates logical organization through grouped imports (standard library, typing, internal modules) and a clear class hierarchy. Nesting is flat with no nested blocks or conditionals. The intent is unambiguous — defining an abstract base class for authentication implementations. Code length is concise and appropriately scoped, with no unnecessary repetition or dead code. Action granularity is clean: each import line is focused, and the only method is a single, well-defined action. The reading flow is natural, moving from imports to the base class definition. Type hints and the abstract method pattern communicate the contract clearly. The only minor deduction is that it uses a `NotImplementedError` rather than `@abstractmethod` from the `abc` module, which could make the contract more explicit, but this does not meaningfully reduce readability.

Run 3

The code is highly readable. It has a clean, logical structure with only one class and imports organized from standard library to third-party to local modules, following convention. Nesting is minimal (flat). The intent of the AuthBase class is clear: it serves as an abstract base for authentication implementations, though it does not explicitly inherit from ABC. The code is concise, with only the essential method defined. Action granularity is appropriate, with one clear action in the __call__ method. Reading flow is natural; imports are grouped logically, and the class/method sequence is intuitive. Minor deductions: some imports (e.g., hashlib, os, re, threading, time, warnings) appear unused, which slightly obscures purpose, and the type hint for 'r' could be more specific (e.g., using TYPE_CHECKING import), but overall the code is exemplary in clarity and organization.

Run 1

1. Code Structure: Imports precede a clearly defined base class, providing logical organization, though many imports are unused in this snippet. 2. Nesting: Minimal nesting keeps the code easy to scan. 3. Clarity of intent: The class name, docstring, type annotations, and exception clearly communicate an authentication interface requiring callable subclasses. PreparedRequest is not defined or imported in the snippet, leaving minor ambiguity. 4. Code length: The implementation is concise, but the extensive import list distracts from its small scope. 5. Action granularity: Each statement occupies its own line, with no bundled operations. 6. Reading flow: The progression from imports to class documentation to the required method is natural; better import grouping and an additional blank line before the class would improve presentation.

Run 2

Code Structure: Imports precede a clearly defined authentication base class, giving the snippet a logical organization. Nesting: Only the necessary class and method levels are present. Clarity of intent: The class name, docstring, type annotations, and explicit NotImplementedError clearly communicate the authentication-hook interface, although the parameter name 'r' is terse. Code length: The implementation is concise, but many imports are unused in the shown snippet and add visual clutter. Action granularity: Each statement performs one action, with no compressed multi-action lines. Reading flow: The progression from imports to class documentation to method is natural; additional spacing between import groups and before the class would improve scanning.

Run 3

Code Structure: Imports precede a clearly defined authentication base class, giving the code a logical organization, although many imports are unused in this snippet. Nesting: Minimal nesting makes it easy to follow. Clarity of intent: The class name, docstring, type annotations, and explicit NotImplementedError clearly communicate an interface for callable authentication hooks; PreparedRequest is not defined or imported in the snippet. Code length: The implementation is concise, but the extensive imports add unnecessary visual overhead for the code shown. Action granularity: Each statement occupies its own line. Reading flow: The progression from imports to class documentation to method is natural, though grouping imports and adding standard blank-line separation would improve presentation.