Sample

pyint-1f4cd40bab80-I10

Deterministically remove some optional blank lines and bracketed line breaks

Matched original source

Lines23

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8370–1; higher is more readable
Mi0.2790–1; higher is more readable
LLOC18Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.6680–1; higher is more readable

Views

Source code

from __future__ import annotations import typing as t from jinja2 import BaseLoader from jinja2 import Environment as BaseEnvironment from jinja2 import Template from jinja2 import TemplateNotFound from .ctx import AppContext from .globals import app_ctx from .helpers import stream_with_context from .signals import before_render_template from .signals import template_rendered class Environment(BaseEnvironment): """Works like a regular Jinja environment but has some additional knowledge of how Flask's blueprint works so that it can prepend the name of the blueprint to referenced templates if necessary. """ def __init__(self, app: App, **options: t.Any) -> None: if "loader" not in options: options["loader"] = app.create_global_jinja_loader() BaseEnvironment.__init__(self, **options) self.app = app

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.594.341−19.613
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.582−6.872

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

Feature contributions

FeatureValueContribution
(log-odds)
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.70.917+0.661
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.041+0.539
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
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.917−0.09
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.44.417−0.088
Indentation frequencyHow rapidly indentation changes from line to line.20−0.045

Intercept 0.07 + feature contributions = 1.633 (log-odds).
Score = sigmoid(1.633) = 0.837.

Score0.279
Score18
Run 1

The code is well-structured with clear imports, a class definition, and an __init__ method that handles loader setup cleanly. Nesting is minimal; there is only one conditional at a shallow level. Intent is clear from the docstring and method logic—customizing Jinja's environment for Flask blueprints. The length is concise but complete. Action granularity is appropriate: each line performs a single clear action. Reading flow is natural, moving from imports to class definition to method logic. Minor deductions: the conditional could be slightly more explicit about its purpose, and typing could be more specific (e.g., using a protocol for app), but overall readability is high.

Run 2

The code is well-structured and readable. It uses clear imports, a concise docstring explaining the class's purpose, and follows a logical flow in the constructor: it sets a default loader, calls the parent initializer, then stores the app reference. Nesting is minimal (one conditional), clarity of intent is high, and the code is concise without being overly terse. Type hints improve maintainability. Minor deductions: the `BaseEnvironment.__init__` call could use `super().__init__`, and the conditional could be more explicit, but overall it's a clean, natural read.

Run 3

The code is clean, well-structured, and follows common Python and Flask patterns. Imports are grouped and explicit, the class docstring clearly explains its purpose, and the __init__ method is flat with a single conditional that adds a default loader before calling the parent initializer. Naming is clear, type hints improve clarity, and each line performs one logical action. The reading flow is natural: imports, class definition, docstring, then a straightforward constructor. Minor deductions: the conditional could be slightly clearer with a comment, and BaseEnvironment.__init__ style is a bit verbose compared to super().__init__, but these are minor and do not harm readability.

Run 1

Code Structure: Imports and a focused class are logically organized, though several imports are unused in this snippet. Nesting: A single shallow conditional keeps complexity low. Clarity of intent: The docstring and descriptive names explain the Flask-aware environment and loader setup; however, App is not defined or imported here, and blueprint behavior is not visible in the implementation. Code length: The constructor is concise without unnecessary logic. Action granularity: Each statement performs one clear action. Reading flow: Initialization proceeds naturally from supplying a default loader to initializing the base class and storing the app. Additional blank lines between imports and the class would improve visual separation.

Run 2

Code Structure: Imports and a small, focused class are logically organized, though several imports are unused in this snippet. Nesting: A single conditional keeps nesting shallow. Clarity of intent: Descriptive names, type annotations, and the docstring clarify the environment customization; however, the docstring describes blueprint behavior not directly shown, and App is not imported in the snippet. Code length: The implementation is concise without unnecessary logic. Action granularity: Each statement performs one clear action. Reading flow: Initialization proceeds naturally from supplying a default loader to initializing the base environment and storing the application. Additional spacing between imports and the class would improve visual separation.

Run 3

Code Structure: Imports followed by a focused class and initializer provide logical organization, though several imports are unused in this snippet. Nesting: A single conditional keeps nesting shallow. Clarity of intent: Descriptive names, type annotations, and a class docstring communicate purpose, although the blueprint behavior described is not directly visible here and App is not imported. Code length: The implementation is concise without unnecessary logic. Action granularity: Each statement performs one clear action. Reading flow: Initialization proceeds naturally from choosing a default loader to initializing the base environment and storing the app. Additional spacing between import groups and before the class would improve visual separation.