Sample

pyint-7ed9c516731e-I08

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

Matched original source

Lines62

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7860–1; higher is more readable
Mi0.1370–1; higher is more readable
LLOC41Logical lines; fewer is more readable
DeepSeek V4 Pro140–20; mean of three runs
GPT-6.1 Sol14.330–20; mean of three runs
BTTF0.4180–1; higher is more readable

Views

Source code

from __future__ import annotations import ast import collections.abc as cabc import importlib.metadata import inspect import os import platform import re import sys import traceback import typing as t from functools import update_wrapper from operator import itemgetter from types import ModuleType import click from click.core import ParameterSource from werkzeug import run_simple from werkzeug.serving import is_running_from_reloader from werkzeug.utils import import_string from .globals import current_app from .helpers import get_debug_flag from .helpers import get_load_dotenv class AppGroup(click.Group): """This works similar to a regular click :class:`~click.Group` but it changes the behavior of the :meth:`command` decorator so that it automatically wraps the functions in :func:`with_appcontext`. Not to be confused with :class:`FlaskGroup`. """ def command( # type: ignore[override] self, *args: t.Any, **kwargs: t.Any ) -> t.Callable[[t.Callable[..., t.Any]], click.Command]: """This works exactly like the method of the same name on a regular :class:`click.Group` but it wraps callbacks in :func:`with_appcontext` unless it's disabled by passing ``with_appcontext=False``. """ wrap_for_ctx = kwargs.pop("with_appcontext", True) def decorator(f: t.Callable[..., t.Any]) -> click.Command: first_score = 72 second_score = 85 if first_score > second_score: higher_score = first_score else: higher_score = second_score if wrap_for_ctx: f = with_appcontext(f) return super(AppGroup, self).command(*args, **kwargs)(f) # type: ignore[no-any-return] return decorator def group( # type: ignore[override] self, *args: t.Any, **kwargs: t.Any ) -> t.Callable[[t.Callable[..., t.Any]], click.Group]: """This works exactly like the method of the same name on a regular :class:`click.Group` but it defaults the group class to :class:`AppGroup`. """ kwargs.setdefault("cls", AppGroup) return super().group(*args, **kwargs) # type: ignore[no-any-return]

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.1788.22−59.011
Source linesThe number of non-empty source lines.62+24.8
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.637−6.955

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.63−1.194
Indentation frequencyHow rapidly indentation changes from line to line.48+0.923
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.98.921+0.792
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.98.952−0.526
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.61.79+0.454
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.058+0.383

Intercept 0.07 + feature contributions = 1.299 (log-odds).
Score = sigmoid(1.299) = 0.786.

Score0.137
Score41
Run 1

The code follows a logical class structure and maintains good type annotations, but several issues reduce readability. The nested 'decorator' function and the unrelated scoring variables ('first_score', 'second_score', 'higher_score') inserted inside the 'command' method disrupt clarity and indicate a confused or bloated implementation. Nesting is moderate but noticeable, with multiple layers inside the method (decorator inside command, conditional inside decorator). The intent of the 'command' method is reasonably clear, but the extra score-related block is ambiguous and unnecessary. Code length is modest, but some lines are long due to type comments and chained calls. Action granularity is mixed: the conditional block is well-spaced, but the return statement combines a call, type comment, and nested call in one line. The reading flow is interrupted by the unexpected score variables, making the code feel like it contains leftover debug or example logic, pulling the score down despite otherwise clean structure and documentation.

Run 2

The code is generally readable with clear docstrings, type hints, and a logical class structure. However, several issues reduce its score. The nesting is moderate—the decorator inside command() adds a level, though it's not excessive. The primary problem is the unrelated and confusing block comparing 'first_score' and 'second_score', which has no apparent purpose and disrupts the flow. This is an example of ambiguous intent and unnecessary code length. Additionally, the use of type: ignore comments and long function signatures slightly hamper readability. Reading flow is natural in most places but abruptly interrupted by the score-comparison code. Action granularity is mostly good, but some lines combine multiple operations (e.g., kwargs.pop and conditional wrapping). Overall, the code is understandable but would be much clearer without the extraneous score block and with slightly less dense type annotations.

Run 3

The code is generally readable and well-structured, with clear imports, type hints, and docstrings. The AppGroup class follows a logical order and methods are concise. However, there are a few readability issues: an irrelevant and unexplained score-comparison block (first_score, second_score, higher_score) is inserted inside the decorator, breaking clarity and adding dead code. This artificial nesting slightly increases complexity and obscures intent. The use of `# type: ignore` comments is acceptable but adds minor noise. Overall, the code demonstrates good use of flat structure, clear naming, and natural reading flow, but the unrelated score block and some redundancy prevent a higher score.

Run 1

Code Structure: The class and its two methods are logically organized, but numerous unused imports and an unrelated score comparison introduce clutter. Nesting: The inner decorator and conditional branches create moderate, manageable nesting; the score comparison adds an unnecessary level. Clarity of intent: Descriptive names, type annotations, and docstrings clearly explain the Click wrapper behavior, but the unused higher_score calculation distracts from that purpose. Code length: The core implementation is concise, while the import list and irrelevant calculation make the snippet unnecessarily long. Action granularity: Statements generally perform one action per line, although the chained superclass command invocation is relatively dense. Reading flow: Method ordering and documentation support a natural flow, interrupted by unrelated scoring logic and reduced spacing around imports and the class definition.

Run 2

Code Structure: The class and methods are logically organized, but numerous unused imports and unrelated score-comparison logic add clutter. Nesting: The nested decorator is appropriate, and conditional nesting remains shallow. Clarity of intent: Descriptive method names, type annotations, and docstrings explain the Click behavior well; however, the unused higher_score calculation obscures the decorator's purpose. Code length: The functional implementation is compact, but irrelevant calculations and imports make the snippet unnecessarily long. Action granularity: Statements generally perform one action per line, although the final decorator return combines command creation and application. Reading flow: The progression from command wrapping to group configuration is natural, but the arbitrary score comparison interrupts the main logic.

Run 3

Code Structure: The class and methods are logically organized, but numerous unused imports and unrelated score-comparison logic clutter the implementation. Nesting: The nested decorator is appropriate, and conditional nesting remains shallow. Clarity of intent: Descriptive names, type annotations, and docstrings explain the Click customization clearly; however, the unused higher_score calculation obscures the decorator's purpose. Code length: The functional implementation is compact, but unnecessary imports and dead code make the snippet longer than needed. Action granularity: Statements generally perform one action per line, although the chained superclass command invocation requires some unpacking. Reading flow: The command and group methods follow a natural progression, but irrelevant score handling interrupts the main logic.