Sample

pyint-7e199a2dcc25-I06

Invert eligible conditions and exchange their branches

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.670–20; mean of three runs
GPT-6.1 Sol170–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 type hints, descriptive class/attribute names, and helpful docstrings. Structure is logical: the class, its attributes, and a straightforward __init__ method are well organized. Nesting is minimal and flat. The only minor issues are an undefined `te.Self` type and missing import for `SessionMixin`, which could cause confusion. The on_update function is concise and correctly captures intent, but it's nested inside __init__, slightly affecting flow. Overall, intent is clear: track session modification via a callback. Code length is appropriate and not overly verbose. Action granularity is one per line, making it easy to follow. Reading flow is natural, though the missing imports and minor nesting keep it from a higher score.

Run 3

The code is generally well-structured and readable. It uses clear imports, a descriptive class name, and a helpful docstring. Type hints improve clarity. The `__init__` method is concise and delegates logic to the parent class. The main issue is a naming inconsistency: `te.Self` is used in the nested `on_update` function without a visible import or definition, which would confuse readers and may cause errors. Also, the parameter `initial: c.Mapping[str, t.Any] | None = None` is slightly less explicit than using a plain `dict` or `MutableMapping`, but still understandable. Nesting is minimal, and the reading flow is natural. Overall, it is highly readable with minor improvement opportunities.

Run 1

Code Structure: Imports, class documentation, state, and initialization are logically organized, though several imports are unused in this excerpt. Nesting: Shallow; the nested callback is appropriate and easy to follow. Clarity of intent: Descriptive names, type annotations, and documentation clearly explain modification tracking, but SessionMixin and te.Self are undefined in the shown code, and the documented accessed behavior is not visible. Code length: The implementation is concise, although the documentation and multiline constructor signature outweigh the small amount of executable code. Action granularity: Each statement performs one clear action. Reading flow: The progression from class purpose to state and callback registration is natural; abbreviated aliases and missing definitions create minor interruptions.

Run 2

Code Structure: Imports, class documentation, state, and initialization are logically organized, although several imports are unused in this snippet. Nesting: Only a small callback is nested within the constructor, keeping complexity low. Clarity of intent: Descriptive names, type annotations, and documentation clearly explain modification tracking. However, SessionMixin and te.Self are undefined in the provided code, and the documentation mentions accessed and new without showing their implementation. Code length: The implementation is concise; the extensive documentation is useful, though the multiline constructor signature is unnecessary for one parameter. Action granularity: Each statement performs one clear action. Reading flow: The progression from session behavior to the update callback and superclass initialization is natural, with minor disruption from missing definitions and import clutter.

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: Descriptive names, type annotations, and comments clearly explain modification tracking. However, SessionMixin and te.Self are undefined in the shown code, and the docstring mentions accessed and new without showing their implementation. Code length: Compact overall, though the multiline constructor signature and extensive documentation add some visual length. Action granularity: Each statement performs a single clear action. Reading flow: Natural progression from session behavior to initialization and callback registration, with minor friction from abbreviated import aliases and missing definitions.