Sample

pyint-a61a3782232b-I01

Remove comments and docstrings

Matched original source

Lines395

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.9920–1; higher is more readable
Mi0.5070–1; higher is more readable
LLOC135Logical lines; fewer is more readable
DeepSeek V4 Pro14.330–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.4610–1; higher is more readable

Views

Source code

from __future__ import annotations import importlib.util import os import pathlib import sys import typing as t from collections import defaultdict from functools import update_wrapper from jinja2 import BaseLoader from jinja2 import FileSystemLoader from werkzeug.exceptions import default_exceptions from werkzeug.exceptions import HTTPException from werkzeug.utils import cached_property from .. import typing as ft from ..helpers import get_root_path from ..templating import _default_template_ctx_processor class Scaffold: cli: Group name: str _static_folder: str | None = None _static_url_path: str | None = None def __init__( self, import_name: str, static_folder: str | os.PathLike[str] | None = None, static_url_path: str | None = None, template_folder: str | os.PathLike[str] | None = None, root_path: str | None = None, ): self.import_name = import_name self.static_folder = static_folder self.static_url_path = static_url_path self.template_folder = template_folder if root_path is None: root_path = get_root_path(self.import_name) self.root_path = root_path self.view_functions: dict[str, ft.RouteCallable] = {} self.error_handler_spec: dict[ ft.AppOrBlueprintKey, dict[int | None, dict[type[Exception], ft.ErrorHandlerCallable]], ] = defaultdict(lambda: defaultdict(dict)) self.before_request_funcs: dict[ ft.AppOrBlueprintKey, list[ft.BeforeRequestCallable] ] = defaultdict(list) self.after_request_funcs: dict[ ft.AppOrBlueprintKey, list[ft.AfterRequestCallable[t.Any]] ] = defaultdict(list) self.teardown_request_funcs: dict[ ft.AppOrBlueprintKey, list[ft.TeardownCallable] ] = defaultdict(list) self.template_context_processors: dict[ ft.AppOrBlueprintKey, list[ft.TemplateContextProcessorCallable] ] = defaultdict(list, {None: [_default_template_ctx_processor]}) self.url_value_preprocessors: dict[ ft.AppOrBlueprintKey, list[ft.URLValuePreprocessorCallable], ] = defaultdict(list) self.url_default_functions: dict[ ft.AppOrBlueprintKey, list[ft.URLDefaultCallable] ] = defaultdict(list) def __repr__(self) -> str: return f"<{type(self).__name__} {self.name!r}>" def _check_setup_finished(self, f_name: str) -> None: raise NotImplementedError @property def static_folder(self) -> str | None: if self._static_folder is not None: return os.path.join(self.root_path, self._static_folder) else: return None @static_folder.setter def static_folder(self, value: str | os.PathLike[str] | None) -> None: if value is not None: value = os.fspath(value).rstrip(r"\/") self._static_folder = value @property def has_static_folder(self) -> bool: return self.static_folder is not None @property def static_url_path(self) -> str | None: if self._static_url_path is not None: return self._static_url_path if self.static_folder is not None: basename = os.path.basename(self.static_folder) return f"/{basename}".rstrip("/") return None @static_url_path.setter def static_url_path(self, value: str | None) -> None: if value is not None: value = value.rstrip("/") self._static_url_path = value @cached_property def jinja_loader(self) -> BaseLoader | None: if self.template_folder is not None: return FileSystemLoader(os.path.join(self.root_path, self.template_folder)) else: return None def _method_route( self, method: str, rule: str, options: dict[str, t.Any], ) -> t.Callable[[T_route], T_route]: if "methods" in options: raise TypeError("Use the 'route' decorator to use the 'methods' argument.") return self.route(rule, methods=[method], **options) @setupmethod def get(self, rule: str, **options: t.Any) -> t.Callable[[T_route], T_route]: return self._method_route("GET", rule, options) @setupmethod def query(self, rule: str, **options: t.Any) -> t.Callable[[T_route], T_route]: return self._method_route("QUERY", rule, options) @setupmethod def post(self, rule: str, **options: t.Any) -> t.Callable[[T_route], T_route]: return self._method_route("POST", rule, options) @setupmethod def put(self, rule: str, **options: t.Any) -> t.Callable[[T_route], T_route]: return self._method_route("PUT", rule, options) @setupmethod def delete(self, rule: str, **options: t.Any) -> t.Callable[[T_route], T_route]: return self._method_route("DELETE", rule, options) @setupmethod def patch(self, rule: str, **options: t.Any) -> t.Callable[[T_route], T_route]: return self._method_route("PATCH", rule, options) @setupmethod def route(self, rule: str, **options: t.Any) -> t.Callable[[T_route], T_route]: def decorator(f: T_route) -> T_route: endpoint = options.pop("endpoint", None) self.add_url_rule(rule, endpoint, f, **options) return f return decorator @setupmethod def add_url_rule( self, rule: str, endpoint: str | None = None, view_func: ft.RouteCallable | None = None, provide_automatic_options: bool | None = None, **options: t.Any, ) -> None: raise NotImplementedError @setupmethod def endpoint(self, endpoint: str) -> t.Callable[[F], F]: def decorator(f: F) -> F: self.view_functions[endpoint] = f return f return decorator @setupmethod def before_request(self, f: T_before_request) -> T_before_request: self.before_request_funcs.setdefault(None, []).append(f) return f @setupmethod def after_request(self, f: T_after_request) -> T_after_request: self.after_request_funcs.setdefault(None, []).append(f) return f @setupmethod def teardown_request(self, f: T_teardown) -> T_teardown: self.teardown_request_funcs.setdefault(None, []).append(f) return f @setupmethod def context_processor( self, f: T_template_context_processor, ) -> T_template_context_processor: self.template_context_processors[None].append(f) return f @setupmethod def url_value_preprocessor( self, f: T_url_value_preprocessor, ) -> T_url_value_preprocessor: self.url_value_preprocessors[None].append(f) return f @setupmethod def url_defaults(self, f: T_url_defaults) -> T_url_defaults: self.url_default_functions[None].append(f) return f @setupmethod def errorhandler( self, code_or_exception: type[Exception] | int ) -> t.Callable[[T_error_handler], T_error_handler]: def decorator(f: T_error_handler) -> T_error_handler: self.register_error_handler(code_or_exception, f) return f return decorator @setupmethod def register_error_handler( self, code_or_exception: type[Exception] | int, f: ft.ErrorHandlerCallable, ) -> None: exc_class, code = self._get_exc_class_and_code(code_or_exception) self.error_handler_spec[None][code][exc_class] = f @staticmethod def _get_exc_class_and_code( exc_class_or_code: type[Exception] | int, ) -> tuple[type[Exception], int | None]: exc_class: type[Exception] if isinstance(exc_class_or_code, int): try: exc_class = default_exceptions[exc_class_or_code] except KeyError: raise ValueError( f"'{exc_class_or_code}' is not a recognized HTTP" " error code. Use a subclass of HTTPException with" " that code instead." ) from None else: exc_class = exc_class_or_code if isinstance(exc_class, Exception): raise TypeError( f"{exc_class!r} is an instance, not a class. Handlers" " can only be registered for Exception classes or HTTP" " error codes." ) if not issubclass(exc_class, Exception): raise ValueError( f"'{exc_class.__name__}' is not a subclass of Exception." " Handlers can only be registered for Exception classes" " or HTTP error codes." ) if issubclass(exc_class, HTTPException): return exc_class, exc_class.code else: return exc_class, None

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.11428.291−377.134
Source linesThe number of non-empty source lines.395+158
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.247−6.371

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.396−12.985
Indentation frequencyHow rapidly indentation changes from line to line.395+12.925
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.394.932+5.111
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
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.088+0.086
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.975−0.019

Intercept 0.07 + feature contributions = 4.782 (log-odds).
Score = sigmoid(4.782) = 0.992.

Score0.507
Score135
Run 1

The code has a clear class structure and uses type hints extensively, which aids comprehension. However, the __init__ method contains excessive comment blocks that are mostly empty placeholders, creating visual noise and making the method appear longer than necessary. The dictionary type annotations for error_handler_spec and similar attributes are complex and span many lines, reducing readability. The nesting level is low, which is positive, but the import section is somewhat disorganized with duplicated imports from jinja2 and werkzeug.exceptions. The method naming and decorator patterns are consistent, showing good intent clarity. Action granularity is mostly one action per line, though some dictionary annotations could be broken down further. The reading flow is acceptable but interrupted by the numerous empty comment blocks. Overall, the code is maintainable but could be improved by removing placeholder comments, consolidating imports, and potentially extracting complex type annotations into type aliases for better readability.

Run 2

The code is generally readable but has some issues. Structure and typing are good, making the code clear and maintainable. However, the long type annotations (especially in the `__init__` method) create visual noise and reduce readability. There are many empty comment blocks (e.g., `#`) which add clutter without providing useful information. The nesting level is low, and methods are broken down into small, single-purpose units, which improves clarity and action granularity. The reading flow is natural, but the verbose type definitions and repetitive structure of the route methods (get, post, put, delete, etc.) could be condensed. Overall, it is readable but would benefit from simplified type annotations and removal of empty comments.

Run 3

The code has clear structure with logical grouping of related methods and consistent naming. However, readability is hurt by excessive comments—many blank inline comments replace documentation where meaningful docstrings should exist. Some type annotations are very long, adding visual noise. Nesting is generally flat, which is good, but the number of similar registration methods makes the class feel verbose. Action granularity is mostly one action per line, but the long type annotations reduce scanability. Reading flow is moderate: methods follow a predictable order, but the repeating pattern of empty comments and lengthy type hints makes it harder to skim. The code is maintainable for experienced developers but would benefit from cleaner docstrings and less redundant commentary.

Run 1

Code Structure: Related functionality is logically grouped into initialization, properties, routing, lifecycle hooks, and error handling. Nesting: Mostly shallow, with straightforward decorator closures and modest branching in exception validation. Clarity of intent: Descriptive names and type annotations make most operations clear, but missing documentation and externally defined symbols such as setupmethod and T_route reduce standalone comprehensibility. Code length: Individual methods are concise, but excessive blank lines greatly inflate the snippet and repeated routing wrappers add some verbosity. Action granularity: Statements generally perform one action per line; chained registry updates remain understandable. Reading flow: Consistent method patterns and logical ordering support navigation, but large whitespace gaps, complex registry annotations, and unexplained dependencies interrupt otherwise natural reading.

Run 2

Code Structure: Methods are logically grouped around configuration, routing, request hooks, and error handling, with shared behavior extracted into helpers. Nesting: Mostly flat; decorators and exception handling introduce only shallow nesting. Clarity of intent: Descriptive names and type annotations make most operations clear, but missing documentation and undefined names such as setupmethod, Group, and type variables reduce standalone comprehension. Code length: Individual methods are concise, but excessive blank lines substantially inflate the listing; repeated convenience methods add some length while keeping the API explicit. Action granularity: Statements generally perform one action per line, and chained registration operations remain understandable. Reading flow: Consistent method patterns support predictable reading, but large whitespace gaps interrupt continuity, and some dense nested type annotations require extra attention.

Run 3

Code Structure: Methods are logically grouped around configuration, routing, request hooks, and error handling, with shared helpers reducing duplication. Nesting: Mostly flat, with modest nesting for decorators and exception validation. Clarity of intent: Descriptive names and type annotations communicate purpose well, but missing definitions such as setupmethod and generic type variables, plus absent documentation, limit standalone understanding. Code length: Individual methods are concise, but excessive blank lines substantially inflate the snippet and repetitive route wrappers add length. Action granularity: Statements generally perform one clear action per line; chained registry operations remain understandable. Reading flow: Method ordering and consistent patterns support natural reading, but large whitespace gaps repeatedly interrupt it. Overall, the implementation is reasonably readable despite distracting formatting and incomplete context.