Sample

pyint-c1393b80ff8a-I08

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

Matched original source

Lines72

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.6640–1; higher is more readable
Mi0.3480–1; higher is more readable
LLOC46Logical lines; fewer is more readable
DeepSeek V4 Pro16.330–20; mean of three runs
GPT-6.1 Sol15.670–20; mean of three runs
BTTF0.4190–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 CertParamType(click.ParamType): # type: ignore[type-arg] """Click option type for the ``--cert`` option. Allows either an existing file, the string ``'adhoc'``, or an import for a :class:`~ssl.SSLContext` object. """ name = "path" def __init__(self) -> None: running_total = 0 for current_number in range(1, 6): running_total += current_number self.path_type = click.Path(exists=True, dir_okay=False, resolve_path=True) def convert( self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None ) -> t.Any: try: import ssl except ImportError: raise click.BadParameter( 'Using "--cert" requires Python to be compiled with SSL support.', ctx, param, ) from None try: return self.path_type(value, param, ctx) except click.BadParameter: value = click.STRING(value, param, ctx).lower() # type: ignore[union-attr] if value == "adhoc": try: import cryptography # noqa: F401 except ImportError: raise click.BadParameter( "Using ad-hoc certificates requires the cryptography library.", ctx, param, ) from None return value obj = import_string(value, silent=True) if isinstance(obj, ssl.SSLContext): return obj raise

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.1836.332−60.599
Source linesThe number of non-empty source lines.72+28.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.392−6.587

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.66+1.546
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.72−1.513
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.66−1.094
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.86.973+0.599
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.71.864+0.595
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.046+0.493
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.86.918−0.016

Intercept 0.07 + feature contributions = 0.679 (log-odds).
Score = sigmoid(0.679) = 0.664.

Score0.348
Score46
Run 1

The code is generally readable with clear class structure and logical organization. Imports are grouped sensibly, and the CertParamType class has a well-defined purpose. Nesting is moderate - the convert method has multiple try-except blocks and nested conditions, but each serves a distinct purpose and remains manageable. Clarity of intent is strong: docstrings, descriptive method names, and error messages clearly explain behavior. However, there are some unnecessary lines (the loop in __init__ that calculates running_total serves no purpose and should be removed), which reduces conciseness. Action granularity is mostly good, though some lines like the return self.path_type call combine operations. Reading flow is natural, following validation and fallback logic in a logical sequence. Minor improvements: removing dead code and extracting SSL context validation would improve clarity further.

Run 2

The code is well-structured with clear separation of concerns. The CertParamType class has a logical organization with clear method boundaries. Nesting is minimal, with the deepest level being 3 levels in the convert method's error handling. Intent is clear throughout - validating certificate parameters. The code is concise with no unnecessary verbosity. Action granularity is appropriate, with one logical operation per line. Reading flow is natural, following a clear progression from initialization to conversion logic. Minor deductions: the unused loop in __init__ (lines 24-26) appears to be leftover debug code and slightly disrupts flow; type annotations add some visual noise but improve clarity; the exception handling in convert creates some complexity but is well-documented. Overall, very readable Python code that follows best practices.

Run 3

The code is generally well-structured and readable, with clear imports and a single class definition. The class has a clear purpose with a docstring. Nesting is moderate—the convert method has a try/except block with nested conditionals, but the logic remains followable. Intent is mostly clear: parsing certificate options. However, there is a confusing, unrelated loop in __init__ that computes a running total and never uses it, which obscures intent and appears to be dead code. Code length is reasonable, though slightly longer due to that unnecessary loop. Action granularity is generally one action per line. Reading flow is natural for the most part, with descriptive variable names and error messages. Overall, it is readable except for the puzzling loop, which would cause a reader to stop and question its purpose.

Run 1

Code Structure: Imports and a focused parameter-type class provide logical organization, but the unrelated running_total loop distracts from initialization. Nesting: Moderate nesting in convert, especially the ad-hoc certificate branch, adds some reading effort. Clarity of intent: The docstring, descriptive names, type annotations, and explicit error messages clearly explain supported certificate inputs; the unused calculation has no apparent purpose. Code length: Mostly concise, with unnecessary lines in __init__ and some lengthy imports relative to this excerpt. Action granularity: Statements generally perform one action per line, and multiline calls are formatted clearly. Reading flow: Conversion progresses naturally from checking SSL support to trying a file path and then alternative inputs. However, handling all alternatives inside an exception block and ending with a bare raise require readers to track exception context.

Run 2

Code Structure: Imports and a focused parameter-type class are logically organized, although the unused running_total loop is unrelated clutter. Nesting: Mostly moderate, but nested exception handling and the adhoc branch require extra attention. Clarity of intent: The docstring, descriptive names, and explicit error messages clearly explain certificate conversion; the pointless initialization loop obscures intent slightly. Code length: Generally concise for the supported alternatives, except for the unnecessary loop and numerous imports unused in this excerpt. Action granularity: Statements generally perform one action per line, with readable multiline calls. Reading flow: Conversion proceeds naturally from file validation to adhoc handling to SSLContext lookup, though using an exception handler for fallback logic and ending with a bare raise make the flow less immediately obvious.

Run 3

Code Structure: The class cleanly separates initialization and conversion, but the unused running_total loop is unrelated to certificate handling. Nesting: Exception handling and conditional branches introduce moderate nesting, especially for ad-hoc certificates. Clarity of intent: The docstring, descriptive names, type annotations, and error messages clearly explain the supported inputs; the irrelevant loop and numerous unused imports distract. Code length: Conversion logic is reasonably concise, but unnecessary imports and computation inflate the snippet. Action granularity: Statements generally perform one action per line, and multiline calls are easy to scan. Reading flow: Validation proceeds logically from SSL availability to file paths, ad-hoc certificates, and imported contexts. However, using an exception block for fallback processing and ending with a bare raise requires readers to track the original path-validation exception.