Sample

pyint-b29f41d36c46-I10

Deterministically remove some optional blank lines and bracketed line breaks

Matched original source

Lines23

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7770–1; higher is more readable
Mi0.3690–1; higher is more readable
LLOC18Logical lines; fewer is more readable
DeepSeek V4 Pro160–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.4850–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. 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.712.555−23.514
Source linesThe number of non-empty source lines.23+9.2
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.725−7.088

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.76.458+0.429
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.917+0.407
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.064+0.319
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.24+0.187
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.22.756−0.092
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.21−0.061
Indentation frequencyHow rapidly indentation changes from line to line.21−0.011

Intercept 0.07 + feature contributions = 1.248 (log-odds).
Score = sigmoid(1.248) = 0.777.

Score0.369
Score18
Run 1

The code is clean, focused, and highly readable. It uses clear imports, a minimal class with __slots__ for memory efficiency, and a single-purpose 'check' method with an obvious isinstance check. The 'to_json' method is concise and uses a clear dictionary comprehension, with an explanatory comment about JSON key constraints. The alias 'tag = to_json' is a small but acceptable pattern, though it adds slight indirection. Overall, structure, nesting, intent, length, granularity, and flow are all strong.

Run 2

The code is generally readable and well-structured. It uses clear type hints, a logical class definition, and follows a flat structure with minimal nesting. The 'check' and 'to_json' methods have single responsibilities and clear intent. The alias 'tag = to_json' is slightly ambiguous at first glance but likely serves a framework convention. One minor weakness: 'PassDict' could use a docstring, and the import block is longer than necessary for the shown code, making it feel somewhat top-heavy. Overall, the code is concise and readable.

Run 3

The code is fairly readable but has some issues. It imports only necessary modules and defines a clear class with a single responsibility. The use of type hints and __slots__ is good practice. Methods are short and focused. However, the class name 'PassDict' is confusing—it suggests a dictionary that passes something, but it actually handles JSON tagging for dicts. The 'check' method is fine, but 'to_json' and 'tag' being aliases is slightly redundant and could confuse readers about which to call. The list comprehension in 'to_json' is compact but may be slightly dense for newcomers. The comment explains a key limitation but could be clearer about why keys aren't tagged. Overall, the structure is logical and flat, but clarity of intent suffers from naming and the dual method alias.

Run 1

Code Structure: The class is logically organized into a type check and a serialization method, although numerous unused imports add clutter and JSONTag is not defined in the snippet. Nesting: Minimal nesting makes the code easy to follow. Clarity of intent: Descriptive method names and the comment explain dictionary handling, though the tag alias and serializer dependency require surrounding context. Code length: The implementation is concise, but the import section is disproportionately long for the functionality shown. Action granularity: Each statement performs a focused action; the dictionary comprehension expresses a straightforward transformation compactly. Reading flow: The progression from imports to class methods is natural, but missing blank lines before the class and before the tag alias slightly reduce visual separation.

Run 2

Code Structure: The class cleanly groups dictionary detection and serialization, although numerous unused imports add clutter and JSONTag is not defined or imported in the snippet. Nesting: Minimal nesting; the dictionary comprehension is straightforward. Clarity of intent: Method names, type annotations, and the comment clearly explain dictionary handling, though the tag alias and serializer dependency require external context. Code length: The implementation is concise, but the import section is disproportionate to the shown functionality. Action granularity: Each statement performs one clear action; the comprehension compactly expresses a single transformation. Reading flow: Imports lead naturally into the class and its methods, but additional spacing before the class and tag alias would improve visual separation.

Run 3

Code Structure: Imports and a small class are logically organized, though many imports are unused in this snippet and JSONTag is not defined here. Nesting: Methods are flat, with a straightforward dictionary comprehension. Clarity of intent: Method names, type hints, and the comment clearly convey dictionary detection and recursive value tagging; the tag alias is less immediately obvious. Code length: The implementation is concise, although unused imports add clutter. Action granularity: Each statement performs one clear action; the comprehension remains easy to understand. Reading flow: The class reads naturally from validation to conversion, but additional spacing before the class and before the tag alias would improve visual separation.