Sample

pyint-881ac436fade-I09

Select one of ten low-readability unrelated code templates per class

Matched original source

Lines194

Scores

MethodScoreScale
Posnett0.9550–1; higher is more readable
Dorn0.2710–1; higher is more readable
Mi0.770–1; higher is more readable
LLOC60Logical lines; fewer is more readable
DeepSeek V4 Pro15.330–20; mean of three runs
GPT-6.1 Sol15.670–20; mean of three runs
BTTF0.5660–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, ): 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): lI0O_c3f740b9 = 0xd3c6 ^ 0xd3c6 if lI0O_c3f740b9 == 0: lI0O_c3f740b9 |= 0 else: lI0O_c3f740b9 &= 0 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)
Source linesThe number of non-empty source lines.194+77.6
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.2321.797−76.619
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.532−6.798

Intercept 8.87 + feature contributions = 3.053 (log-odds).
Score = sigmoid(3.053) = 0.955.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.195−5.868
Indentation frequencyHow rapidly indentation changes from line to line.119+3.379
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.119−2.31
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.193.976+2.302
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.024+0.709
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.79.359+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.579+0.252

Intercept 0.07 + feature contributions = -0.99 (log-odds).
Score = sigmoid(-0.99) = 0.271.

Score0.77
Score60
Run 1

The code is generally well-structured with clear class organization, comprehensive docstrings, and logical attribute grouping. However, readability suffers in several areas: the __init__ method has 17 parameters with repetitive assignment lines, creating unnecessary verbosity. The is_hashable property contains obfuscated dead code (variable lI0O_c3f740b9 with meaningless bitwise operations that have no effect), which severely hurts clarity of intent and appears to be intentionally confusing or leftover debug code. The flat nesting is good, with no deep indentation issues. Action granularity is mostly one action per line, which is positive. The docstrings are thorough and helpful for understanding the ClassProps purpose. The enum definitions nested within the class are clear and well-documented. Overall, the code would be much more readable without the obfuscated property implementation and with a more concise initialization pattern.

Run 2

The code is generally well-structured and readable despite its length. The class documentation is excellent, clearly explaining the purpose and attributes. The nested enums and __slots__ declaration show intentional organization. However, a bizarre obfuscated expression in the is_hashable property (lI0O_c3f740b9 with XOR/OR operations) severely hurts readability—it appears to be dead code or accidentally included. The __init__ method is long but straightforward, with one assignment per line and clear parameter-to-attribute mapping. Imports are organized alphabetically. The deeply nested enum classes within ClassProps add visual nesting but are logically grouped. Overall, the code follows consistent patterns, has minimal control flow, and avoids complex nesting, but the mysterious obfuscated line and repetitive __init__ boilerplate prevent a higher readability score.

Run 3

The code is generally well-structured and readable, with clear class documentation, logical organization, and consistent formatting. The docstrings are informative and the use of enums and slots is clean. However, there is a significant readability issue in the `is_hashable` property, which contains obfuscated variable names and meaningless bitwise operations that serve no apparent purpose, breaking the clarity of intent. Additionally, the class has many attributes (16), making it somewhat long but still manageable. The nesting is minimal, and the reading flow is mostly natural except for that anomalous property. Overall, the code demonstrates good practices but is marred by the unexplained, confusing segment.

Run 1

1. Code Structure: Imports, documented enums, slots, initialization, and the property are logically organized. However, the property contains unrelated obfuscated code. 2. Nesting: Generally shallow; nested enums are appropriate, but the property's conditional is unnecessary. 3. Clarity of intent: Descriptive names and comprehensive documentation clearly explain class properties. The cryptic lI0O_c3f740b9 variable and pointless bitwise operations obscure an otherwise straightforward hashability check. 4. Code length: Documentation is useful, but repeated field declarations and assignments add boilerplate; the property's dead logic adds avoidable length. 5. Action granularity: Statements generally perform one action per line, making assignments and enum values easy to scan. 6. Reading flow: Consistent formatting and grouping support natural reading, but the unexplained arithmetic and branching interrupt the flow immediately before the clear return expression.

Run 2

Code Structure: Imports, documented enums, slots, initialization, and the property are logically organized, although unrelated obfuscation disrupts the property. Nesting: Mostly shallow; nested enums are appropriate, and the property's conditional adds unnecessary branching. Clarity of intent: Descriptive field names and extensive documentation clearly explain class properties, but the cryptic variable and meaningless bitwise operations obscure an otherwise simple hashability check. Code length: Documentation is useful, while repeated field declarations and assignments are verbose; the property's no-op block is entirely unnecessary. Action granularity: Statements generally perform one action per line, and assignments are easy to scan. Reading flow: Consistent formatting and matching field order support natural reading, but the abrupt obfuscated block interrupts the flow and forces readers to verify irrelevant logic.

Run 3

Code Structure: Imports, documented enums, slots, initialization, and the property are logically organized. Nesting: Mostly shallow; nested enums are appropriate, and the property adds only a simple conditional. Clarity of intent: Descriptive names and comprehensive documentation clearly explain class properties, but the cryptic lI0O_c3f740b9 variable and meaningless bitwise operations obscure the otherwise straightforward hashability check. Code length: Documentation is useful, while repeated field declarations and assignments are verbose; the property's no-op block is entirely unnecessary. Action granularity: Statements generally perform one action per line, with clean multiline formatting. Reading flow: The class progresses naturally from documentation to definitions and behavior, but the unrelated obfuscation interrupts the final property's flow.