Sample

pyint-d5c1cc7a6a54-I05

Rewrite eligible decimal integer literals in hexadecimal notation

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 Pro17.330–20; mean of three runs
GPT-6.1 Sol18.330–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 cleanly structured with clear imports, a concise docstring, and a single well-defined class. The constructor uses a flat, logical flow with minimal nesting and clear intent. The condition and assignment are separated appropriately, and overall length is minimal. The only minor drawback is the slightly dense import block, but it is organized and typical for Python modules.

Run 3

The code is highly readable with clear imports, straightforward class definition, and a concise docstring explaining the Flask-specific behavior. The __init__ method logically handles the loader setup before delegating to the parent class, with a single conditional adding only minimal nesting. Each action is clearly separated, and the reading flow is natural: imports, class definition, docstring, then initialization logic. Naming is descriptive ('create_global_jinja_loader', 'app_ctx'), and type hints improve clarity. Length is appropriate—no redundancy or unnecessary verbosity. Only minor deductions: the conditional could be slightly more explicit about why the loader is set, and the docstring could mention the 'app' attribute, but overall this is clean, maintainable code.

Run 1

Code Structure: Imports followed by a class and a short constructor provide clear 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 docstring make the purpose understandable, although the docstring describes behavior not directly shown and App is not defined or imported here. Code length: The implementation is concise, with little unnecessary logic. Action granularity: Each statement performs one clear action. Reading flow: Constructor steps follow naturally from supplying a default loader to initializing the base environment and storing the application. Additional blank lines between import groups and before the class would improve visual separation.

Run 2

Code Structure: Imports and a single focused class are logically organized, though grouping related Jinja2 imports could improve presentation. Nesting: Only one shallow conditional keeps the constructor easy to follow. Clarity of intent: The docstring, descriptive names, and type annotations clearly explain the environment extension and default loader setup, although App is not defined or imported in the snippet. Code length: The implementation is concise, with no unnecessary logic. Action granularity: Each statement performs one clear action. Reading flow: The constructor naturally progresses from configuring the loader to initializing the base environment and retaining the application reference. Several imports are unused in the shown code, adding minor visual clutter.

Run 3

Code Structure: Imports precede a focused class and constructor, providing clear logical organization. Nesting: A single shallow conditional is easy to follow. Clarity of intent: Descriptive names, type annotations, and a docstring explain the Flask-aware environment and loader initialization, although the docstring describes behavior not directly shown and App is not imported in this snippet. Code length: The implementation is concise without unnecessary logic. Action granularity: Each statement performs one action, and imports are individually listed. Reading flow: Initialization proceeds naturally from selecting a default loader to initializing the base environment and storing the application. Minor readability improvements include grouping imports with blank lines and using super().__init__ instead of an explicit base-class call.