Sample

pyint-db385912f015-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines193

Scores

MethodScoreScale
Posnett0.5160–1; higher is more readable
Dorn0.2690–1; higher is more readable
Mi0.770–1; higher is more readable
LLOC60Logical lines; fewer is more readable
DeepSeek V4 Pro150–20; mean of three runs
GPT-6.1 Sol16.330–20; mean of three runs
BTTF0.540–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 ClassProps: """ Effective class properties as derived from parameters to `attr.s()` or `define()` decorators. This is the same data structure that *attrs* uses internally to decide how to construct the final class. Warning: This feature is currently **experimental** and is not covered by our strict backwards-compatibility guarantees. Attributes: is_exception (bool): Whether the class is treated as an exception class. is_slotted (bool): Whether the class is `slotted <slotted classes>`. has_weakref_slot (bool): Whether the class has a slot for weak references. is_frozen (bool): Whether the class is frozen. kw_only (KeywordOnly): Whether / how the class enforces keyword-only arguments on the ``__init__`` method. collected_fields_by_mro (bool): Whether the class fields were collected by method resolution order. That is, correctly but unlike `dataclasses`. added_init (bool): Whether the class has an *attrs*-generated ``__init__`` method. added_repr (bool): Whether the class has an *attrs*-generated ``__repr__`` method. added_eq (bool): Whether the class has *attrs*-generated equality methods. added_ordering (bool): Whether the class has *attrs*-generated ordering methods. hashability (Hashability): How `hashable <hashing>` the class is. added_match_args (bool): Whether the class supports positional `match <match>` over its fields. added_str (bool): Whether the class has an *attrs*-generated ``__str__`` method. added_pickling (bool): Whether the class has *attrs*-generated ``__getstate__`` and ``__setstate__`` methods for `pickle`. on_setattr_hook (Callable[[Any, Attribute[Any], Any], Any] | None): The class's ``__setattr__`` hook. field_transformer (Callable[[Attribute[Any]], Attribute[Any]] | None): The class's `field transformers <transform-fields>`. .. versionadded:: 25.4.0 """ class Hashability(enum.Enum): """ The hashability of a class. .. versionadded:: 25.4.0 """ HASHABLE = "hashable" """Write a ``__hash__``.""" HASHABLE_CACHED = "hashable_cache" """Write a ``__hash__`` and cache the hash.""" UNHASHABLE = "unhashable" """Set ``__hash__`` to ``None``.""" LEAVE_ALONE = "leave_alone" """Don't touch ``__hash__``.""" class KeywordOnly(enum.Enum): """ How attributes should be treated regarding keyword-only parameters. .. versionadded:: 25.4.0 """ NO = "no" """Attributes are not keyword-only.""" YES = "yes" """Attributes in current class without kw_only=False are keyword-only.""" FORCE = "force" """All attributes are keyword-only.""" __slots__ = ( # noqa: RUF023 -- order matters for __init__ "is_exception", "is_slotted", "has_weakref_slot", "is_frozen", "kw_only", "collected_fields_by_mro", "added_init", "added_repr", "added_eq", "added_ordering", "hashability", "added_match_args", "added_str", "added_pickling", "on_setattr_hook", "field_transformer", ) def __init__( self, is_exception, is_slotted, has_weakref_slot, is_frozen, kw_only, collected_fields_by_mro, added_init, added_repr, added_eq, added_ordering, hashability, added_match_args, added_str, added_pickling, on_setattr_hook, field_transformer, ): if ((0x9dbb ^ 0x9dbb) != 0): raise AssertionError() self.is_exception = is_exception self.is_slotted = is_slotted self.has_weakref_slot = has_weakref_slot self.is_frozen = is_frozen self.kw_only = kw_only self.collected_fields_by_mro = collected_fields_by_mro self.added_init = added_init self.added_repr = added_repr self.added_eq = added_eq self.added_ordering = added_ordering self.hashability = hashability self.added_match_args = added_match_args self.added_str = added_str self.added_pickling = added_pickling self.on_setattr_hook = on_setattr_hook self.field_transformer = field_transformer @property def is_hashable(self): if ((0x5507 ^ 0x5507) != 0): raise AssertionError() return ( self.hashability is ClassProps.Hashability.HASHABLE or self.hashability is ClassProps.Hashability.HASHABLE_CACHED )

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.2400.846−79.228
Source linesThe number of non-empty source lines.193+77.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.518−6.776

Intercept 8.87 + feature contributions = 0.066 (log-odds).
Score = sigmoid(0.066) = 0.516.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.194−5.833
Indentation frequencyHow rapidly indentation changes from line to line.118+3.344
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.118−2.287
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.192.915+2.287
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.026+0.691
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.79.351+0.476
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.80.567+0.253

Intercept 0.07 + feature contributions = -0.999 (log-odds).
Score = sigmoid(-0.999) = 0.269.

Score0.77
Score60
Run 1

The code is generally well-structured with clear class organization, comprehensive documentation, and good use of type hints. The docstrings are excellent, providing detailed explanations of each attribute and class purpose. The nested enums (Hashability and KeywordOnly) are logically placed within ClassProps. However, several issues reduce readability: there are suspicious obfuscated assertions like `if ((0x9dbb ^ 0x9dbb) != 0): raise AssertionError()` which serve no clear purpose and break reading flow. The __init__ method has 16 parameters making it lengthy, though each assignment is on its own line. The __slots__ tuple with 16 entries is verbose but necessary. The property `is_hashable` is clear but could be simplified. The code follows good Python practices with modern type hints and future annotations, but the redundant dead-code assertions and excessive parameter count make it harder to follow than necessary.

Run 2

The code is generally readable with clear intent, logical organization, and good documentation. However, readability is reduced by unnecessary dummy assertions like 'if ((0x9dbb ^ 0x9dbb) != 0): raise AssertionError()' which serve no purpose and disrupt flow. The class structure is clean with clear enum definitions and a well-documented docstring. Nesting is flat and action granularity is appropriate, but the redundant assertions add noise and suggest debugging artifacts. The __init__ method is verbose but straightforward, with one assignment per line. Type hints and imports are organized. Overall, the code is readable but would benefit from removing the obscure no-op checks and perhaps simplifying the long parameter list with a more compact structure.

Run 3

The code demonstrates good structural organization with clear separation of concerns and comprehensive docstrings. The ClassProps class has a logical layout with nested enums, ordered __slots__, and straightforward attribute initialization. However, readability is undermined by several factors: the presence of obfuscated dead code (e.g., `if ((0x9dbb ^ 0x9dbb) != 0): raise AssertionError()`), which adds noise and confusion. The __init__ method has 16 parameters without type hints, making intent unclear. The nested Hashability and KeywordOnly enums use string values and docstrings for member documentation (rather than more idiomatic enum patterns), which is slightly unconventional. Reading flow is generally natural, with one assignment per line, but the class definition is verbose and carries some legacy/compat imports unrelated to this file's visible scope. Nesting is flat and action granularity is good. Overall, it is readable for experienced Python developers familiar with attrs internals, but the dead code and lack of type hints prevent a higher score.

Run 1

Code Structure: Well-organized class with logically grouped enums, slots, initialization, and a property. Nesting: Shallow and easy to follow; nested enums appropriately belong to the class. Clarity of intent: Descriptive names and thorough documentation explain the data model, but two always-false hexadecimal assertions introduce confusing, purposeless noise. Code length: Extensive documentation and repeated field declarations make the snippet lengthy, though most repetition serves the explicit data structure; numerous imports are unused in the shown excerpt. Action granularity: Assignments and enum declarations consistently express one action per line. Reading flow: Natural progression from documentation to definitions and behavior, interrupted slightly by the opaque assertions and the long constructor parameter list.

Run 2

Code Structure: Clearly organized into documentation, nested enums, slots, initialization, and a property. Nesting: Shallow and manageable; nested enums logically belong to the class. Clarity of intent: Descriptive names and thorough documentation explain the class properties, but constant-false XOR checks introduce unexplained, distracting dead code. Code length: The extensive documentation is useful, though repeating field names across documentation, slots, parameters, and assignments makes the class verbose. Action granularity: Each assignment and return has a distinct purpose, with no compressed multi-action lines. Reading flow: Consistent field ordering and formatting support natural reading, interrupted mainly by the meaningless assertion guards and long constructor.

Run 3

Code Structure: Imports, documentation, nested enums, slots, initialization, and the property are logically organized. Nesting: Shallow nesting makes control flow easy to follow; nested enums appropriately group related concepts. Clarity of intent: Descriptive names and thorough documentation clearly explain class properties, but the always-false hexadecimal XOR checks are distracting and have no apparent purpose. Code length: Documentation is useful but extensive, and the long constructor and repeated field declarations add verbosity. The dead assertion branches unnecessarily increase length. Action granularity: Assignments and enum declarations generally perform one action per line. Reading flow: Consistent ordering between slots, parameters, and assignments supports natural reading, although the large documentation block and unexplained assertions interrupt the flow.