Sample

pyint-31a3e4311095-I11

Split eligible integer literals into pairs of short-named intermediate 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 Pro15.330–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 good structure and clear intent, but has a few issues. Positives: clean imports, clear class docstring, well-organized attributes, and a straightforward __init__ method with explicit typing. The single-level nesting in on_update is flat and each action is on its own line. However, the code loses points for the undefined 'te.Self' reference (should be 't.Self' or just omit), which creates ambiguity. The 'SessionMixin' base class is referenced but not imported in the shown snippet, and 'CallbackDict' usage could be clearer. The conditional logic is minimal but the mutable tracking caveat in the docstring, while informative, is verbose. Overall, the code follows good Python practices but the naming inconsistencies and missing imports prevent a higher score.

Run 3

The code is generally readable with clear structure and intent. It uses type hints, docstrings, and logical organization. The class inherits from CallbackDict and SessionMixin, and the __init__ method defines a simple on_update callback to track modifications. Nesting is minimal, and line lengths are reasonable. However, readability is slightly reduced by the unused imports (hashlib, datetime, timezone, BadSignature, URLSafeTimedSerializer, TaggedJSONSerializer) and the use of `te.Self` without a visible import of `te`, which could confuse readers. The score reflects strong overall clarity but minor distractions from unused imports and a potentially undefined alias.

Run 1

Code Structure: Imports, class documentation, state, and initialization are logically organized, though several imports are unused in this snippet. Nesting: Shallow, with only a small callback nested inside the constructor. Clarity of intent: Descriptive names, type annotations, and comments explain modification tracking well, but SessionMixin and te are undefined in the supplied code, and the docstring mentions accessed without showing its handling. Code length: The implementation is concise; documentation is longer but provides useful behavioral context. Action granularity: Each statement performs one clear action. Reading flow: The sequence is natural and easy to follow, although sparse separation between imports and the class, abbreviated module aliases, and missing definitions slightly interrupt readability.

Run 2

Code Structure: Imports, class documentation, state, and initialization are logically organized, although several imports are unused in this excerpt. Nesting: Minimal nesting; the small update callback inside the constructor is straightforward. Clarity of intent: Descriptive names, type annotations, and documentation clearly explain modification tracking, but SessionMixin and te.Self are undefined in the provided code, and documentation mentions attributes not shown. Code length: Implementation is concise; documentation is longer than the executable code but provides useful behavioral context. Action granularity: Each statement performs one clear action. Reading flow: The progression from session behavior to state and initialization is natural, though missing definitions and abbreviated import aliases slightly interrupt understanding.

Run 3

Code Structure: Imports, class documentation, state, and initialization are logically organized. Nesting: Shallow, with only a small callback nested inside the constructor. Clarity of intent: The docstring, attribute comments, and callback clearly explain modification tracking, although SessionMixin and te.Self are undefined in the provided snippet, and the documentation mentions attributes not shown. Code length: Implementation is concise; documentation is somewhat lengthy relative to the functionality but provides useful context. Action granularity: Each statement performs one clear action. Reading flow: Natural progression from session behavior to initialization, slightly interrupted by verbose comments, abbreviated import aliases, and missing dependency definitions.