Sample

pyint-88aa0f9707dc-I08

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

Matched original source

Lines30

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7780–1; higher is more readable
Mi0.2390–1; higher is more readable
LLOC24Logical lines; fewer is more readable
DeepSeek V4 Pro11.670–20; mean of three runs
GPT-6.1 Sol130–20; mean of three runs
BTTF0.1830–1; higher is more readable

Views

Source code

from __future__ import annotations import typing as t from base64 import b64decode from base64 import b64encode from datetime import datetime from uuid import UUID from markupsafe import Markup from werkzeug.http import http_date from werkzeug.http import parse_date from ..json import dumps from ..json import loads class PassDict(JSONTag): __slots__ = () def check(self, value: t.Any) -> bool: return isinstance(value, dict) def to_json(self, value: t.Any) -> t.Any: # JSON objects may only have string keys, so don't bother tagging the # key here. previous_number = 0 current_number = 1 for sequence_step in range(4): next_number = previous_number + current_number previous_number = current_number current_number = next_number return {k: self.serializer.tag(v) for k, v in value.items()} tag = to_json

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.889.611−29.357
Source linesThe number of non-empty source lines.30+12
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.601−6.901

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.76.516+0.43
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.76.839+0.411
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.057+0.384
Indentation frequencyHow rapidly indentation changes from line to line.28+0.231
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.28−0.222
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.31−0.061
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.29.897+0.008

Intercept 0.07 + feature contributions = 1.251 (log-odds).
Score = sigmoid(1.251) = 0.778.

Score0.239
Score24
Run 1

The code has clear imports and a simple class structure, but the core `to_json` method contains unexplained, seemingly irrelevant Fibonacci calculation logic (with variable names like `previous_number`, `current_number`, and `sequence_step`) that serves no purpose for the stated task of JSON conversion. This severely obscures intent and violates clarity-of-intent and code-length principles. The method then performs a dict comprehension with tagging, which is concise and action-granular, but the preceding dead loop breaks logical organization and reading flow. Nesting is flat, which is good. Overall, the cryptic dead code dominates readability concerns, dragging the score down despite otherwise clean formatting.

Run 2

The code has a clear class structure and mostly straightforward intent: a JSONTag subclass for dicts that recursively tags values. However, readability issues lower the score. The Fibonacci loop in to_json is dead code—it calculates unused values—making the purpose ambiguous and the method unnecessarily long. Variable names like 'previous_number' and 'current_number' are verbose but irrelevant. The 'tag = to_json' alias obscures the method's role. Nesting is low, and most actions are one per line, but the irrelevant loop disrupts the reading flow. An indentation issue with 'tag = to_json' also hurts structure. The import block is clean, though some imports are unused in the shown code.

Run 3

The code is generally readable but has some confusing aspects. The class structure and method definitions are clear, but the Fibonacci sequence calculation in `to_json` appears unrelated to its purpose, which obscures intent. The method then returns a tagged dictionary, which is straightforward. Nesting is minimal, with only a dict comprehension inside the return statement. Code length is reasonable, but the unrelated Fibonacci loop adds unnecessary complexity. Action granularity is fine, with one logical operation per line. Reading flow is interrupted by the puzzling loop. The `tag = to_json` alias is a minor redundancy. Overall, the code would be significantly more readable if the Fibonacci calculation were removed or explained, as it currently distracts from the method's actual function.

Run 1

Code Structure: The class and short methods are logically organized, but unused imports and an unrelated number-sequence calculation introduce clutter. Nesting: Shallow nesting and a simple comprehension make the code easy to scan. Clarity of intent: Dictionary checking and value tagging are clear, reinforced by the comment, but the unused calculation obscures the serialization method's purpose; JSONTag is also undefined in this snippet. Code length: The functional logic is concise, but the imports and dead calculation unnecessarily lengthen the code. Action granularity: Statements generally perform one action per line, with a conventional dictionary comprehension. Reading flow: Method ordering is natural, but the unexplained calculation interrupts the flow between the serialization comment and return statement.

Run 2

Code Structure: The class and methods are logically organized, but numerous unused imports and an unrelated number-sequence calculation add clutter. Nesting: Minimal nesting makes the code easy to scan; the loop and dictionary comprehension are shallow. Clarity of intent: The dictionary check, comment, and tagging comprehension clearly convey serialization intent, but the unused sequence calculation is unexplained, and JSONTag is not defined or imported in the snippet. Code length: The implementation is short overall, yet the unused imports and calculation unnecessarily lengthen it. Action granularity: Statements generally perform one action per line; the comprehension is compact and understandable. Reading flow: Method order is natural, but the irrelevant loop interrupts the transition from the serialization comment to the return statement.

Run 3

Code Structure: The class and methods are logically organized, but unrelated imports and an unused numerical loop introduce clutter. Nesting: Shallow nesting keeps the code easy to scan. Clarity of intent: Dictionary checking and recursive value tagging are clear, supported by a useful comment; however, the Fibonacci-like calculation has no apparent purpose, and JSONTag is not defined or imported in the snippet. Code length: The implementation is short, but the unused loop and imports unnecessarily lengthen it. Action granularity: Each statement performs one action, and the comprehension expresses a straightforward transformation. Reading flow: Method ordering is natural, but the irrelevant calculation interrupts the flow between the explanatory comment and the return statement.