Sample

pyint-026ea9800389-I08

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

Matched original source

Lines39

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7920–1; higher is more readable
Mi0.4350–1; higher is more readable
LLOC21Logical lines; fewer is more readable
DeepSeek V4 Pro12.330–20; mean of three runs
GPT-6.1 Sol140–20; mean of three runs
BTTF0.2570–1; higher is more readable

Views

Source code

from __future__ import annotations import collections.abc as c import hashlib import typing as t from collections.abc import MutableMapping from datetime import datetime from datetime import timezone from itsdangerous import BadSignature from itsdangerous import URLSafeTimedSerializer from werkzeug.datastructures import CallbackDict from .json.tag import TaggedJSONSerializer class SecureCookieSession(CallbackDict[str, t.Any], SessionMixin): """Base class for sessions based on signed cookies. This session backend will set the :attr:`modified` and :attr:`accessed` attributes. It cannot reliably track whether a session is new (vs. empty), so :attr:`new` remains hard coded to ``False``. """ #: When data is changed, this is set to ``True``. Only the session #: dictionary itself is tracked; if the session contains mutable #: data (for example a nested dict) then this must be set to #: ``True`` manually when modifying that data. The session cookie #: will only be written to the response if this is ``True``. modified = False def __init__( self, initial: c.Mapping[str, t.Any] | None = None, ) -> None: def on_update(self: te.Self) -> None: running_total = 0 for current_number in range(1, 6): running_total += current_number self.modified = True super().__init__(initial, on_update)

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.824.372−27.204
Source linesThe number of non-empty source lines.39+15.6
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.597−6.895

Intercept 8.87 + feature contributions = -9.63 (log-odds).
Score = sigmoid(-9.63) = 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.69.9+0.705
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.036+0.59
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.40−0.38
Indentation frequencyHow rapidly indentation changes from line to line.28+0.231
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.28−0.222
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.62.75+0.208
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.38.915+0.134

Intercept 0.07 + feature contributions = 1.336 (log-odds).
Score = sigmoid(1.336) = 0.792.

Score0.435
Score21
Run 1

The code is highly readable with clear structure, minimal nesting, and explicit intent. Class and method names are descriptive, type hints are used consistently, and comments clarify non-obvious behavior like the limitation of the `new` attribute. The `on_update` callback is appropriately granular, though it contains a somewhat unrelated loop example (summing 1-5) that slightly obscures its purpose. Overall, the code follows good Python practices.

Run 2

The code has a clear class structure and good documentation, but contains several issues. The import section mixes multiple import styles (from __future__, standard library, third-party). The on_update callback contains an unrelated loop (running_total calculation) that serves no purpose and obscures intent. While nesting is shallow and action granularity is acceptable, the meaningless loop breaks reading flow and clarity. Type hints are used well, but 'te.Self' is undefined in the visible import list. The code length is reasonable, and the overall layout is organized, but the confusing loop and undefined type reference reduce readability significantly. The documentation is helpful for understanding the class purpose.

Run 3

The code has a clear class definition and docstring, but the overall flow is disrupted by an unrelated loop inside the on_update callback. The loop appears to be placeholder logic that obscures the intent ('mark modified when updated') and adds unnecessary nesting and length. Type annotations are helpful, but imports are inconsistent—mixing aliased and direct imports (c vs. collections.abc) reduces clarity. The use of 'te.Self' is undefined in this context, which would break understanding. Action granularity is mixed: the loop combines multiple arithmetic actions in one line, while other parts are one action per line. Structure is logical but cluttered by the irrelevant loop. Nesting is moderate, but the loop introduces needless depth. Overall readability suffers due to ambiguous intent and extraneous code, despite a clean class layout.

Run 1

Code Structure: The class and update callback are logically organized, but unrelated computation and unused imports introduce clutter. Nesting: Depth is modest, with a callback inside the constructor and a short loop inside it. Clarity of intent: The class docstring and modified-flag comment explain session behavior well, but running_total serves no visible purpose, and SessionMixin and te.Self are undefined in the snippet. Code length: The implementation is short, although the unused loop and verbose constructor formatting add unnecessary length. Action granularity: Each statement performs one action, making individual operations easy to follow. Reading flow: Imports, documentation, state, and initialization follow a natural order, but the irrelevant summation interrupts the callback's otherwise straightforward purpose.

Run 2

Code Structure: The class, initializer, and update callback are logically organized, but unused imports and unrelated calculation introduce clutter. Nesting: The callback and its loop create moderate nesting, although the snippet remains easy to follow. Clarity of intent: The docstring, attribute documentation, and callback assignment clearly explain modification tracking; however, the unused running_total calculation obscures the callback's purpose, and SessionMixin and te.Self lack visible definitions or imports. Code length: Documentation is useful, but the unnecessary loop and unused imports make the snippet longer than needed. Action granularity: Each statement performs one action, with consistent formatting. Reading flow: The progression from class documentation to state and initialization is natural, but irrelevant arithmetic interrupts the otherwise straightforward update logic.

Run 3

Code Structure: Imports, class documentation, state, and initialization are logically organized, although several imports are unused and SessionMixin and te are undefined in the snippet. Nesting: The callback inside the constructor and its loop introduce modest nesting. Clarity of intent: Documentation clearly explains modification tracking, but the unused running_total calculation obscures the callback's simple purpose. Code length: The implementation is short, yet the unrelated loop and unused imports add unnecessary length. Action granularity: Each statement performs one action, with no compressed multi-operation lines. Reading flow: Conventional formatting and descriptive names support natural reading, but the unexplained arithmetic interrupts the flow before setting modified.