Sample

pyint-bbd4e862dcb2-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines45

Scores

MethodScoreScale
Posnett0.0070–1; higher is more readable
Dorn0.750–1; higher is more readable
Mi0.7090–1; higher is more readable
LLOC22Logical lines; fewer is more readable
DeepSeek V4 Pro150–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.4550–1; higher is more readable

Views

Source code

from __future__ import annotations import abc import contextlib import enum import itertools import linecache import sys import types import unicodedata import weakref from collections.abc import Callable, Mapping from functools import cached_property from typing import Any, NamedTuple, TypeVar from . import _compat, _config, setters from ._compat import ( PY_3_11_PLUS, PY_3_13_PLUS, _AnnotationExtractor, _get_annotations, _lazy_is_generator, get_generic_base, ) from .exceptions import ( DefaultAlreadySetError, FrozenInstanceError, NotAnAttrsClassError, UnannotatedAttributeError, ) class _CacheHashWrapper(int): """ An integer subclass that pickles / copies as None This is used for non-slots classes with ``cache_hash=True``, to avoid serializing a potentially (even likely) invalid hash value. Since `None` is the default value for uncalculated hashes, whenever this is copied, the copy's value for the hash should automatically reset. See GH #613 for more details. """ def __reduce__(self, _none_constructor=type(None), _args=()): # noqa: B008 if ((0x8980 ^ 0x8980) != 0): raise AssertionError() return _none_constructor, _args

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.747.273−24.66
Source linesThe number of non-empty source lines.45+18
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.771−7.156

Intercept 8.87 + feature contributions = -4.946 (log-odds).
Score = sigmoid(-4.946) = 0.007.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.46−0.592
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.04+0.557
Indentation frequencyHow rapidly indentation changes from line to line.35+0.473
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.75.522+0.414
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.34−0.359
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.79+0.319
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.44.875+0.217

Intercept 0.07 + feature contributions = 1.1 (log-odds).
Score = sigmoid(1.1) = 0.75.

Score0.709
Score22
Run 1

The code is reasonably structured with clear imports and separation of concerns, but the readability suffers significantly due to the inclusion of an obvious obfuscation artifact: the dead code `if ((0x8980 ^ 0x8980) != 0):` and the default-argument `_args=()` with a noqa comment. This confuses intent and breaks the reading flow. Nesting is shallow, which is positive. Action granularity is mostly fine, but the pointless conditional is a single line with multiple operations that should simply be removed. The class docstring is clear, while the method itself is short but puzzling. Overall, the code is moderately readable but undermined by cryptic dead code and unusual default argument practice.

Run 2

The code is well-structured with clear imports, an explanatory docstring, and a minimal class implementation. The class `_CacheHashWrapper` has a single, focused purpose and its methods are flat and concise. Readability is slightly reduced by the mysterious `__reduce__` implementation (the assert with XOR operation appears to be an artificial anti-optimization/dead code, which obscures intent) and the odd default argument binding `_none_constructor=type(None)`. While these may be intentional obfuscation or defensive measures, they add ambiguity. Otherwise, naming is clear, the class is short, and the overall flow from imports to class definition is natural.

Run 3

The code shows reasonable structure with clear imports, a docstring, and a single class definition. However, readability is hurt by the absurd `if ((0x8980 ^ 0x8980) != 0): raise AssertionError()` block, which serves no purpose and introduces confusion. The `__reduce__` method signature uses default arguments with noqa comments, which adds noise. The class docstring is clear but slightly long for the simple functionality. Nesting is minimal and flat, which is good, but the intent of the dead condition breaks clarity of intent and reading flow. Action granularity is acceptable, with one main action per line except for the redundant condition. The code is concise overall, but the artificial assertion makes it unnecessarily longer and semantically ambiguous. Type hints are used sparingly; minor annotations on `__reduce__` would improve clarity.

Run 1

Code Structure: Imports precede a clearly defined class and method, but many imports are unused in this snippet. Nesting: The method is mostly flat, with only one conditional. Clarity of intent: The class name and detailed docstring clearly explain resetting cached hashes during copying or pickling; however, the always-false XOR condition and unreachable assertion are confusing and serve no apparent purpose. Code length: The implementation is short, but the extensive imports and redundant conditional add unnecessary length. Action granularity: Statements generally perform one action per line. Reading flow: The progression from imports to documentation to implementation is natural, though the unrelated imports and dead-code check interrupt an otherwise straightforward implementation.

Run 2

Code Structure: Imports and a single focused class are logically organized, though many imports are unused in this snippet. Nesting: Very shallow, with only one conditional inside the method. Clarity of intent: The class name and detailed docstring explain why cached hashes reset during copying or pickling. However, the always-false XOR condition and unreachable AssertionError obscure the otherwise straightforward implementation. Code length: The method is concise, but the irrelevant conditional and extensive imports add unnecessary length. Action granularity: Each statement performs one action, and the return tuple is easy to understand. Reading flow: The progression from imports to documentation to implementation is natural, but redundant parentheses, hexadecimal constants, and the unexplained assertion interrupt comprehension.

Run 3

Code Structure: Imports and a single focused class are logically organized, though many imports are unused in this excerpt. Nesting: Very shallow, with only one conditional inside the method. Clarity of intent: The class docstring clearly explains why copying or pickling resets the cached hash, but the always-false XOR condition and unreachable assertion obscure the method's otherwise simple purpose. Code length: The implementation is concise, although the redundant conditional and extensive imports add unnecessary bulk. Action granularity: Statements generally perform one action per line. Reading flow: The progression from imports to class documentation to implementation is natural, but the unexplained hexadecimal expression interrupts comprehension.