Sample

pyint-62b50613bdfc-I10

Deterministically remove some optional blank lines and bracketed line breaks

Matched original source

Lines157

Scores

MethodScoreScale
Posnett0.0020–1; higher is more readable
Dorn0.2450–1; higher is more readable
Mi0.5190–1; higher is more readable
LLOC56Logical lines; fewer is more readable
DeepSeek V4 Pro9.330–20; mean of three runs
GPT-6.1 Sol14.330–20; mean of three runs
BTTF0.5970–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): 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.2161.997−71.346
Source linesThe number of non-empty source lines.157+62.8
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.489−6.734

Intercept 8.87 + feature contributions = -6.41 (log-odds).
Score = sigmoid(-6.41) = 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.158−4.558
Indentation frequencyHow rapidly indentation changes from line to line.89+2.341
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.156.99+1.785
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.89−1.621
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.103.956+0.873
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.103.975−0.739
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.023+0.721

Intercept 0.07 + feature contributions = -1.128 (log-odds).
Score = sigmoid(-1.128) = 0.245.

Score0.519
Score56
Run 1

The code has several readability issues. Structure is logical (class definition with nested enums and properties) but formatting is inconsistent. Import statements and exception imports are oddly aligned. Nesting is acceptable - only one level deep in the property method. Clarity of intent is mixed: docstrings are helpful, but the class constructor has 17 parameters with no type hints or defaults, making it unclear how to instantiate. Code length is appropriate for the number of attributes. Action granularity is inconsistent - some __slots__ entries and parameter lists have multiple items per line while others don't. Reading flow suffers significantly from misaligned formatting, inconsistent spacing around assignment operators in __slots__, and the odd line breaks in parameters. The is_hashable property has unnecessary parentheses and line breaks. Overall, the code functions but formatting inconsistencies and lack of parameter documentation make it harder to read than necessary.

Run 2

The code has reasonable logical organization with clear class structure and documentation, but suffers from inconsistent formatting that harms readability. The imports are partially aligned but have awkward spacing and line breaks. The ClassProps class is well-documented with clear attributes, but the __slots__ tuple and __init__ method have poorly aligned continuation lines with inconsistent spacing. The nested enums are logically placed and the property method is concise, though the return statement has odd indentation. Overall, the code is understandable but the inconsistent formatting creates unnecessary cognitive overhead. The mixed alignment styles in multi-line statements make the code feel disorganized despite the logical structure being sound. Score reflects good structure but poor formatting consistency.

Run 3

The code has some good documentation but suffers from severe structural and formatting issues. The nested class definitions are clear, but the overall layout is chaotic. Many lines have inconsistent indentation and spacing (e.g., the __slots__ tuple, the __init__ parameters). This breaks the natural reading flow and makes the code difficult to scan. The imports contain misaligned items and unnecessary parentheses, adding to the confusion. While the ClassProps docstring is detailed and helpful, the __init__ parameter list has no type hints or defaults despite being a public constructor, reducing clarity of intent. Action granularity is violated in places (e.g., multiple items per line in __slots__ and imports), and the code length is reasonable but not concise due to repetitive formatting. Overall, the logic is understandable, but the poor formatting, inconsistent nesting, and lack of parameter annotations make it significantly less readable.

Run 1

Code Structure: Logically organized around a class, related enums, initialization, and a derived property, but inconsistent spacing weakens visual separation. Nesting: Shallow and appropriate; nested enums do not introduce complex control flow. Clarity of intent: Descriptive names and extensive documentation clearly explain the class properties and hashability behavior. Code length: Documentation is useful but dominates the snippet; the long constructor and repetitive assignments add scanning overhead. Action granularity: Assignments consistently perform one action per line, although multiple imports, slot names, and parameters are awkwardly grouped on some lines. Reading flow: The overall progression is natural, but irregular indentation, crowded declarations, and missing blank lines interrupt readability.

Run 2

Code Structure: The class is logically organized into documentation, related enums, slots, initialization, and a derived property, although missing blank lines weaken separation. Nesting: Shallow and appropriate; nested enums introduce little complexity. Clarity of intent: Descriptive names and extensive documentation clearly explain the data model and hashability check, though constructor parameters lack type annotations. Code length: Documentation is useful, but the long parameter list and repetitive assignments make the class verbose. Action granularity: Assignments consistently perform one action per line; several imports, slot names, and parameters are crowded onto single lines. Reading flow: The conceptual progression is natural, but inconsistent spacing, awkward line breaks, and compressed declarations repeatedly interrupt scanning.

Run 3

Code Structure: Logically organized around class properties, related enums, initialization, and a derived property, but insufficient spacing weakens section boundaries. Nesting: Shallow and appropriate; nested enums introduce no difficult control flow. Clarity of intent: Descriptive names and comprehensive documentation clearly explain the purpose, although constructor parameters lack type annotations. Code length: Documentation and repetitive assignments make the snippet lengthy, but most serve a clear purpose. Action granularity: Assignments consistently perform one action per line; several imports, slot names, and parameters are crowded onto shared lines. Reading flow: The progression is natural, but irregular whitespace, inconsistent wrapping, and missing blank lines interrupt scanning. Overall, understandable design and explicit intent outweigh distracting formatting.