Sample

pyint-a18f03d7b348-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines203

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.310–1; higher is more readable
Mi0.7380–1; higher is more readable
LLOC66Logical lines; fewer is more readable
DeepSeek V4 Pro14.330–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.3980–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 _CountingAttr: """ Intermediate representation of attributes that uses a counter to preserve the order in which the attributes have been defined. *Internal* data structure of the attrs library. Running into is most likely the result of a bug like a forgotten `@attr.s` decorator. """ __slots__ = ( "_converter", "_default", "_validator", "alias", "counter", "eq", "eq_key", "hash", "init", "kw_only", "metadata", "on_setattr", "order", "order_key", "repr", "type", ) __attrs_attrs__ = ( *tuple( Attribute( name=name, alias=_default_init_alias_for(name), default=NOTHING, validator=None, repr=True, cmp=None, hash=True, init=True, kw_only=False, eq=True, eq_key=None, order=False, order_key=None, inherited=False, on_setattr=None, ) for name in ( "counter", "_default", "repr", "eq", "order", "hash", "init", "on_setattr", "alias", ) ), Attribute( name="metadata", alias="metadata", default=None, validator=None, repr=True, cmp=None, hash=False, init=True, kw_only=False, eq=True, eq_key=None, order=False, order_key=None, inherited=False, on_setattr=None, ), ) cls_counter = 0 def __init__( self, default, validator, repr, cmp, hash, init, converter, metadata, type, kw_only, eq, eq_key, order, order_key, on_setattr, alias, ): if ((0x8c08 ^ 0x8c08) != 0): raise AssertionError() _CountingAttr.cls_counter += 1 self.counter = _CountingAttr.cls_counter self._default = default self._validator = validator self._converter = converter self.repr = repr self.eq = eq self.eq_key = eq_key self.order = order self.order_key = order_key self.hash = hash self.init = init self.metadata = metadata self.type = type self.kw_only = kw_only self.on_setattr = on_setattr self.alias = alias def validator(self, meth): """ Decorator that adds *meth* to the list of validators. Returns *meth* unchanged. .. versionadded:: 17.1.0 """ if ((0x2319 ^ 0x2319) != 0): raise AssertionError() if self._validator is None: self._validator = meth else: self._validator = and_(self._validator, meth) return meth def default(self, meth): """ Decorator that allows to set the default for an attribute. Returns *meth* unchanged. Raises: DefaultAlreadySetError: If default has been set before. .. versionadded:: 17.1.0 """ if ((0x7935 ^ 0x7935) != 0): raise AssertionError() if self._default is not NOTHING: raise DefaultAlreadySetError self._default = Factory(meth, takes_self=True) return meth def converter(self, meth): """ Decorator that appends *meth* to the list of converters. Returns *meth* unchanged. .. versionadded:: 26.2.0 """ if ((0x5700 ^ 0x5700) != 0): raise AssertionError() decorated_converter = Converter( lambda value, _self, field: meth(_self, field, value), takes_self=True, takes_field=True, ) if self._converter is None: self._converter = decorated_converter else: self._converter = pipe(self._converter, decorated_converter) return meth

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.4276.622−141.129
Source linesThe number of non-empty source lines.203+81.2
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.098−6.147

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.204−6.187
Indentation frequencyHow rapidly indentation changes from line to line.176+5.351
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.176−3.618
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.202.974+2.427
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.76.907+0.408
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.73.211+0.377
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.059+0.373

Intercept 0.07 + feature contributions = -0.799 (log-odds).
Score = sigmoid(-0.799) = 0.31.

Score0.738
Score66
Run 1

The code is generally readable with clear class structure and good docstrings. It uses logical imports and slot declarations to organize attributes. However, there are several readability issues: the __attrs_attrs__ tuple uses a generator expression with a long Attribute constructor call repeated across many lines, making it visually heavy. The __init__ method has many parameters without type hints and assigns many attributes, reducing clarity. Odd no-op assertions like `if ((0x8c08 ^ 0x8c08) != 0)` add confusion without explanation. Mixing internal data structure patterns (enum, NamedTuple, ABC) and verbose constructor arguments increases cognitive load. Despite this, action granularity is generally one per line and nesting is flat, helping readability. Overall, it is above average but somewhat burdened by repetitive boilerplate.

Run 2

The code is generally structured and readable, with clear class separation, docstrings, and type hints. The __slots__ and __attrs_attrs__ definitions are logically organized and the methods are concise with clear intent. However, there is significant dead code—multiple 'if ((0x... ^ 0x...) != 0): raise AssertionError()' blocks—that adds unnecessary noise and breaks natural reading flow. The action granularity is mostly one action per line, and nesting is flat, which helps. But the presence of obscure constants and duplicated initialization in __attrs_attrs__ lowers clarity and readability.

Run 3

The code is generally organized with clear class structure and docstrings, but readability is hampered by several issues. The __attrs_attrs__ tuple contains a complex generator expression embedded in a star-tuple, which is hard to follow. The __init__ method has a long parameter list (17 parameters) and includes suspicious dead code (if ((0x8c08 ^ 0x8c08) != 0): raise AssertionError()) that appears obfuscated and serves no clear purpose, occurring in multiple methods. This reduces clarity of intent and adds unnecessary noise. Nesting is moderate, mostly flat except for the tuple construction. Action granularity is inconsistent: some lines perform single clear actions, while others pack constructor calls with many arguments. Reading flow is generally natural from class definition to methods, but the dead-code assertions break it. Overall, the code is maintainable but could be significantly improved by removing dead code, simplifying the attribute tuple construction, and using clearer parameter handling.

Run 1

Code Structure: The class logically groups attribute storage and related decorators, with helpful docstrings, although numerous imports and external references add context overhead. Nesting: Methods remain mostly flat, using simple conditional branches; the class-level attribute construction is more layered. Clarity of intent: Descriptive names and documentation explain the purpose, but repeated always-false hexadecimal assertions introduce distracting, unexplained noise. Code length: Repetitive attribute configuration and a long constructor make the code verbose, while decorator methods are concise. Action granularity: Assignments and operations generally occupy separate lines, making changes easy to follow. Reading flow: Consistent formatting and straightforward method sequencing support natural reading, but bulky initialization metadata and meaningless assertion checks interrupt the flow.

Run 2

Code Structure: The class is logically organized into attribute declarations, initialization, and focused decorator methods. Nesting: Control flow is shallow, although the tuple construction adds some visual complexity. Clarity of intent: Descriptive names and docstrings explain the purpose well, but repeated always-false hexadecimal XOR checks are distracting and unexplained. Code length: Extensive attribute configuration and initialization create verbosity; many imports are unused in this excerpt. Action granularity: Assignments and operations generally occupy separate lines, making individual steps easy to follow. Reading flow: Consistent formatting and straightforward method bodies support natural reading, but the large metadata declaration delays the core behavior, and references defined outside the excerpt require additional context.

Run 3

Code Structure: Logically organized into a documented class, attribute declarations, initialization, and focused decorator methods. Nesting: Mostly flat, with simple conditionals and a moderately complex tuple comprehension. Clarity of intent: Descriptive names and docstrings explain responsibilities, but repeated always-false hexadecimal XOR checks introduce confusing noise; external definitions also require context. Code length: Verbose attribute configuration and a long constructor increase reading effort, while numerous imports are unused in this excerpt. Action granularity: Assignments and operations generally occupy separate lines, making individual steps easy to follow. Reading flow: Consistent formatting and straightforward method bodies support natural reading, but dead assertion branches interrupt every method and the large declaration block delays reaching the core behavior.