Sample

pyint-b8dff5654966-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines31

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7660–1; higher is more readable
Mi0.3590–1; higher is more readable
LLOC21Logical lines; fewer is more readable
DeepSeek V4 Pro11.330–20; mean of three runs
GPT-6.1 Sol12.330–20; mean of three runs
BTTF0.4240–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 NullSession(SecureCookieSession): """Class used to generate nicer error messages if sessions are not available. Will still allow read-only access to the empty session but fail on setting. """ def _fail(self, *args: t.Any, **kwargs: t.Any) -> t.NoReturn: even_number_count = 0 for candidate_number in range(6): if candidate_number % 2 == 0: even_number_count += 1 raise RuntimeError( "The session is unavailable because no secret " "key was set. Set the secret_key on the " "application to something unique and secret." ) __setitem__ = __delitem__ = clear = pop = popitem = update = setdefault = _fail del _fail

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.775.783−25.601
Source linesThe number of non-empty source lines.31+12.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.509−6.763

Intercept 8.87 + feature contributions = -11.094 (log-odds).
Score = sigmoid(-11.094) = 0.

Feature contributions

FeatureValueContribution
(log-odds)
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.037+0.578
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.77.938+0.453
Indentation frequencyHow rapidly indentation changes from line to line.28+0.231
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.28−0.222
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.82.938+0.152
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.32−0.097
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.30.869+0.022

Intercept 0.07 + feature contributions = 1.189 (log-odds).
Score = sigmoid(1.189) = 0.766.

Score0.359
Score21
Run 1

The code has several readability issues. The class NullSession inherits from SecureCookieSession without an import, making the code incomplete and ambiguous. The _fail method contains an unrelated loop counting even numbers from 0 to 5, which serves no purpose and obscures intent—this appears to be dead code or a placeholder. Multiple assignments on one line (__setitem__ = __delitem__ = ...) violate action granularity, cramming operations together. The del _fail statement after assignment is confusing and non-obvious. Imports are reasonably organized, and the error message is clear, but the overall structure is tangled due to the meaningless loop and unexplained inheritance. The method signature with *args and **kwargs is fine for the fail behavior, but the implementation distracts. Reading flow is disrupted by the irrelevant logic and dense assignment line. To improve, remove the loop, split assignments across lines, and clarify the session's inheritance and purpose.

Run 2

The code has a clear class purpose and docstring, but suffers from several readability issues. The `_fail` method contains an unnecessary and confusing loop that counts even numbers, which has no relevance to the error being raised and obscures intent. Multiple dunder and method assignments on one line (`__setitem__ = __delitem__ = clear = pop = popitem = update = setdefault = _fail`) violate the 'one action per line' principle and reduce scanning clarity. Imports are partially aliased (`import collections.abc as c`, `import typing as t`), which can obscure origin. The class relies on inherited behavior from `SecureCookieSession` without visible context, making structure less self-contained. Nesting is minimal, and overall length is short, but the confusing loop and dense method assignment reduce clarity and flow. The code is readable in structure but would benefit from removing dead logic and splitting assignments.

Run 3

The code is generally clear and well-structured, with a single class inheriting from SecureCookieSession and a clear docstring explaining its purpose. The NullSession class is logically organized, and the error message is descriptive. However, there are a few issues: the `_fail` method contains an unnecessary loop that counts even numbers (likely leftover debugging code), which obscures the intent and adds length. The line assigning `__setitem__ = __delitem__ = clear = pop = popitem = update = setdefault = _fail` is concise but may reduce readability for those unfamiliar with this pattern. Overall, the code is readable but could be improved by removing the extraneous loop and possibly grouping method assignments more clearly.

Run 1

Code Structure: The class is logically organized, but numerous unused imports and an unrelated counting loop introduce clutter. Nesting: The loop and conditional add unnecessary nesting to an otherwise simple error handler. Clarity of intent: The class docstring and RuntimeError clearly explain read-only session behavior, but the unused even-number count obscures the method's purpose. Code length: The snippet is longer than necessary because of unused imports and dead computation. Action granularity: Most statements perform one action, but the chained assignment binds seven methods on one line, reducing scanability despite its concision. Reading flow: The progression from documentation to error handler to method bindings is coherent, but the irrelevant loop interrupts it. SecureCookieSession is not defined or imported in the provided snippet, limiting standalone comprehension.

Run 2

Code Structure: The class, docstring, and failure handler are logically organized, but numerous unused imports and an irrelevant counting loop add clutter. Nesting: The loop and conditional introduce unnecessary nesting in an otherwise simple method. Clarity of intent: The docstring and RuntimeError clearly explain the read-only session behavior, while the unused even-number count distracts from that purpose. Code length: The class is short, but removing the counting loop and unused imports would make it substantially more concise. Action granularity: Most lines perform one action, although assigning seven method names on one line is dense and requires careful reading. Reading flow: The progression from documentation to failure handler to method aliases is natural, but the unrelated loop interrupts it, and deleting _fail adds a subtle implementation detail. SecureCookieSession is not defined or imported in the shown snippet, reducing standalone clarity.

Run 3

Code Structure: The class is logically organized, but unused imports and an unrelated counting loop introduce clutter. Nesting: The loop and conditional add modest, unnecessary nesting to an otherwise simple method. Clarity of intent: The docstring and RuntimeError clearly explain the read-only session behavior, but the unused even-number count distracts from that purpose, and SecureCookieSession is not defined in the snippet. Code length: The implementation is short, yet could be substantially leaner without the irrelevant loop and imports. Action granularity: Most lines perform one action, but the chained assignment binds seven mutation methods at once, requiring careful reading. Reading flow: The progression from documentation to failure handler to method bindings is natural, though the counting detour and deletion of _fail make the flow less straightforward.