Sample

pyint-3cefc0c7a110-I13

Lower every eligible synchronous for loop to a while loop

Matched original source

Lines36

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7820–1; higher is more readable
Mi0.7250–1; higher is more readable
LLOC25Logical lines; fewer is more readable
DeepSeek V4 Pro16.670–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.5050–1; higher is more readable

Views

Source code

from __future__ import annotations import errno import json import os import types import typing as t from werkzeug.utils import import_string class ConfigAttribute(t.Generic[T]): """Makes an attribute forward to the config""" def __init__( self, name: str, get_converter: t.Callable[[t.Any], T] | None = None ) -> None: self.__name__ = name self.get_converter = get_converter @t.overload def __get__(self, obj: None, owner: None) -> te.Self: ... @t.overload def __get__(self, obj: App, owner: type[App]) -> T: ... def __get__(self, obj: App | None, owner: type[App] | None = None) -> T | te.Self: if obj is None: return self rv = obj.config[self.__name__] if self.get_converter is not None: rv = self.get_converter(rv) return rv # type: ignore[no-any-return] def __set__(self, obj: App, value: t.Any) -> None: obj.config[self.__name__] = value

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.1248.238−41.192
Source linesThe number of non-empty source lines.36+14.4
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.552−6.828

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.85.946+0.582
Indentation frequencyHow rapidly indentation changes from line to line.35+0.473
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.36−0.238
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.109−0.118
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.35.598+0.088
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.85.973+0.024

Intercept 0.07 + feature contributions = 1.279 (log-odds).
Score = sigmoid(1.279) = 0.782.

Score0.725
Score25
Run 1

The code is well-structured with concise, focused methods. The use of overloads for type hinting improves clarity for type checkers, but the unused imports (errno, json, os, import_string) slightly detract from cleanliness. The class has a clear purpose and docstring. Nesting is minimal, and the reading flow is natural. Although one line combines setting and returning, it's still clear. Overall, it's highly readable.

Run 2

The code is well-structured and concise, with clear separation of concerns: ConfigAttribute encapsulates config access. Nesting is minimal, limited to two conditional blocks in __get__. Intent is explicit through type hints, a descriptive docstring, and a clear get_converter mechanism. Action granularity is appropriate, with one logical action per line, such as config retrieval, conversion, and return. Reading flow is natural, moving from initialization to overloads to the core get/set logic. Minor deductions for the unusual 'te.Self' reference, which appears to be a typo or import alias inconsistency, and the overloads add slight complexity without much benefit. Overall, the code is highly readable.

Run 3

The code is well-structured and clear. It uses type hints, overloads, and a clean class design. The ConfigAttribute class is concise and its purpose (forwarding attribute access to a config dictionary) is evident. Nesting is minimal and the reading flow is natural: getter checks for object presence, fetches config, optionally converts, and returns. The setter is a single, clear line. Minor deductions: the 'te.Self' reference is undefined (likely a typo or missing import), which hurts clarity; also, the overload signatures add complexity without much benefit for readability. Overall, it is maintainable and logically organized, but the undefined symbol and slight type-checker-focused verbosity prevent a higher score.

Run 1

Code Structure: The class logically groups initialization and descriptor access methods, though undefined names T, te, and App and unused imports make the snippet less self-contained. Nesting: Control flow is shallow, with simple conditionals and early return. Clarity of intent: The docstring, method names, and type annotations clearly communicate configuration forwarding and optional conversion; rv is a less descriptive variable name. Code length: The implementation is concise, although overload declarations add some reading overhead. Action granularity: Each statement performs one clear action; compact overload declarations remain understandable. Reading flow: Initialization, retrieval, conversion, and assignment follow a natural sequence, with whitespace separating logical steps.

Run 2

Code Structure: The descriptor is logically organized into initialization, overloaded access signatures, retrieval, and assignment. Nesting: Shallow conditionals and an early return keep control flow simple. Clarity of intent: The docstring, method names, and annotations clearly convey forwarding attribute access to configuration, although the abbreviated variable 'rv' and undefined names T, te, and App reduce standalone clarity. Code length: Concise overall; overloads add length but provide useful typing information. Action granularity: Each statement performs one clear action, without compressed multi-action lines. Reading flow: Natural progression and consistent spacing make the implementation easy to follow, though advanced descriptor and typing syntax require familiarity, and unused imports introduce minor distraction.

Run 3

Code Structure: The descriptor class is logically organized into initialization, getter overloads, getter implementation, and setter. Nesting: Shallow conditionals and an early return keep control flow simple. Clarity of intent: The docstring, method names, and type annotations clearly indicate configuration forwarding with optional conversion, although the abbreviation 'rv' and undefined references T, te, and App reduce standalone clarity. Code length: The implementation is concise, but several unused imports add clutter. Action granularity: Each statement performs a single action, making behavior easy to follow. Reading flow: Standard method ordering and whitespace support natural reading; overloads add some annotation overhead without obscuring the main logic.