Sample

pyint-4e2d127f86eb-I03

Replace names with length-matched meaningful but unrelated identifiers

Matched original source

Lines36

Scores

MethodScoreScale
Posnett0.0010–1; higher is more readable
Dorn0.8730–1; higher is more readable
Mi0.4340–1; higher is more readable
LLOC18Logical lines; fewer is more readable
DeepSeek V4 Pro160–20; mean of three runs
GPT-6.1 Sol16.670–20; mean of three runs
BTTF0.4560–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, history: c.Mapping[str, t.Any] | None = None, ) -> None: def on_update(self: te.Self) -> None: self.modified = True super().__init__(history, 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.701.154−23.138
Source linesThe number of non-empty source lines.36+14.4
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.633−6.95

Intercept 8.87 + feature contributions = -6.818 (log-odds).
Score = sigmoid(-6.818) = 0.001.

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.838+0.707
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.034+0.609
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.37−0.274
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.62.243+0.2
Indentation frequencyHow rapidly indentation changes from line to line.25+0.128
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.35.845+0.091

Intercept 0.07 + feature contributions = 1.93 (log-odds).
Score = sigmoid(1.93) = 0.873.

Score0.434
Score18
Run 1

The code is well-structured and readable. It uses clear type hints, modern Python features (e.g., from __future__ import annotations), and proper imports. Class and method definitions are logically organized, with a docstring that clearly explains purpose and limitations. Nesting is minimal—only a single nested function inside __init__, which is fine. Intent is clear: this is a session backend for signed cookies. Code length is concise; no unnecessary lines. Action granularity is appropriate, with one logical action per line (e.g., setting modified in on_update, calling super().__init__). Reading flow is natural: imports, class definition, docstring, attribute, then constructor. Minor deductions: the nested function could be extracted for clarity, and the use of single-letter import alias 'c' is slightly less readable than a more descriptive name. Overall, highly readable.

Run 2

The code is generally readable with clear structure: imports are organized, class and method names are descriptive, and docstrings provide helpful context. The nesting is minimal, and the update callback is concise. However, a few issues reduce clarity: the class inherits from both CallbackDict and SessionMixin without showing SessionMixin's import, which may confuse readers about its origin. The type hint te.Self appears without an explicit import of 'te', creating ambiguity. The 'history' parameter is typed as optional mapping, but its role in a cookie session context isn't immediately obvious. The 'modified' attribute documentation is verbose but helpful. Overall, the code is readable but slightly hampered by missing import context and unexplained type aliases.

Run 3

The code is well-structured with clear imports, logical grouping, and a single class definition. It uses type hints and docstrings effectively, contributing to clarity of intent. Nesting is minimal, with only one small closure inside __init__. Action granularity is appropriate—each logical action is on its own line. Reading flow is natural, with imports first, class definition, class attribute, and then a clear constructor. The code length is concise. Minor issues prevent a higher score: 'te.Self' appears to be a typo (should be 't.Self' or 'SecureCookieSession'), and 'SessionMixin' is referenced but not imported, which could confuse maintainability. The docstring is helpful but slightly verbose regarding limitations. Overall, very readable code with excellent structure and intent clarity.

Run 1

Code Structure: Imports, class documentation, state, and initialization are logically organized, though some imports are unused in this excerpt. Nesting: Only a small callback is nested inside the constructor, keeping complexity low. Clarity of intent: The docstring and comments clearly explain session modification tracking, but SessionMixin and te.Self are not defined or imported in the shown code, and 'history' is a less intuitive name for initial session data. Code length: The implementation is concise; documentation is longer than the executable code but useful. Action granularity: Each statement performs one clear action. Reading flow: The progression from class purpose to modification flag to update callback is natural, although abbreviated aliases and unresolved names slightly interrupt comprehension.

Run 2

Code Structure: Imports, class documentation, state, and initialization are logically organized, though SessionMixin and te are not defined or imported in the snippet. Nesting: Shallow; the nested callback is appropriate and easy to follow. Clarity of intent: Descriptive names, type annotations, and comments explain modification tracking, but the docstring also promises accessed tracking that is not shown. Code length: The implementation is concise, although documentation and the multiline constructor signature outweigh the small amount of executable code. Action granularity: Each executable line performs one clear action. Reading flow: Natural progression from session behavior to initialization, with minor friction from abbreviated aliases and missing dependencies.

Run 3

Code Structure: Imports and a focused session class are logically organized, although several imports are unused in this snippet. Nesting: Only a small callback is nested inside the constructor, keeping complexity low. Clarity of intent: The class documentation, attribute comments, and descriptive callback name clearly explain modification tracking; however, SessionMixin and te.Self are undefined in the provided code, and documentation mentions attributes not shown. Code length: The implementation is concise, with extensive but useful documentation. Action granularity: Each statement performs one clear action. Reading flow: The progression from imports to class documentation, state, and initialization is natural, though unused imports and unresolved names slightly interrupt comprehension.