Sample

pyint-d869dd2a306f-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines36

Scores

MethodScoreScale
Posnett0.0010–1; higher is more readable
Dorn0.8730–1; higher is more readable
Mi0.4350–1; higher is more readable
LLOC18Logical lines; fewer is more readable
DeepSeek V4 Pro150–20; mean of three runs
GPT-6.1 Sol16.670–20; mean of three runs
BTTF0.4540–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.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.628−6.941

Intercept 8.87 + feature contributions = -6.809 (log-odds).
Score = sigmoid(-6.809) = 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.435
Score18
Run 1

The code is generally readable but has a few issues. The structure and intent are clear, with good use of type hints and docstrings. However, the import section is cluttered with multiple overlapping imports (collections.abc as c, MutableMapping imported but unused), creating confusion. The unused 'MutableMapping' import and the import of 'te.Self' without an explicit import statement are problematic. The nesting level is minimal (one inline function), but the 'typing as t' alias combined with the undefined 'te' namespace creates a potential runtime error. Action granularity is good in the __init__ method, though the inline 'on_update' function could be extracted for clarity. The reading flow is mostly natural, starting with imports and moving to class definition, but the unused imports and undefined 'te' reference disrupt the flow. The class attributes are well-documented, which aids comprehension.

Run 2

The code is generally readable, with clear class/module imports and descriptive docstrings. It defines a single session class with concise attributes and an __init__ method that uses a helper closure to set the `modified` flag. Structure is logical and nesting is shallow. However, readability is slightly reduced by type hints using `te.Self` (likely a typo or missing import, since `t` import was not used) and a mix of import styles (`collections.abc as c` but also `from collections.abc import MutableMapping`). The `SessionMixin` class is referenced but not imported, which could confuse readers. These minor inconsistencies make the code slightly less clear than it could be.

Run 3

The code is generally readable with a clear structure, appropriate typing, and concise documentation. The class definition inheriting from CallbackDict and using on_update to set modified is logical and cleanly organized. Nesting is minimal, and intent is clear. The main issues are minor: the type hint 'te.Self' is inconsistent (likely 't.Self' was intended), which could confuse readers. The code length is appropriate. Action granularity and reading flow are adequate. Docstrings clarify purpose.

Run 1

Code Structure: Imports, class documentation, state, and initialization are logically organized, although SessionMixin and te are not imported in the snippet and several imports are unused. Nesting: Shallow; the nested callback is small and appropriate. Clarity of intent: Descriptive names and documentation clearly explain modification tracking, but the docstring also promises accessed tracking that is not shown. Code length: The implementation is concise, though the extensive documentation and multiline signature outweigh the small amount of logic. Action granularity: Each statement performs one clear action. Reading flow: The progression from session behavior to the modified flag and update callback is natural; unexplained aliases and missing definitions slightly interrupt comprehension.

Run 2

Code Structure: Imports, class documentation, state, and initialization are logically organized, although several imports are unused in this snippet. Nesting: Shallow; the single nested callback is appropriate and easy to follow. Clarity of intent: Descriptive names, type annotations, and documentation clearly explain modification tracking, but undefined SessionMixin and te references reduce self-contained clarity. Code length: The implementation is concise, though the documentation is relatively lengthy and discusses accessed and new attributes not shown here. Action granularity: Each statement performs one clear action. Reading flow: The progression from session behavior to default state to callback registration is natural, with whitespace helping separate concerns.

Run 3

Code Structure: Imports, class documentation, state, and initialization are logically organized, although several imports are unused in this snippet. Nesting: Shallow; the nested callback is appropriate and easy to follow. Clarity of intent: The class docstring and modified-state explanation clearly describe the purpose, but SessionMixin and te.Self are undefined in the shown code, and the docstring mentions accessed without showing its implementation. Code length: Implementation is concise, though documentation dominates the snippet and the multiline signature is somewhat excessive. Action granularity: Each statement performs one clear action. Reading flow: Natural progression from session description to change tracking and callback registration; abbreviated aliases and missing definitions slightly interrupt comprehension.