Sample

pyint-5349a4423f92-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines43

Scores

MethodScoreScale
Posnett0.020–1; higher is more readable
Dorn0.8580–1; higher is more readable
Mi0.5840–1; higher is more readable
LLOC22Logical lines; fewer is more readable
DeepSeek V4 Pro16.670–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.7470–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 SessionMixin(MutableMapping[str, t.Any]): """Expands a basic dictionary with session attributes.""" @property def permanent(self) -> bool: """This reflects the ``'_permanent'`` key in the dict.""" return self.get("_permanent", False) # type: ignore[no-any-return] @permanent.setter def permanent(self, value: bool) -> None: self["_permanent"] = bool(value) #: Some implementations can detect whether a session is newly #: created, but that is not guaranteed. Use with caution. The mixin # default is hard-coded ``False``. new = False #: Some implementations can detect changes to the session and set #: this when that happens. The mixin default is hard coded to #: ``True``. modified = True accessed = False """Indicates if the session was accessed, even if it was not modified. This is set when the session object is accessed through the request context, including the global :data:`.session` proxy. A ``Vary: cookie`` header will be added if this is ``True``. .. versionchanged:: 3.1.3 This is tracked by the request context. """

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.696.883−22.997
Source linesThe number of non-empty source lines.43+17.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.653−6.979

Intercept 8.87 + feature contributions = -3.906 (log-odds).
Score = sigmoid(-3.906) = 0.02.

Feature contributions

FeatureValueContribution
(log-odds)
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.026+0.69
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.44−0.522
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.73.795+0.386
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.78.909+0.323
Indentation frequencyHow rapidly indentation changes from line to line.29+0.266
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.42.875+0.189

Intercept 0.07 + feature contributions = 1.801 (log-odds).
Score = sigmoid(1.801) = 0.858.

Score0.584
Score22
Run 1

The code is well-structured with clear class definition and logical grouping of properties and attributes. Nesting is minimal—only one class and no deep indentation. The intent is clear: extending a dictionary with session-specific behavior. Code length is concise; each property is short and focused. Action granularity is appropriate, with one logical action per line. Reading flow is natural, moving from imports to class definition to documented attributes. Type hints and docstrings improve understandability. Minor deductions include a couple of slightly long lines and mixed import styles, but overall readability is strong.

Run 2

The code demonstrates excellent readability through its clean structure, clear intent, and well-organized documentation. The SessionMixin class is logically structured with a clear purpose - expanding a basic dictionary with session attributes. The property decorator implementation for 'permanent' is straightforward and properly annotated with type hints. The code maintains a flat nesting structure with no deep conditional or loop complexity. Variable names are descriptive and follow Python conventions. Class attributes like 'new', 'modified', and 'accessed' are well-documented with clear docstrings explaining their purpose. The import statements are organized logically (even if slightly unconventional with 'import collections.abc as c' which could be more explicit). Each action is on its own line, promoting readability. The only minor deduction is for the type ignore comment and the unused imports (collections, hashlib, datetime, timezone) that could be cleaned up, which slightly reduces clarity about what the module actually uses.

Run 3

The code is largely readable. The class structure is logical and the SessionMixin class has a clear purpose, with methods and properties straightforwardly organized. Nesting is minimal, contributing to a flat structure. Intent is clear through descriptive naming (permanent, modified, accessed) and docstrings. Code length is concise for a mixin. Action granularity is mostly good, though the `return self.get("_permanent", False) # type: ignore` packs a type suppression into a single line, adding minor noise. Reading flow is natural, with methods and attributes interspersed logically. The raw `# type: ignore[no-any-return]` comment and slightly dense import block reduce clarity slightly, but overall the code is maintainable and understandable.

Run 1

Code Structure: Imports and a focused mixin class are logically organized, though import grouping could be clearer. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: Descriptive property names, type annotations, and documentation clearly explain session behavior; abbreviated import aliases are slightly less explicit. Code length: Implementation is concise, although documentation occupies substantially more space than executable code. Action granularity: Each statement performs a single clear action. Reading flow: The property getter and setter appear together, followed by related state attributes, producing a natural progression. Mixed documentation styles and the long accessed attribute explanation introduce minor visual inconsistency.

Run 2

Code Structure: Imports and a single focused mixin are logically organized, although spacing between import groups and the class could improve. Nesting: Minimal nesting makes the code easy to follow. Clarity of intent: Descriptive names, type annotations, and documentation clearly explain session attributes and the permanent property; abbreviated import aliases and mixed documentation styles slightly reduce clarity. Code length: The implementation is concise, though several imports are unused in this excerpt and documentation occupies more space than the logic. Action granularity: Each statement performs one clear action. Reading flow: The getter, setter, and default attributes follow a natural sequence, but switching between preceding comments and a trailing attribute docstring introduces minor inconsistency.

Run 3

Code Structure: Imports and a focused session mixin are logically organized, though import grouping and spacing could improve. Nesting: Very shallow, with straightforward property methods and class attributes. Clarity of intent: Descriptive names, type annotations, and documentation clearly explain session behavior; abbreviated import aliases and the type-ignore comment add minor friction. Code length: Concise implementation, although documentation occupies substantially more space than executable code. Action granularity: Each statement performs one action, with no compressed multi-operation lines. Reading flow: The getter and setter appear together, followed by related session flags, making progression natural. Mixed documentation styles for class attributes slightly interrupt consistency.