Sample

pyint-af2ebddc7288-I05

Rewrite eligible decimal integer literals in hexadecimal notation

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 Pro17.330–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 with clear structure and intent. The SessionMixin class is logically organized with properties and attributes properly separated. Nesting is minimal - only one class and two methods with no deep indentation. The intent is clearly expressed through descriptive naming and comprehensive docstrings that explain not just what each component does but also important caveats. Code length is appropriate with no unnecessary verbosity, though the multiline docstring for 'accessed' is slightly long but justified given the version change reference. Each line performs a single clear action. Reading flow is natural - imports are properly grouped, class purpose is immediately evident, and methods follow a logical progression. The type hints and explicit return type annotations enhance clarity. Minor deductions for the type ignore comment and the slight inconsistency in docstring formatting between attributes, but overall this is production-quality readable code.

Run 3

The code is highly readable with clear structure and purpose. It defines a SessionMixin class with well-documented properties and attributes. The 'permanent' property demonstrates good encapsulation with a getter/setter pattern and clear docstrings. Nesting is minimal, and action granularity is appropriate - each method or property does one thing. The reading flow is natural, starting with imports, then class definition, followed by properties and attributes. The use of type hints and docstrings enhances clarity. Minor deductions: some attributes like 'new' and 'modified' lack type annotations, and the 'accessed' attribute has a multi-line docstring that slightly breaks the flow between 'modified' and 'accessed'. However, overall the code follows Python best practices and remains concise.

Run 1

Code Structure: Imports and a focused session mixin are logically organized, though import grouping could be clearer. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: Descriptive names, type annotations, and documentation clearly explain session attributes and the permanent property; abbreviated import aliases slightly reduce immediate clarity. Code length: The implementation is concise, with proportionate documentation, although several imports are unused in the shown snippet. Action granularity: Each statement performs a single action, with no compressed multi-operation lines. Reading flow: The progression from the class description to the property and session flags is natural. Minor inconsistencies in attribute documentation styles and limited spacing between import groups slightly interrupt an otherwise clear presentation.

Run 2

Code Structure: Imports and session-related behavior are logically grouped within a focused mixin, although import grouping could be cleaner. 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 and differing comment styles slightly reduce clarity. Code length: The implementation is concise, with documentation providing useful context rather than unnecessary complexity, though several imports are unused in this excerpt. Action granularity: Each executable line performs a single clear action. Reading flow: The progression from the permanent property to session-state flags is natural, but inconsistent documentation placement and formatting introduce minor interruptions.

Run 3

Code Structure: Imports and a single focused mixin are logically organized, although import grouping could be clearer. Nesting: Minimal nesting, limited to straightforward property methods. Clarity of intent: Descriptive names, type annotations, and documentation clearly explain session attributes; abbreviated import aliases slightly reduce clarity. Code length: Concise implementation, with documentation appropriately explaining behavioral caveats, though several imports are unused in this snippet. Action granularity: Each executable line performs one clear action. Reading flow: The getter, setter, and default attributes follow naturally, but inconsistent documentation styles and embedded version metadata mildly interrupt the flow.