Sample

pyint-1710f28428ed-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines195

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.3460–1; higher is more readable
Mi0.7380–1; higher is more readable
LLOC58Logical lines; fewer is more readable
DeepSeek V4 Pro15.330–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.480–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, ): _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 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 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 """ 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.3811.44−125.778
Source linesThe number of non-empty source lines.195+78
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.037−6.056

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.196−5.903
Indentation frequencyHow rapidly indentation changes from line to line.168+5.074
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.168−3.434
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.194.987+2.316
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.053+0.424
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.75.342+0.411
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.964+0.405

Intercept 0.07 + feature contributions = -0.638 (log-odds).
Score = sigmoid(-0.638) = 0.346.

Score0.738
Score58
Run 1

The code is generally well-structured and readable. It uses clear naming conventions, docstrings, and type hints. The class definition and methods are logically organized, and the use of `__slots__` improves clarity. However, there are some readability challenges. The `__attrs_attrs__` tuple construction is complex and visually dense, mixing comprehensions with explicit `Attribute` calls. The long parameter lists in `__init__` and `Attribute` reduce readability. The code is mostly flat with minimal deep nesting, and each line tends to perform one action, which aids comprehension. The reading flow is mostly natural, but the large block of attribute definitions could be broken down for better scannability. Overall, it is readable but could be improved by simplifying the meta-attribute construction and reducing verbosity in parameter handling.

Run 2

The code is generally structured, with clear sections for imports, class definition, slots, and methods. It uses typing and docstrings. However, readability is hampered in places: the __attrs_attrs__ assignment uses a large tuple/generator mix that is visually dense. The __init__ method takes many positional parameters, making intent and usage harder to follow at a glance. Some nested expressions, like the lambda in converter(), slightly reduce clarity. Positive aspects include flat nesting, one action per line in most methods, and clear method names. Overall, the code is maintainable but could be more approachable with better parameter organization and less dense attribute declarations.

Run 3

The code is generally readable and well-structured, with clear class organization and reasonable use of docstrings. It uses `__slots__` and tuple-based `__attrs_attrs__` definitions, which are common in this codebase but add some cognitive overhead. The `__attrs_attrs__` definition is long and contains repetitive `Attribute(...)` calls, which reduces readability. However, the methods are concise, each performing a single logical action, and the nesting is flat. The `converter` method has a slightly complex lambda, but it is understandable given the context. Overall, the code is maintainable but could benefit from reducing repetition in the attribute definitions.

Run 1

Code Structure: The class is logically organized into slot declarations, attribute metadata, initialization, and decorator methods. Nesting: Control flow is shallow, with simple conditionals; the metadata comprehension adds modest complexity. Clarity of intent: Descriptive names and focused docstrings explain ordering and decorator behavior, although external helpers and numerous configuration fields require library context. Code length: Explicit metadata definitions and a long constructor are somewhat repetitive but easy to inspect. Action granularity: Statements generally perform one action per line, with clearly separated assignments. Reading flow: Methods follow a consistent pattern, and spacing supports scanning. The lengthy class-level metadata and constructor delay reaching the core behavior, while the converter lambda requires closer reading.

Run 2

Code Structure: The class is logically organized into metadata, initialization, and focused decorator methods, although the large metadata declaration dominates the opening. Nesting: Control flow is shallow, with simple conditionals; the nested tuple comprehension adds modest visual complexity. Clarity of intent: Descriptive names and method docstrings explain attribute ordering and decorator behavior well. External symbols and the converter lambda require some library context. Code length: Methods are concise, but repeated Attribute arguments, the lengthy constructor signature, and mechanical assignments make the class verbose. Action granularity: Statements generally perform one action per line, making state changes easy to follow. Reading flow: Consistent formatting and straightforward methods support natural reading, though extensive imports and metadata delay the main behavior. Overall, readable and maintainable despite some boilerplate and framework-specific complexity.

Run 3

Code Structure: The class is logically organized into attribute declarations, initialization, and focused decorator methods, although the extensive imports distract from this excerpt. Nesting: Control flow is shallow; only the attribute-construction comprehension adds visual complexity. Clarity of intent: Descriptive method names and useful docstrings explain ordering, validation, defaults, and conversion. External helpers and sentinel values require library context, while names such as cmp and meth are less explicit. Code length: The constructor and repeated Attribute configuration are verbose but largely justified by the data model; some configuration could be factored out. Action granularity: Statements generally perform one action per line, making assignments and state changes easy to follow. Reading flow: Consistent formatting and straightforward method bodies support natural reading, though the large class-level metadata block delays reaching the main behavior.