Sample

pyint-801130c57895-I10

Deterministically remove some optional blank lines and bracketed line breaks

Matched original source

Lines33

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8780–1; higher is more readable
Mi0.4010–1; higher is more readable
LLOC18Logical lines; fewer is more readable
DeepSeek V4 Pro160–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.4630–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: 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.701.154−23.138
Source linesThe number of non-empty source lines.33+13.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.624−6.937

Intercept 8.87 + feature contributions = -8.005 (log-odds).
Score = sigmoid(-8.005) = 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.882+0.705
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 (horizontal)How rapidly the visual pattern of comment characters changes from left to right.65.647+0.255
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.34−0.167
Indentation frequencyHow rapidly indentation changes from line to line.23+0.058
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.32.887+0.05

Intercept 0.07 + feature contributions = 1.978 (log-odds).
Score = sigmoid(1.978) = 0.878.

Score0.401
Score18
Run 1

The code is generally clean and readable, with clear type hints and docstrings explaining purpose. It uses a flat structure with limited nesting, and each import is on its own line. The class definition and method are logically placed. However, readability is reduced by inconsistent import ordering (mixing 'from' and 'import' statements), a misplaced indentation on the 'initial' parameter line, and an undefined 'te.Self' type. The 'on_update' function is concise but its purpose could be clearer with a comment. The score reflects solid overall clarity but some minor structural and typographical issues that interrupt reading flow.

Run 2

The code is generally readable with good structural organization and clear intent, especially for a Flask session implementation. The class has a reasonable purpose and docstrings explain behavior. Nesting is minimal. However, there are some readability issues: the import section is slightly cluttered with redundant imports (e.g., both 'collections.abc as c' and 'from collections.abc import MutableMapping'), which adds noise. The unused imports (hashlib, datetime, itsdangerous, etc.) in this snippet are confusing without context. The constructor signature uses an awkward line break with extra indentation on 'initial', and the parameter name 'c' as an alias makes the type hint less self-documenting. The inner function 'on_update' and the use of 'te.Self' (likely a typing alias) introduce minor ambiguity. Overall, the code is clean but could be slightly tightened for clarity.

Run 3

The code is highly readable overall. It has clear structure with logical separation of docstrings, attributes, and methods. Nesting is minimal and appropriate. The intent is clearly stated in comments and class/method names. Length is concise but includes necessary documentation. Action granularity is good, with one logical action per line. Reading flow is natural, progressing from imports to class definition, attributes, and methods. Minor deductions: the import 'collections.abc as c' with single-letter alias slightly reduces clarity, and there's a silent dependency on 'te.Self' and 'SessionMixin' without visible imports in this snippet.

Run 1

Code Structure: Imports, class documentation, state, and initialization are logically organized, although SessionMixin and te are undefined in the snippet. Nesting: Shallow nesting, with only a small callback inside the constructor. Clarity of intent: Descriptive names, type hints, and comments clearly explain modification tracking, but the documentation mentions accessed behavior that is not shown. Code length: The implementation is concise; documentation is relatively lengthy but useful. Action granularity: Each executable statement performs one clear action. Reading flow: Generally natural, but the awkward constructor parameter spacing, limited blank-line separation, and inconsistent typing aliases interrupt readability.

Run 2

Code Structure: The class is logically organized into documentation, state, and initialization, but several unused imports add clutter. Nesting: Only one shallow callback function is nested inside the constructor, making control flow easy to follow. Clarity of intent: Descriptive names, type annotations, and comments explain modification tracking well; however, SessionMixin and te.Self are undefined in the snippet, and the docstring describes attributes not shown. Code length: The implementation is concise, although imports and extensive documentation outweigh the executable code. Action granularity: Each executable line performs a single clear action. Reading flow: The progression from class description to flag definition to callback registration is natural, but the irregular constructor formatting and limited spacing between sections interrupt readability.

Run 3

Code Structure: Imports, class documentation, state, and initialization are logically organized, though several imports are unused in this snippet. Nesting: Only one nested callback, which is appropriate and easy to follow. Clarity of intent: Descriptive names and detailed comments explain modification tracking, but SessionMixin and te.Self are unresolved in the shown code, and the documentation mentions accessed tracking that is not visible. Code length: The implementation is concise, although documentation outweighs the small amount of executable code. Action granularity: Each executable statement performs one clear action. Reading flow: The progression from documentation to default state to callback registration is natural, but the awkward spacing and line break in the constructor signature, abbreviated import aliases, and limited separation between sections slightly hinder readability.