Sample

pyint-8849942bfe3f-I04

Replace names with deterministic minifier-style shortest identifiers

Matched original source

Lines585

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.9050–1; higher is more readable
Mi0.3190–1; higher is more readable
LLOC204Logical lines; fewer is more readable
DeepSeek V4 Pro4.330–20; mean of three runs
GPT-6.1 Sol90–20; mean of three runs
BTTF0.110–1; higher is more readable

Views

Source code

from __future__ import annotations import os import typing as t from collections import defaultdict from functools import update_wrapper from .. import typing as ft from .scaffold import _endpoint_from_view_func from .scaffold import _sentinel from .scaffold import Scaffold from .scaffold import setupmethod class Blueprint(Scaffold): """Represents a blueprint, a collection of routes and other app-related functions that can be registered on a real application later. A blueprint is an object that allows defining application functions without requiring an application object ahead of time. It uses the same decorators as :class:`~flask.Flask`, but defers the need for an application by recording them for later registration. Decorating a function with a blueprint creates a deferred function that is called with :class:`~flask.blueprints.BlueprintSetupState` when the blueprint is registered on an application. See :doc:`/blueprints` for more information. :param name: The name of the blueprint. Will be prepended to each endpoint name. :param import_name: The name of the blueprint package, usually ``__name__``. This helps locate the ``root_path`` for the blueprint. :param static_folder: A folder with static files that should be served by the blueprint's static route. The path is relative to the blueprint's root path. Blueprint static files are disabled by default. :param static_url_path: The url to serve static files from. Defaults to ``static_folder``. If the blueprint does not have a ``url_prefix``, the app's static route will take precedence, and the blueprint's static files won't be accessible. :param template_folder: A folder with templates that should be added to the app's template search path. The path is relative to the blueprint's root path. Blueprint templates are disabled by default. Blueprint templates have a lower precedence than those in the app's templates folder. :param url_prefix: A path to prepend to all of the blueprint's URLs, to make them distinct from the rest of the app's routes. :param subdomain: A subdomain that blueprint routes will match on by default. :param url_defaults: A dict of default values that blueprint routes will receive by default. :param root_path: By default, the blueprint will automatically set this based on ``import_name``. In certain situations this automatic detection can fail, so the path can be specified manually instead. .. versionchanged:: 1.1.0 Blueprints have a ``cli`` group to register nested CLI commands. The ``cli_group`` parameter controls the name of the group under the ``flask`` command. .. versionadded:: 0.7 """ _got_registered_once = False def __init__( self, E: str, F: str, G: str | os.PathLike[str] | None = None, H: str | None = None, I: str | os.PathLike[str] | None = None, J: str | None = None, K: str | None = None, L: dict[str, t.Any] | None = None, M: str | None = None, N: str | None = _sentinel, # type: ignore[assignment] ): super().__init__( import_name=F, static_folder=G, static_url_path=H, template_folder=I, root_path=M, ) if not E: raise ValueError("'name' may not be empty.") if "." in E: raise ValueError("'name' may not contain a dot '.' character.") self.name = E self.url_prefix = J self.subdomain = K self.deferred_functions: list[DeferredSetupFunction] = [] if L is None: L = {} self.url_values_defaults = L self.cli_group = N self._blueprints: list[tuple[Blueprint, dict[str, t.Any]]] = [] def a(self, O: str) -> None: if self._got_registered_once: raise AssertionError( f"The setup method '{O}' can no longer be called on the blueprint" f" '{self.name}'. It has already been registered at least once, any" " changes will not be applied consistently.\n" "Make sure all imports, decorators, functions, etc. needed to set up" " the blueprint are done before registering it." ) @setupmethod def b(self, P: DeferredSetupFunction) -> None: """Registers a function that is called when the blueprint is registered on the application. This function is called with the state as argument as returned by the :meth:`make_setup_state` method. """ self.deferred_functions.append(P) @setupmethod def c(self, Q: DeferredSetupFunction) -> None: """Works like :meth:`record` but wraps the function in another function that will ensure the function is only called once. If the blueprint is registered a second time on the application, the function passed is not called. """ def wrapper(R: BlueprintSetupState) -> None: if R.first_registration: func(R) self.b(update_wrapper(wrapper, Q)) def d( self, S: App, T: dict[str, t.Any], U: bool = False ) -> BlueprintSetupState: """Creates an instance of :meth:`~flask.blueprints.BlueprintSetupState` object that is later passed to the register callback functions. Subclasses can override this to return a subclass of the setup state. """ return BlueprintSetupState(self, S, T, U) @setupmethod def e(self, V: Blueprint, **W: t.Any) -> None: """Register a :class:`~flask.Blueprint` on this blueprint. Keyword arguments passed to this method will override the defaults set on the blueprint. .. versionchanged:: 2.0.1 The ``name`` option can be used to change the (pre-dotted) name the blueprint is registered with. This allows the same blueprint to be registered multiple times with unique names for ``url_for``. .. versionadded:: 2.0 """ if V is self: raise ValueError("Cannot register a blueprint on itself") self._blueprints.append((V, W)) def g(self, X: App, Y: dict[str, t.Any]) -> None: """Called by :meth:`Flask.register_blueprint` to register all views and callbacks registered on the blueprint with the application. Creates a :class:`.BlueprintSetupState` and calls each :meth:`record` callback with it. :param app: The application this blueprint is being registered with. :param options: Keyword arguments forwarded from :meth:`~Flask.register_blueprint`. .. versionchanged:: 2.3 Nested blueprints now correctly apply subdomains. .. versionchanged:: 2.1 Registering the same blueprint with the same name multiple times is an error. .. versionchanged:: 2.0.1 Nested blueprints are registered with their dotted name. This allows different blueprints with the same name to be nested at different locations. .. versionchanged:: 2.0.1 The ``name`` option can be used to change the (pre-dotted) name the blueprint is registered with. This allows the same blueprint to be registered multiple times with unique names for ``url_for``. """ Z = Y.get("name_prefix", "") aa = Y.get("name", self.name) ab = f"{Z}.{aa}".lstrip(".") if ab in X.blueprints: ac = "this" if X.blueprints[ab] is self else "a different" ad = f" '{ab}'" if aa != ab else "" raise ValueError( f"The name '{aa}' is already registered for" f" {ac} blueprint{ad}. Use 'name=' to" f" provide a unique name." ) ae = not any(af is self for af in X.blueprints.values()) ag = ab not in X.blueprints X.blueprints[ab] = self self._got_registered_once = True ah = self.d(X, Y, ae) if self.has_static_folder: ah.add_url_rule( f"{self.static_url_path}/<path:filename>", view_func=self.send_static_file, # type: ignore[attr-defined] endpoint="static", ) # Merge blueprint data into parent. if ae or ag: self.h(X, ab) for ai in self.deferred_functions: ai(ah) aj = Y.get("cli_group", self.cli_group) if self.cli.commands: if aj is None: X.cli.commands.update(self.cli.commands) elif aj is _sentinel: self.cli.name = ab X.cli.add_command(self.cli) else: self.cli.name = aj X.cli.add_command(self.cli) for ak, al in self._blueprints: al = al.copy() am = al.get("url_prefix") an = al.get("subdomain") if an is None: an = ak.subdomain if ah.subdomain is not None and an is not None: al["subdomain"] = an + "." + ah.subdomain elif an is not None: al["subdomain"] = an elif ah.subdomain is not None: al["subdomain"] = ah.subdomain if am is None: am = ak.url_prefix if ah.url_prefix is not None and am is not None: al["url_prefix"] = ( ah.url_prefix.rstrip("/") + "/" + am.lstrip("/") ) elif am is not None: al["url_prefix"] = am elif ah.url_prefix is not None: al["url_prefix"] = ah.url_prefix al["name_prefix"] = ab ak.register(X, al) def h(self, ao: App, ap: str) -> None: def extend( ay: dict[ft.AppOrBlueprintKey, list[t.Any]], az: dict[ft.AppOrBlueprintKey, list[t.Any]], ) -> None: for aA, aB in ay.items(): aA = name if aA is None else f"{name}.{aA}" az[aA].extend(aB) for aq, ar in self.error_handler_spec.items(): aq = ap if aq is None else f"{ap}.{aq}" ar = defaultdict( dict, { au: {at: ax for at, ax in av.items()} for au, av in ar.items() }, ) ao.error_handler_spec[aq] = ar for aw, ax in self.view_functions.items(): ao.view_functions[aw] = ax extend(self.before_request_funcs, ao.before_request_funcs) extend(self.after_request_funcs, ao.after_request_funcs) extend( self.teardown_request_funcs, ao.teardown_request_funcs, ) extend(self.url_default_functions, ao.url_default_functions) extend(self.url_value_preprocessors, ao.url_value_preprocessors) extend(self.template_context_processors, ao.template_context_processors) @setupmethod def i( self, aC: str, aD: str | None = None, aE: ft.RouteCallable | None = None, aF: bool | None = None, **aG: t.Any, ) -> None: """Register a URL rule with the blueprint. See :meth:`.Flask.add_url_rule` for full documentation. The URL rule is prefixed with the blueprint's URL prefix. The endpoint name, used with :func:`url_for`, is prefixed with the blueprint's name. """ if aD and "." in aD: raise ValueError("'endpoint' may not contain a dot '.' character.") if aE and hasattr(aE, "__name__") and "." in aE.__name__: raise ValueError("'view_func' name may not contain a dot '.' character.") self.b( lambda s: s.add_url_rule( aC, aD, aE, provide_automatic_options=aF, **aG, ) ) @t.overload def l(self, aH: T_template_filter) -> T_template_filter: ... @t.overload def l( self, aI: str | None = None ) -> t.Callable[[T_template_filter], T_template_filter]: ... @setupmethod def l( self, aJ: T_template_filter | str | None = None ) -> T_template_filter | t.Callable[[T_template_filter], T_template_filter]: """Decorate a function to register it as a custom Jinja filter. The name is optional. The decorator may be used without parentheses. The :meth:`add_app_template_filter` method may be used to register a function later rather than decorating. The filter is available in all templates, not only those under this blueprint. Equivalent to :meth:`.Flask.template_filter`. :param name: The name to register the filter as. If not given, uses the function's name. """ if callable(aJ): self.m(aJ) return aJ def decorator(aK: T_template_filter) -> T_template_filter: self.m(aK, name=name) return aK return decorator @setupmethod def m( self, aL: ft.TemplateFilterCallable, aM: str | None = None ) -> None: """Register a function to use as a custom Jinja filter. The :meth:`app_template_filter` decorator can be used to register a function by decorating instead. The filter is available in all templates, not only those under this blueprint. Equivalent to :meth:`.Flask.add_template_filter`. :param f: The function to register. :param name: The name to register the filter as. If not given, uses the function's name. """ def register_template_filter(aN: BlueprintSetupState) -> None: aN.app.add_template_filter(f, name=name) self.c(register_template_filter) @t.overload def p(self, aO: T_template_test) -> T_template_test: ... @t.overload def p( self, aP: str | None = None ) -> t.Callable[[T_template_test], T_template_test]: ... @setupmethod def p( self, aQ: T_template_test | str | None = None ) -> T_template_test | t.Callable[[T_template_test], T_template_test]: """Decorate a function to register it as a custom Jinja test. The name is optional. The decorator may be used without parentheses. The :meth:`add_app_template_test` method may be used to register a function later rather than decorating. The test is available in all templates, not only those under this blueprint. Equivalent to :meth:`.Flask.template_test`. :param name: The name to register the filter as. If not given, uses the function's name. .. versionadded:: 0.10 """ if callable(aQ): self.q(aQ) return aQ def decorator(aR: T_template_test) -> T_template_test: self.q(aR, name=name) return aR return decorator @setupmethod def q( self, aS: ft.TemplateTestCallable, aT: str | None = None ) -> None: """Register a function to use as a custom Jinja test. The :meth:`app_template_test` decorator can be used to register a function by decorating instead. The test is available in all templates, not only those under this blueprint. Equivalent to :meth:`.Flask.add_template_test`. :param f: The function to register. :param name: The name to register the test as. If not given, uses the function's name. .. versionadded:: 0.10 """ def register_template_test(aU: BlueprintSetupState) -> None: aU.app.add_template_test(f, name=name) self.c(register_template_test) @t.overload def v(self, aV: T_template_global) -> T_template_global: ... @t.overload def v( self, aW: str | None = None ) -> t.Callable[[T_template_global], T_template_global]: ... @setupmethod def v( self, aX: T_template_global | str | None = None ) -> T_template_global | t.Callable[[T_template_global], T_template_global]: """Decorate a function to register it as a custom Jinja global. The name is optional. The decorator may be used without parentheses. The :meth:`add_app_template_global` method may be used to register a function later rather than decorating. The global is available in all templates, not only those under this blueprint. Equivalent to :meth:`.Flask.template_global`. :param name: The name to register the global as. If not given, uses the function's name. .. versionadded:: 0.10 """ if callable(aX): self.w(aX) return aX def decorator(aY: T_template_global) -> T_template_global: self.w(aY, name=name) return aY return decorator @setupmethod def w( self, aZ: ft.TemplateGlobalCallable, ba: str | None = None ) -> None: """Register a function to use as a custom Jinja global. The :meth:`app_template_global` decorator can be used to register a function by decorating instead. The global is available in all templates, not only those under this blueprint. Equivalent to :meth:`.Flask.add_template_global`. :param f: The function to register. :param name: The name to register the global as. If not given, uses the function's name. .. versionadded:: 0.10 """ def register_template_global(bb: BlueprintSetupState) -> None: bb.app.add_template_global(f, name=name) self.c(register_template_global) @setupmethod def x(self, bc: T_before_request) -> T_before_request: """Like :meth:`before_request`, but before every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.before_request`. """ self.c( lambda s: s.app.before_request_funcs.setdefault(None, []).append(bc) ) return bc @setupmethod def y(self, bd: T_after_request) -> T_after_request: """Like :meth:`after_request`, but after every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.after_request`. """ self.c( lambda s: s.app.after_request_funcs.setdefault(None, []).append(bd) ) return bd @setupmethod def z(self, be: T_teardown) -> T_teardown: """Like :meth:`teardown_request`, but after every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.teardown_request`. """ self.c( lambda s: s.app.teardown_request_funcs.setdefault(None, []).append(be) ) return be @setupmethod def A( self, bf: T_template_context_processor ) -> T_template_context_processor: """Like :meth:`context_processor`, but for templates rendered by every view, not only by the blueprint. Equivalent to :meth:`.Flask.context_processor`. """ self.c( lambda s: s.app.template_context_processors.setdefault(None, []).append(bf) ) return bf @setupmethod def B( self, bg: type[Exception] | int ) -> t.Callable[[T_error_handler], T_error_handler]: """Like :meth:`errorhandler`, but for every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.errorhandler`. """ def decorator(bh: T_error_handler) -> T_error_handler: def from_blueprint(bi: BlueprintSetupState) -> None: bi.app.errorhandler(code)(f) self.c(from_blueprint) return bh return decorator @setupmethod def C( self, bj: T_url_value_preprocessor ) -> T_url_value_preprocessor: """Like :meth:`url_value_preprocessor`, but for every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.url_value_preprocessor`. """ self.c( lambda s: s.app.url_value_preprocessors.setdefault(None, []).append(bj) ) return bj @setupmethod def D(self, bk: T_url_defaults) -> T_url_defaults: """Like :meth:`url_defaults`, but for every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.url_defaults`. """ self.c( lambda s: s.app.url_default_functions.setdefault(None, []).append(bk) ) return bk

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.17157.291−566.191
Source linesThe number of non-empty source lines.585+234
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.393−6.589

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.586−19.712
Indentation frequencyHow rapidly indentation changes from line to line.390+12.753
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.584.921+7.766
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.85.596+0.577
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.05+0.461
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
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.87.961−0.06

Intercept 0.07 + feature contributions = 2.251 (log-odds).
Score = sigmoid(2.251) = 0.905.

Score0.319
Score204
Run 1

The code is virtually unreadable due to systematic replacement of meaningful identifiers with cryptic letters (E, F, G, etc.) for parameters, methods, and local variables. This obliterates clarity of intent and obscures the purpose of every function. The code structure mirrors the original Flask Blueprint class, but the renaming makes it impossible to follow. Nesting is moderate but exacerbated by ambiguous variable names in complex logic. The reading flow is severe: readers must constantly jump between docstrings and implementation to guess what each symbol means. Action granularity is sometimes one action per line, but meaningless names negate that benefit. Code length is acceptable, but conciseness is overshadowed by obfuscation. Overall, this level of renaming renders the code functionally unmaintainable and fails almost every readability criterion.

Run 2

The code has several serious readability issues. Most critically, all meaningful identifiers (parameters, methods, local variables) have been replaced with meaningless names like 'E', 'F', 'G', 'a', 'b', 'h', 'aa', 'ab', etc. This destroys clarity of intent and reading flow despite the original Flask code's good structure. The remaining docstrings provide some context, but they conflict with the obfuscated parameter names. While the original code structure (logical organization into methods, flat nesting, reasonable action granularity) survives, the naming sabotage makes it nearly impossible to understand what each method does without heavy reverse-engineering. Code length is normal for Flask, but the loss of meaningful names makes it seem longer and more complex than it is. Some methods like 'g' and 'h' are still relatively complex with multiple nested loops and conditionals, which would be challenging even with good names. The score reflects that the underlying structure is sound, but the deliberate obfuscation of identifiers renders the code barely readable.

Run 3

This code is extremely difficult to read due to deliberate obfuscation. Meaningful names (e.g., 'name', 'import_name', 'record', 'register') are replaced with single-letter variables (E, F, a, b, c...), making intent unclear and requiring constant cross-referencing. The structure remains logical, and nesting is moderate, but clarity of intent is severely compromised. Action granularity and reading flow are mixed; some lines are concise, while others pack multiple complex operations, and the unnatural naming breaks any natural flow. Although the code is functionally organized, the extensive use of meaningless identifiers collapses the readability score despite preserving the original Flask Blueprint architecture.

Run 1

Code Structure: Methods are logically grouped within a class, with reusable helpers and consistent decorator patterns, although registration combines several responsibilities. Nesting: Mostly shallow, with moderate nesting in registration logic and callback factories. Clarity of intent: Severely weakened by meaningless method and parameter names; docstrings help but reference names absent from the implementation. Unresolved references such as func, name, f, and code further obscure intended data flow. Code length: Extensive documentation and repetitive template-registration methods make the class lengthy, though individual methods are generally concise. Action granularity: Most statements perform one action, but chained calls inside lambdas compress multiple operations. Reading flow: Consistent indentation, annotations, and sequential setup steps support scanning, but opaque identifiers force repeated cross-referencing and prevent natural understanding.

Run 2

Code Structure: Methods separate initialization, registration, and callbacks logically, although registration combines several responsibilities. Nesting: Mostly shallow, with moderate nesting in registration branches and decorator closures. Clarity of intent: Severely weakened by opaque method and parameter names; docstrings help, but reference names that no longer match the code. Unexplained references such as func, name, f, and code further obscure data flow. Code length: Extensive documentation is useful, but repetitive decorator patterns and a long registration method increase reading effort. Action granularity: Generally one action per line, though chained calls, lambdas, and nested comprehensions compress some operations. Reading flow: Consistent indentation, spacing, and type annotations support navigation, but readers must repeatedly infer identifier meanings and reconcile documentation with implementations.

Run 3

Code Structure: Methods logically separate initialization, registration, and callbacks, although the registration method combines several responsibilities. Nesting: Mostly shallow, with moderate nesting in registration branches and decorator closures. Clarity of intent: Severely weakened by opaque method and parameter names such as g, aJ, and bk. Docstrings help, but reference original names that no longer match the code; unresolved references such as func, name, f, and code further obscure intent. Code length: Extensive documentation and repeated decorator patterns make the class lengthy, though most individual methods are concise. Action granularity: Statements generally perform one action per line, but chained calls and lambdas compress some operations. Reading flow: Consistent formatting, type annotations, and logical sequencing support scanning, but readers must repeatedly reconstruct identifier meanings and reconcile documentation with implementation.