Sample

pyint-e2087edf19dd-I10

Deterministically remove some optional blank lines and bracketed line breaks

Matched original source

Lines41

Scores

MethodScoreScale
Posnett0.0090–1; higher is more readable
Dorn0.850–1; higher is more readable
Mi0.5770–1; higher is more readable
LLOC22Logical lines; fewer is more readable
DeepSeek V4 Pro15.330–20; mean of three runs
GPT-6.1 Sol17.670–20; mean of three runs
BTTF0.7390–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.41+16.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.652−6.978

Intercept 8.87 + feature contributions = -4.705 (log-odds).
Score = sigmoid(-4.705) = 0.009.

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.42−0.451
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.71.714+0.353
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.79+0.319
Indentation frequencyHow rapidly indentation changes from line to line.27+0.197
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.40.875+0.162

Intercept 0.07 + feature contributions = 1.738 (log-odds).
Score = sigmoid(1.738) = 0.85.

Score0.577
Score22
Run 1

The code is well-structured and highly readable. It uses clear imports, type hints, and a logical class hierarchy with SessionMixin extending MutableMapping. The property methods for 'permanent' are concise with clear intent, and class-level attributes are well-documented with explanatory comments. Nesting is minimal and the reading flow is natural, following a standard Python layout. The code slightly loses points for a few minor issues: the import 'c' is aliased but unused, 'CallbackDict' and 'TaggedJSONSerializer' are imported but not referenced in this snippet, and some comments like '#: Some implementations...' are somewhat vague. Overall, the code demonstrates strong organization, appropriate granularity, and clear separation of concerns.

Run 2

The code is highly readable with clear structure and purpose. It defines a SessionMixin class that extends MutableMapping, with well-documented properties and attributes. The nesting is minimal (only one level in property methods), and each action is on its own line with appropriate spacing. Imports are organized, though some are unused (datetime, timezone, hashlib, itsdangerous imports) which slightly detracts. The docstrings are informative but could be more concise. Type hints improve clarity. The class-level attributes (new, modified, accessed) are well-placemented with explanatory comments. Overall structure is logical, progressing from imports through class definition to properties. Minor improvements could include removing unused imports and tightening some docstring verbosity, but the code maintains high readability standards with clear intent and natural flow.

Run 3

The code is logically organized with clear class structure and imports, but readability is hindered by several factors. Imports use cryptic aliases ('c', 't') and include unused modules (hashlib, datetime, itsdangerous), suggesting potential placeholder or incomplete code. The class methods are concise and well-documented, with clear property/setter logic, but the action granularity is mixed—some lines bundle multiple operations (imports on separate lines vs combined aliased imports). The attribute declarations ('new', 'modified', 'accessed') are flat and readable, though the trailing docstring placement after 'accessed' breaks natural flow. The session permanence property has clear intent, but the type ignore comment adds minor noise. Overall, readable for experienced Python developers but less friendly to newcomers due to abbreviated imports and unused dependencies.

Run 1

Code Structure: Imports precede a focused mixin class, and session attributes are logically grouped; blank lines between imports and the class would improve separation. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: Descriptive names, type annotations, and documentation clearly explain session behavior, although abbreviated import aliases and framework-specific references require some familiarity. Code length: The implementation is concise; comments are proportionate to the behavior being documented, though several imports are unused in this excerpt. Action granularity: Each executable line performs a single clear action. Reading flow: The getter and setter appear together, followed by related state flags, creating a natural progression. Inconsistent documentation styles and dense spacing near the imports slightly reduce readability.

Run 2

Code Structure: The mixin logically groups a session property and related state flags, although imports lack grouping and separation from the class. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: Descriptive names, type annotations, and documentation clearly explain session behavior; 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 comments occupy more space than executable code. Action granularity: Each executable line performs one clear action. Reading flow: The property getter and setter appear together, followed by related flags, providing a natural progression. Missing blank lines around top-level sections and inconsistent comment formatting modestly interrupt that flow.

Run 3

Code Structure: Imports and a single focused mixin are logically organized, although blank lines between import groups and before the class would improve separation. 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 are less expressive. Code length: The implementation is concise, with documentation adding useful context rather than unnecessary complexity. Action granularity: Each executable line performs one clear operation. Reading flow: The property getter, setter, and default attributes follow a natural sequence, though mixed documentation styles and tightly packed imports slightly interrupt consistency.