Sample

pyint-494c2b583d15-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines43

Scores

MethodScoreScale
Posnett0.0180–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 Pro11.330–20; mean of three runs
GPT-6.1 Sol13.670–20; mean of three runs
BTTF0.6960–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 per2(self) -> bool: """This reflects the ``'_permanent'`` key in the dict.""" return self.get("_permanent", False) # type: ignore[no-any-return] @permanent.setter def per2(self, val: bool) -> None: self["_permanent"] = bool(val) #: 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.699.947−23.098
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.663−6.995

Intercept 8.87 + feature contributions = -4.023 (log-odds).
Score = sigmoid(-4.023) = 0.018.

Feature contributions

FeatureValueContribution
(log-odds)
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.026+0.688
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.932+0.322
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.837+0.189

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

Score0.584
Score22
Run 1

The code is generally readable with clear docstrings and type hints. Structure is logical, nesting is flat, and intent is mostly clear. However, there are issues: a typo in the property name 'per2' instead of 'permanent' (the setter references 'permanent' but the property is 'per2'), which creates confusion. The unused imports (collections.abc, hashlib, datetime, timezone, itsdangerous, TaggedJSONSerializer) add noise and suggest copied code. Action granularity is mixed—some lines combine multiple concepts (e.g., get with type ignore). The 'new', 'modified', and 'accessed' attributes are defined with comments that break reading flow, and the use of 'CallbackDict' and 'TaggedJSONSerializer' imports without usage is misleading. Overall, the code is understandable but could be improved by fixing the typo, removing unused imports, and clarifying attribute definitions.

Run 2

The code has several readability issues. The property is named 'per2' but the docstring and setter reference '_permanent', creating ambiguity about intent. The property setter is named 'permanent' while the getter is 'per2', which is inconsistent and likely a bug or typo. Imports are aliased unnecessarily (collections.abc as c, typing as t), though this is a minor style choice. Class-level attributes like 'new', 'modified', and 'accessed' are interspersed with docstrings, disrupting reading flow. The mixin is flat and relatively short, but the naming inconsistency and unclear property relationships make the code's purpose confusing. While the structure is not deeply nested and actions are generally single-purpose, the overall clarity of intent suffers significantly from the mismatched names and unclear property definitions, reducing what could otherwise be a straightforward mixin to ambiguous and potentially malfunctioning code.

Run 3

The code is generally readable with clear docstrings and type hints, but has notable issues. The property is named 'per2' which is ambiguous and likely a typo for 'permanent', reducing clarity of intent. The class structure is logical, but the mixing of attributes with docstrings in different positions (some above, some below) creates inconsistent reading flow. The nesting is flat and action granularity is appropriate. The code length is concise but could be misleading due to the naming issue. Imports are organized but the aliasing of 'collections.abc as c' is unnecessary and confusing. Overall, the code is understandable but the naming inconsistency and typo significantly impact readability.

Run 1

Code Structure: Imports and the session mixin are logically organized, although import grouping could be clearer. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: Type annotations and documentation explain the session attributes, but the name 'per2' is unclear, and '@permanent.setter' references an undefined property rather than 'per2', creating confusion. Code length: The implementation is concise; documentation occupies most of the snippet but provides useful context. Action granularity: Each executable line performs a single clear action. Reading flow: The progression from imports to properties and session flags is natural, though inconsistent comment styles and the mismatched setter interrupt comprehension.

Run 2

Code Structure: Imports and a focused session mixin provide logical organization, though numerous unused imports distract. Nesting: Flat class methods and properties are easy to scan. Clarity of intent: Type annotations and documentation explain session attributes, but the cryptic name 'per2' obscures the permanent-session property. The '@permanent.setter' decorator references an undefined name rather than 'per2', making the intended relationship confusing and preventing class creation as shown. Code length: The implementation is concise, although comments and imports outweigh the executable code. Action granularity: Each executable line performs a single clear action. Reading flow: The property and related session flags follow a sensible sequence, but inconsistent naming, mixed documentation styles, and ungrouped imports interrupt the flow.

Run 3

Code Structure: Imports and session attributes are logically organized within a small mixin, although several imports are unused in this snippet. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: Type hints and documentation explain session behavior, but the opaque name 'per2' obscures the property’s purpose. More seriously, '@permanent.setter' references an undefined name rather than the declared property, creating a confusing inconsistency. Code length: The implementation is concise, though documentation is lengthy relative to the executable code. Action granularity: Each statement performs a single action, with no compressed multi-action lines. Reading flow: The property, setter, and flags follow a natural sequence, but inconsistent comment styles and the naming/decorator mismatch interrupt comprehension.