Sample

pyint-c20d4715171f-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines14

Scores

MethodScoreScale
Posnett0.0230–1; higher is more readable
Dorn0.4620–1; higher is more readable
Mi0.5120–1; higher is more readable
LLOC6Logical lines; fewer is more readable
DeepSeek V4 Pro17.670–20; mean of three runs
GPT-6.1 Sol15.670–20; mean of three runs
BTTF0.6780–1; higher is more readable

Views

Source code

from __future__ import annotations from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequence from typing import ( TYPE_CHECKING, Any, Protocol, TypeAlias, TypeVar, runtime_checkable, ) @runtime_checkable class SupportsRead(Protocol[_T_co]): def read(self, length: int = ..., /) -> _T_co: ...

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.330.619−10.91
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.88−7.319
Source linesThe number of non-empty source lines.14+5.6

Intercept 8.87 + feature contributions = -3.76 (log-odds).
Score = sigmoid(-3.76) = 0.023.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.15+0.505
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Indentation frequencyHow rapidly indentation changes from line to line.14−0.253
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.81+0.234
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.13.805−0.217
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.106−0.086

Intercept 0.07 + feature contributions = -0.152 (log-odds).
Score = sigmoid(-0.152) = 0.462.

Score0.512
Score6
Run 1

The code is highly readable. It has a clear, logical structure with imports organized by standard library modules and typing utilities. Nesting is essentially flat — the only indented block is a minimal Protocol method definition. Intent is explicit: it defines a runtime-checkable structural protocol for objects with a `read` method. The code is concise, avoiding any unnecessary verbosity. Action granularity is appropriate, with each import grouping and the Protocol definition on separate logical lines. Reading flow is natural, from future imports down to the protocol definition. The only minor deduction is that the lengthy import block could be slightly streamlined, but it is well-organized and conventional.

Run 2

This code is highly readable. It has a clear, logical structure: future import, standard library imports, then typing imports. Nesting is minimal and only used for type definitions. The intent is unambiguous — defining a runtime-checkable protocol for objects with a read method. Code length is concise for its purpose. Action granularity is one action per line, with imports grouped and the protocol definition cleanly separated. Reading flow is natural, moving from imports to the protocol definition. Minor deductions: the ellipsis default and positional-only marker (`/`) require some familiarity with advanced typing, and the `_T_co` TypeVar is not explicitly shown (assumed imported), which could briefly confuse readers if this snippet is standalone.

Run 3

The code is well-structured and highly readable. It begins with `from __future__ import annotations` for consistent behavior, followed by clear imports grouped from `collections.abc` and `typing`. The Protocol class `SupportsRead` is concise, with a single method `read` that has a clear signature, default argument, and return type. The use of `runtime_checkable` and a type variable `_T_co` demonstrates intent for flexible, static-duck typing. Nesting is minimal, and the overall length is appropriately short. Each significant element sits on its own line, improving scanning. The reading flow is natural, from setup to definition. Minor deductions are because the import block is slightly verbose for what could be a simpler stub, and the underscore-prefixed type variable may be unfamiliar to some readers.

Run 1

Code Structure: Imports followed by a protocol definition provide clear, logical organization. Nesting: Only the necessary class and method levels are present. Clarity of intent: SupportsRead and read clearly describe a readable-object interface, although _T_co is not defined in the snippet and advanced typing syntax requires familiarity. Code length: The implementation is concise, but numerous unused imports add clutter. Action granularity: Each statement has a single purpose; the inline ellipsis is appropriate for a protocol method stub. Reading flow: The code reads naturally from dependencies to interface, though a second blank line before the top-level class would improve visual separation.

Run 2

Code Structure: Imports and the protocol declaration are logically organized, though several imports are unused in this snippet. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: SupportsRead clearly represents objects with a read method, but the undefined _T_co obscures the return-type parameter and makes the snippet incomplete. Code length: The declaration is concise, while the extensive imports add unnecessary length relative to the functionality shown. Action granularity: Each statement has a distinct purpose; the one-line method stub is appropriate for a protocol. Reading flow: The progression from imports to decorator, class, and method is natural, although additional spacing before the top-level class would improve presentation.

Run 3

Code Structure: Imports and the protocol declaration are logically organized, but several imports are unused and _T_co is undefined in the snippet. Nesting: Minimal, with only a class and its method. Clarity of intent: SupportsRead, the read method, and runtime_checkable clearly indicate a runtime-checkable reading interface; the missing type variable definition weakens clarity. Code length: The implementation is concise, though unused imports add clutter. Action granularity: Each statement serves a single purpose; the inline ellipsis is conventional for protocol methods. Reading flow: The code reads naturally from imports to interface definition, but the missing generic declaration interrupts understanding, and an additional blank line before the class would improve formatting.