Sample

pyint-66c9d3ff9c93-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines189

Scores

MethodScoreScale
Posnett0.9880–1; higher is more readable
Dorn0.2780–1; higher is more readable
Mi0.770–1; higher is more readable
LLOC56Logical lines; fewer is more readable
DeepSeek V4 Pro8.670–20; mean of three runs
GPT-6.1 Sol130–20; mean of three runs
BTTF0.6310–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, is3, is4, has, is5, kw, collected, added, added2, added3, added4, has2, added5, added6, added7, on, field, ): self.is_exception = is3 self.is_slotted = is4 self.has_weakref_slot = has self.is_frozen = is5 self.kw_only = kw self.collected_fields_by_mro = collected self.added_init = added self.added_repr = added2 self.added_eq = added3 self.added_ordering = added4 self.hashability = has2 self.added_match_args = added5 self.added_str = added6 self.added_pickling = added7 self.on_setattr_hook = on self.field_transformer = field @property def is2(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)
Source linesThe number of non-empty source lines.189+75.6
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.2222.559−73.344
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.491−6.736

Intercept 8.87 + feature contributions = 4.389 (log-odds).
Score = sigmoid(4.389) = 0.988.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.190−5.691
Indentation frequencyHow rapidly indentation changes from line to line.114+3.206
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.188.963+2.232
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.114−2.195
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.3+0.475
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.926+0.238

Intercept 0.07 + feature contributions = -0.956 (log-odds).
Score = sigmoid(-0.956) = 0.278.

Score0.77
Score56
Run 1

The code has clear documentation, type hints, and logical organization, but the __init__ method uses opaque parameter names (is3, is4, has, added2, etc.) that don't match the documented attributes. This makes it very hard to understand what each argument represents without cross-referencing the __slots__ order. Additionally, the property 'is2' has a non-descriptive name. These choices significantly hurt clarity of intent and reading flow.

Run 2

The code has good documentation and type hints, making intent fairly clear. However, it suffers from severe readability issues: the __init__ method uses cryptic parameter names (is3, is4, has, is5, added2, has2, etc.) that don't map clearly to their attributes. Action granularity is poor, as each line sets one attribute but with confusing names. The nested enums add some structure, but the overall reading flow is disrupted by inconsistent naming and unclear parameter semantics. The __slots__ declaration with RUF023 comment shows awareness of ordering but doesn't help readability. While the class documentation is thorough, the code itself requires constant cross-referencing between parameters and attributes, making it ambiguous and difficult to follow.

Run 3

The code has some good structure (nested enums, single class with documented attributes), but readability is severely hurt by poor naming and lack of clear intent. The '__init__' parameters are cryptic and nondescript (is3, is4, has, is5, added2, etc.) which makes it impossible to understand what each argument represents without cross-referencing the class slots. This forces readers to map numbers to attributes manually. The property 'is2' is also ambiguous. The flat-ish structure and one-action-per-line in '__init__' help slightly, but the code is unnecessarily obscure due to those names. Docstrings are helpful, but the implementation fails to mirror their clarity. Overall, not terrible to skim if you ignore the constructor, but painful to work with or maintain.

Run 1

Code Structure: Logically organized into documentation, nested enums, slots, initialization, and a property. Nesting: Shallow and easy to follow; nested enums appropriately group related concepts. Clarity of intent: Descriptive attributes and thorough documentation explain the data model, but constructor parameters such as is3, added4, and has2 obscure their meanings. The property name is2 also fails to communicate its purpose. Code length: Most length comes from useful documentation, though the large constructor and repetitive assignments increase scanning effort. Action granularity: Each assignment and enum definition performs one action per line. Reading flow: Consistent formatting and sequential assignments support natural reading, but readers must repeatedly map ambiguous parameters to meaningful attributes. Overall, the structure is readable, while poor parameter and property naming substantially weakens comprehension.

Run 2

Code Structure: Logically organized into a documented class, nested enums, slots, initialization, and a property. Nesting: Shallow and easy to follow; nested enums are appropriate. Clarity of intent: Descriptive attributes and extensive documentation help, but constructor parameters such as is3, added4, and has2 obscure their meanings, and the property name is2 hides its purpose. Code length: The documentation is useful but dominates this small implementation; numerous imports are unused within the snippet, and repetitive initialization adds bulk. Action granularity: Assignments and enum definitions generally perform one action per line, making individual statements easy to scan. Reading flow: The class follows a natural progression, but readers must repeatedly map ambiguous constructor parameters to descriptive attributes, disrupting comprehension.

Run 3

Code Structure: Logically organized into a documented class, nested enums, slots, initialization, and a property. Nesting: Shallow and appropriate, with no complex control flow. Clarity of intent: Descriptive attribute names and extensive documentation help, but cryptic constructor parameters such as is3, added4, and has2 obscure their meanings; the property name is2 hides its hashability check. Code length: Straightforward implementation, but lengthy documentation and repetitive declarations make this simple data container cumbersome to scan. Action granularity: Each assignment occupies its own line, and enum definitions are clearly separated. Reading flow: The overall progression is natural, but readers must repeatedly map ambiguous parameters to documented attributes, significantly interrupting comprehension.