Sample

pyint-77678a4ca97a-SRC

Unmodified source class

Lines36

Scores

MethodScoreScale
Posnett0.0010–1; higher is more readable
Dorn0.8730–1; higher is more readable
Mi0.4350–1; higher is more readable
LLOC18Logical lines; fewer is more readable
DeepSeek V4 Pro14.670–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.4540–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 SecureCookieSession(CallbackDict[str, t.Any], SessionMixin): """Base class for sessions based on signed cookies. This session backend will set the :attr:`modified` and :attr:`accessed` attributes. It cannot reliably track whether a session is new (vs. empty), so :attr:`new` remains hard coded to ``False``. """ #: When data is changed, this is set to ``True``. Only the session #: dictionary itself is tracked; if the session contains mutable #: data (for example a nested dict) then this must be set to #: ``True`` manually when modifying that data. The session cookie #: will only be written to the response if this is ``True``. modified = False def __init__( self, initial: c.Mapping[str, t.Any] | None = None, ) -> None: def on_update(self: te.Self) -> None: self.modified = True super().__init__(initial, on_update)

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.701.154−23.138
Source linesThe number of non-empty source lines.36+14.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.628−6.941

Intercept 8.87 + feature contributions = -6.809 (log-odds).
Score = sigmoid(-6.809) = 0.001.

Feature contributions

FeatureValueContribution
(log-odds)
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.69.838+0.707
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.034+0.609
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.37−0.274
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.62.243+0.2
Indentation frequencyHow rapidly indentation changes from line to line.25+0.128
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.35.845+0.091

Intercept 0.07 + feature contributions = 1.93 (log-odds).
Score = sigmoid(1.93) = 0.873.

Score0.435
Score18
Run 1

The code is well-structured with clear section separation via imports, class definition, and method. Imports are organized in three logical groups. There is minimal nesting with only one nested function `on_update` inside `__init__`. Intent is clearly conveyed through descriptive names, type hints, and comprehensive docstrings explaining the class behavior and the `modified` attribute. Code length is appropriate—no unnecessary repetition or verbosity. Each action generally occupies its own line, and the `super().__init__` call clearly combines initialization and callback registration in one logical step. Reading flow is natural: docstring, attribute, then constructor with callback definition before use. Minor deductions: renaming `collections.abc` to `c` slightly reduces readability compared to full name; `typing as t` and `te.Self` mixed aliases could be more consistent. Overall, highly readable code.

Run 2

The code is clear and well-structured overall. It uses modern Python features (type hints, `__future__` import, `typing` aliases) that improve intent. Class and method purpose are evident: it defines a mutable session backed by a callback dict. Nesting is minimal; only one small inner function is used. Action granularity is appropriate, with logical line breaks. The docstring and inline comments clarify domain constraints (e.g. `new` hardcoded, `modified` tracking). Minor readability concerns: several unused/ambiguous imports (`hashlib`, `datetime`, `URLSafeTimedSerializer`, etc.) add visual noise. Also, `te.Self` is referenced without an import for `te`, which is a slight clarity gap. The long import list could be condensed. Overall, the code is easy to follow and maintain, but cleanup of imports and consistent type annotations would improve it.

Run 3

The code has clear docstrings and type hints, but falls short in several areas. The class has a clear purpose, but inherits from CallbackDict without showing its definition, leaving the reader unaware of how on_update is used. The nested function definition inside __init__ adds unnecessary nesting and indirection, reducing clarity. The import of MutableMapping is unused, and the alias 'c' for collections.abc is too cryptic. The class's responsibility is clear, but the code length is slightly padded due to verbose comments and unused imports. Action granularity is generally one action per line, but the nested on_update function obscures the flow. Overall, the structure is logical but implementation details create unnecessary friction.

Run 1

Code Structure: Imports, class documentation, state, and initialization are logically organized. Nesting: The single nested callback is shallow and appropriate. Clarity of intent: Descriptive names, type annotations, and comments clearly explain modification tracking, though SessionMixin and te.Self are undefined in the provided snippet, and the documentation mentions accessed and new without showing their implementation. Code length: The implementation is concise; documentation is somewhat lengthy but explains important behavior. Action granularity: Each statement performs one action, with no compressed or compound operations. Reading flow: The progression from class purpose to state and initialization is natural, although unused imports and missing definitions introduce distractions.

Run 2

Code Structure: Imports, class documentation, state, and initialization are logically organized, although several imports are unused in this snippet. Nesting: Shallow; the nested update callback is small and easy to follow. Clarity of intent: Descriptive names, type annotations, and documentation clearly explain modification tracking, but SessionMixin and te.Self are undefined in the provided code, and the documented accessed behavior is not shown. Code length: Implementation is concise, though documentation is relatively long and the multiline constructor signature adds visual space. Action granularity: Each statement performs one clear action. Reading flow: The progression from class purpose to state definition and callback registration is natural, with minor friction from abbreviated import aliases and missing definitions.

Run 3

Code Structure: Imports, class documentation, state, and initialization are logically organized, although several imports are unused in this snippet. Nesting: Shallow; the nested callback adds little complexity. Clarity of intent: Descriptive names, type hints, and documentation clearly explain modification tracking, but undefined SessionMixin and te references reduce self-contained clarity. Code length: The implementation is concise; documentation is comparatively lengthy but explains important behavior. Action granularity: Each statement performs one action, with no compressed multi-action lines. Reading flow: The progression from session behavior to the update callback and superclass initialization is natural, though the docstring mentions accessed and new attributes whose implementation is not shown.