Sample

pyint-25a1bf88b3ab-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines29

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7620–1; higher is more readable
Mi0.3590–1; higher is more readable
LLOC19Logical lines; fewer is more readable
DeepSeek V4 Pro13.330–20; mean of three runs
GPT-6.1 Sol13.330–20; mean of three runs
BTTF0.390–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: if ((0x2bf2 ^ 0x2bf2) != 0): raise AssertionError() 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.720.458−23.775
Source linesThe number of non-empty source lines.29+11.6
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.568−6.853

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

Feature contributions

FeatureValueContribution
(log-odds)
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.041+0.541
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.77.6+0.448
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.26−0.176
Indentation frequencyHow rapidly indentation changes from line to line.26+0.162
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.933+0.152
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.30−0.026
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.28.929−0.005

Intercept 0.07 + feature contributions = 1.166 (log-odds).
Score = sigmoid(1.166) = 0.762.

Score0.359
Score19
Run 1

The code is fairly readable with clear class documentation explaining its purpose. It uses descriptive naming (NullSession, _fail) and proper type hints. However, some issues reduce clarity: the bizarre dead condition `if ((0x2bf2 ^ 0x2bf2) != 0):` is confusing and should be removed; multiple assignments on one line (`__setitem__ = __delitem__ = ... = _fail`) compress several actions into a single statement, reducing granularity; the `del _fail` line is cryptic without context; and the class inherits from `SecureCookieSession` which isn't imported in the snippet, making the code incomplete. Several imports appear unused (`hashlib`, `datetime`, `timezone`, `BadSignature`, `URLSafeTimedSerializer`) which adds noise. The logic is flat and the flow is coherent, but the unexplained obfuscated condition and the multi-method aliasing line hurt readability.

Run 2

The code is relatively short and each method assignment is on one line, which aids action granularity. However, readability suffers from several issues: the class inherits from SecureCookieSession without an import visible in the snippet, creating ambiguity. The unnecessary XOR check in _fail is confusing and misleading. Multiple method assignments chained on a single line reduce clarity, as each assignment is not clearly separated. The 'del _fail' statement is unusual and may obscure intent. The docstring is helpful but overall the code mixes clear structure with puzzling constructs, leading to moderate readability.

Run 3

The code is moderately readable but has some notable issues. The class structure is logical with a clear docstring explaining purpose, and the error message is descriptive. However, there is a suspicious dead code segment (`if ((0x2bf2 ^ 0x2bf2) != 0):`) that adds confusion and unnecessary nesting. The method `_fail` is well-named and its intent is clear, but the multiple assignment of `_fail` to many methods on one line reduces clarity and action granularity. The `del _fail` line is also confusing without context. Overall, the code is concise but could be clearer with better separation of concerns and removal of the odd conditional check.

Run 1

Code Structure: The small class logically groups session mutation failures, although numerous unused imports and an undefined base class in the snippet distract. Nesting: Shallow, with only one conditional inside the method. Clarity of intent: The docstring and RuntimeError clearly explain read-only behavior, but the hexadecimal XOR condition is always false and unnecessarily obscures intent. Code length: Mostly concise, though the dead conditional and unused imports add noise. Action granularity: Most lines perform one action, but assigning seven mutation methods in one chained statement reduces scanability. Reading flow: The progression from documentation to failure handler to method aliases is natural; deleting the helper and the unexplained dead assertion interrupt that flow.

Run 2

Code Structure: The class is logically organized, but numerous unused imports and an undefined-in-snippet base class add clutter and context dependence. Nesting: Minimal nesting makes the method easy to follow. Clarity of intent: The docstring and RuntimeError clearly explain why session mutations fail, but the hexadecimal XOR condition is opaque, always false, and distracts from that purpose. Code length: The class is concise, although the dead assertion branch and unused imports are unnecessary. Action granularity: Most lines express a single action; the long chained assignment binds seven mutation methods at once, requiring extra interpretation. Reading flow: The progression from documentation to error handler to method bindings is natural, but the irrelevant condition and deletion of the helper interrupt straightforward reading.

Run 3

Code Structure: The class is logically organized, but numerous unused imports and an undefined base class in the snippet add clutter. Nesting: Shallow nesting makes the methods easy to follow. Clarity of intent: The docstring and RuntimeError clearly explain the read-only session behavior, while the hexadecimal XOR condition is opaque, always false, and unnecessary. Code length: The implementation is compact, though imports and dead code inflate it. Action granularity: Most lines contain one action, but assigning seven mutation methods to _fail in a single statement reduces scanability. Reading flow: The progression from documentation to failure handler to method aliases is natural, but the dead assertion branch and deletion of _fail interrupt straightforward reading.