Sample

pyint-1482e4eecc88-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines27

Scores

MethodScoreScale
Posnett0.0010–1; higher is more readable
Dorn0.8610–1; higher is more readable
Mi0.3590–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro11.330–20; mean of three runs
GPT-6.1 Sol11.670–20; mean of three runs
BTTF0.5270–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 fai(self, *arg: t.Any, **kwa: t.Any) -> t.NoReturn: 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.618.286−20.403
Source linesThe number of non-empty source lines.27+10.8
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.525−6.787

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

Feature contributions

FeatureValueContribution
(log-odds)
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.034+0.611
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.80.071+0.487
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
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.893+0.154
Indentation frequencyHow rapidly indentation changes from line to line.24+0.093
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.28+0.045
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.26.893−0.034

Intercept 0.07 + feature contributions = 1.825 (log-odds).
Score = sigmoid(1.825) = 0.861.

Score0.359
Score17
Run 1

The code is difficult to read due to several critical issues. The method named 'fai' lacks an 'l', so it should likely be 'fail', while the alias assignment at the bottom references '_fail', which does not exist, causing a NameError at class definition time. This inconsistency severely harms clarity. The imports are scattered and contain unused or redundant aliases (e.g., collections.abc imported twice in different styles). The class overall is short, which helps length and nesting (flat structure), but the action granularity is poor: the __setitem__ assignment line crams many operations into one logical action, obscuring intent. Reading flow is broken by the naming mismatch and the misplaced 'del _fail' appearing after class-level assignments. The intent of NullSession is documented, but the implementation fails to match its own documentation and aliases, making it untrustworthy and hard to follow.

Run 2

The code has clear intent (a session class that fails on modification) and logical structure, but suffers from a critical bug: the method is defined as 'fai' but referenced as '_fail', and the reference is deleted afterward with 'del _fail'. This breaks readability and correctness. Nesting is flat and action granularity is generally fine, but the mutation of dunder methods through assignment is terse and may confuse readers unfamiliar with this pattern. The import block is slightly cluttered with unused or redundant imports (e.g., both 'collections.abc as c' and 'from collections.abc import MutableMapping'). Overall, the code is concise but ambiguous due to naming inconsistency and unconventional method assignment, lowering clarity and reading flow.

Run 3

The code is generally readable with clear intent and good structure. The class name and docstring clearly explain the purpose. Using a helper method to raise a consistent error is clean. However, the method name 'fai' appears to be a typo for 'fail', and the final line references '_fail' inconsistently, which introduces confusion. Assigning multiple dunder methods on one line reduces granularity and harms readability. Overall the code is concise and reasonably organized, but these naming inconsistencies and the condensed method assignments prevent a higher score.

Run 1

Code Structure: Imports and the session class are logically separated, but numerous unused imports add clutter, and SecureCookieSession is not defined or imported in the snippet. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The docstring and RuntimeError clearly explain read-only behavior when a secret key is missing. However, the method is named fai while the assignments and deletion reference _fail, creating a confusing inconsistency that prevents the class from being defined as shown. Code length: The class is concise, though its import block is disproportionate to the implementation. Action granularity: Most lines perform one action, but the long chained assignment binds seven methods at once and requires more attention. Reading flow: The progression from documentation to failure handler to method bindings is natural, but the naming mismatch and unexplained base class disrupt understanding.

Run 2

Code Structure: Imports and a small class are logically organized, but numerous unused imports add clutter, and SecureCookieSession is not defined or imported in the snippet. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The docstring and error message clearly explain read-only session behavior, but the method is named fai while assignments and deletion reference _fail, creating a confusing inconsistency. Code length: The implementation is concise, though the import list is disproportionate to its functionality. Action granularity: Most lines perform one action, but the chained assignment binds seven methods at once, reducing immediate readability. Reading flow: The progression from documentation to error handling to method bindings is natural, but the naming mismatch and undefined references interrupt comprehension.

Run 3

Code Structure: The class is logically organized, but numerous unused imports add clutter, and SecureCookieSession is not defined or imported in the snippet. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The docstring and error message clearly explain the read-only fallback behavior, but the method name 'fai' is unclear and conflicts with the undefined '_fail' used below. Code length: The implementation is concise, although the imports are excessive for the shown code. Action granularity: Most lines perform one action, but the chained assignment binds seven methods at once, reducing readability. Reading flow: The progression from documentation to error handling to method overrides is natural, but the naming mismatch and deletion of undefined '_fail' interrupt comprehension.