Sample

pyint-49a04dd7947c-I12

Inline all eligible single-use intermediate local variables

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 Pro170–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 is generally well-structured and readable. It defines a SessionMixin class with clear documentation for each property and attribute. The methods are concise with logical separation. However, there are minor readability issues: the imports are somewhat disorganized (mixing 'collections.abc as c' with 'from collections.abc import MutableMapping'), several imports appear unused (hashlib, datetime, URLSafeTimedSerializer, etc.), and the 'permanent' property has a type ignore comment that's slightly distracting. The class attributes are clearly documented but clustered together at different indentation levels. Overall, the code shows good clarity of intent through docstrings and follows Python conventions, though it could benefit from cleaner, more intentional imports.

Run 3

The code is highly readable with a clear, logical structure. It uses straightforward imports, a well-documented class, and concise methods. Nesting is minimal, and the intent—extending a dictionary with session attributes—is explicit through the class name, type hints, and docstrings. Each property and attribute is clearly separated, with comments explaining non-obvious behaviors. The use of type annotations and descriptive names like 'permanent', 'modified', and 'accessed' enhances clarity. Code length is appropriate, and action granularity is one action per line. Reading flow is natural: imports, class definition, properties, and attributes follow a logical order. Minor nitpicks: the attribute 'new' and 'modified' are class variables with inline comments that could be slightly more explicit, and the docstring for 'accessed' is quite long but informative. Overall, this is excellent code that balances documentation and conciseness.

Run 1

Code Structure: Imports and session attributes are logically organized within a focused mixin. Nesting: The code is flat, with only simple property methods. Clarity of intent: Descriptive names, type annotations, and documentation make session behavior clear, although abbreviated import aliases and the type-ignore comment require some familiarity. Code length: Implementation is concise; documentation is comparatively lengthy but explains important behavioral distinctions. Action granularity: Each statement performs a single action, making individual operations easy to follow. Reading flow: The getter, setter, and default attributes follow a natural sequence. Minor inconsistencies in attribute documentation style and limited spacing between import groups and the class slightly reduce polish.

Run 2

Code Structure: Imports and the session mixin are logically organized, although import grouping could be clearer. Nesting: Methods are flat and minimal, with no complex branching. Clarity of intent: Descriptive names, type annotations, and documentation clearly explain session attributes and behavior; abbreviated import aliases slightly reduce clarity. Code length: Implementation is concise, while longer comments provide useful context rather than unnecessary repetition. Action granularity: Each executable line performs a single clear action. Reading flow: The property, setter, and default attributes follow a natural sequence, though inconsistent documentation styles and unused imports in this excerpt introduce minor distractions.

Run 3

Code Structure: Imports and a focused session mixin are logically organized, although import grouping could be cleaner. Nesting: Minimal nesting, limited to the class and simple property methods. Clarity of intent: Descriptive names, type annotations, and documentation clearly explain session behavior; abbreviated import aliases and type-ignore syntax add minor friction. Code length: Implementation is concise, though documentation occupies most of the snippet and some imports are unused here. Action granularity: Each executable line performs one clear action. Reading flow: The property getter and setter appear together, followed by related session flags, creating a natural progression. Inconsistent documentation styles across attributes slightly interrupt the otherwise smooth flow.