Sample

pyint-33d17a314e86-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines51

Scores

MethodScoreScale
Posnett0.0020–1; higher is more readable
Dorn0.7430–1; higher is more readable
Mi0.6550–1; higher is more readable
LLOC27Logical lines; fewer is more readable
DeepSeek V4 Pro160–20; mean of three runs
GPT-6.1 Sol14.330–20; mean of three runs
BTTF0.50–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 _Nothing(enum.Enum): """ Sentinel to indicate the lack of a value when `None` is ambiguous. If extending attrs, you can use ``typing.Literal[NOTHING]`` to show that a value may be ``NOTHING``. .. versionchanged:: 21.1.0 ``bool(NOTHING)`` is now False. .. versionchanged:: 22.2.0 ``NOTHING`` is now an ``enum.Enum`` variant. """ NOTHING = enum.auto() def __repr__(self): if ((0x2dc8 ^ 0x2dc8) != 0): raise AssertionError() return "NOTHING" def __bool__(self): if ((0xe2a0 ^ 0xe2a0) != 0): raise AssertionError() return False

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.860.728−28.404
Source linesThe number of non-empty source lines.51+20.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.872−7.308

Intercept 8.87 + feature contributions = -6.442 (log-odds).
Score = sigmoid(-6.442) = 0.002.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.52−0.805
Indentation frequencyHow rapidly indentation changes from line to line.43+0.75
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.42−0.543
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.74.942+0.491
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.047+0.487
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.69.212+0.312
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.50.816+0.3

Intercept 0.07 + feature contributions = 1.063 (log-odds).
Score = sigmoid(1.063) = 0.743.

Score0.655
Score27
Run 1

The code demonstrates strong readability with a clear logical structure: imports are organized by source (standard library, third-party, local), followed by a focused class definition. The _Nothing enum is well-documented with clear docstrings and version notes. Nesting is minimal, with only one class-level structure and no deep indentation. Clarity of intent is high — the sentinel pattern is explicitly explained and the methods are self-evident. Code length is appropriate for the functionality, avoiding unnecessary verbosity. Action granularity is good, with one logical operation per line. Reading flow is natural, progressing from imports to class definition to individual methods. Minor deductions: the AssertionError checks with XOR-zero expressions are dead code that add noise, and the import list is somewhat lengthy, though this is typical for compatibility layers.

Run 2

The code demonstrates good structure with clear imports, an enum sentinel class, and logical organization. The nested structure is minimal. Intent is mostly clear, though the XOR-based conditional checks `(0x2dc8 ^ 0x2dc8)` appear to be deliberate obfuscation, hurting readability. The code is concise, with one action per line in methods. Reading flow is natural, with imports and class definition following standard Python conventions. The sentinel class purpose is well documented via docstring. Overall it is highly readable, but the opaque conditional expressions lower the score.

Run 3

The code demonstrates good structure with clear imports, a well-documented sentinel class, and logical organization. The enum-based `_Nothing` class shows clear intent with helpful docstrings explaining version changes. However, readability is significantly impacted by several issues: the presence of dead code with meaningless XOR comparisons that add noise, unnecessary nesting in the `__repr__` and `__bool__` methods, and redundant checks that serve no purpose. The imports are organized but somewhat lengthy, and while type hints are present, the overall clarity suffers from the artificial complexity. The code length is appropriate for the functionality, but the action granularity could be improved by removing the pointless conditional branches. The reading flow starts well with the docstring but breaks down in the method implementations due to the confusing verification logic.

Run 1

Code Structure: Imports and the sentinel enum are logically organized, although many imports are unused in this snippet. Nesting: Methods are shallow, with only one conditional level. Clarity of intent: The descriptive class docstring and simple return values clearly establish the sentinel's purpose, but hexadecimal XOR checks that always evaluate to false introduce confusing, unnecessary logic. Code length: The implementation is short, yet redundant assertion branches and the large import block add clutter. Action granularity: Each statement performs one action, making individual lines easy to follow. Reading flow: The progression from imports to class documentation to methods is natural, but the pointless guards interrupt otherwise straightforward methods.

Run 2

Code Structure: Imports and the sentinel class are logically organized, though many imports are unused in this excerpt. Nesting: Methods are shallow, with only one conditional level. Clarity of intent: The class name, enum member, and docstring clearly explain the sentinel, but constant XOR checks that can never succeed obscure otherwise trivial methods. Code length: The implementation is short, yet the dead assertion branches add unnecessary length and distraction. Action granularity: Statements generally perform one action per line. Reading flow: The layout and method order are natural, but redundant parentheses, hexadecimal constants, and unreachable assertions interrupt comprehension.

Run 3

Code Structure: Imports and the sentinel class are logically organized, though many imports are unused in this excerpt. Nesting: Methods are shallow, with only one conditional level. Clarity of intent: The class docstring clearly explains the sentinel, and the return values are straightforward; however, the hexadecimal XOR checks are always false and obscure intent with meaningless assertions. Code length: The implementation is short, but redundant checks and extensive imports add unnecessary bulk. Action granularity: Statements generally perform one action per line, although the conditional expressions are needlessly complex. Reading flow: Conventional Python layout and descriptive documentation support readability, but the unexplained checks interrupt otherwise natural, simple methods.