Sample

pyint-1ce4e525acd0-SRC

Unmodified source class

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 Pro11.670–20; mean of three runs
GPT-6.1 Sol16.670–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 shows good structure with clear imports, a focused class, and natural method grouping. However, readability suffers from a long, hard-to-scan __attrs_attrs__ construction with deeply nested tuple/generator expressions and many keyword arguments. Nesting and sparse comments increase complexity, while clarity of intent is partly reduced by terse one-letter abbreviations (e.g., 'eq', 'cmp', 'hash'). Action granularity varies: some lines pack several operations (e.g., self._validator = and_(...)), while others are appropriately single-action. Overall, knowledgeable readers can follow it, but it would benefit from shorter, better-named grouping for attrs metadata.

Run 2

The code is a mix of clear patterns and poor structure. Imports and docstrings are readable, but the `__attrs_attrs__` tuple is a deeply nested, repetitive construction that obscures intent and violates flat structure and action granularity. The `Attribute` constructor call is repeated many times with slight variations, making the code longer than necessary and hard to scan. While individual methods like `validator`, `default`, and `converter` are concise and clear, the overall class definition suffers from low readability due to tangled metadata construction and multiple parameters without clear grouping. The reading flow is disrupted by the large tuple literal before the `__init__` method. The use of `__slots__` is fine, but the overall file segment is dense and requires careful reading to understand attribute definitions.

Run 3

The code is generally well-structured and readable, with clear class and method definitions. However, several factors reduce readability: the `__init__` method has a very long parameter list (14 parameters), which makes it hard to scan and understand. The `__attrs_attrs__` tuple is complex, mixing a generator-like tuple unpacking with a manual `Attribute` definition, which obscures the overall structure. Some methods like `converter` and `validator` are clear, but the lambda inside `converter` adds unnecessary nesting and indirection. The code uses descriptive names and follows Python idioms, but the dense class-level metadata and long initialization logic make it harder to follow. Overall, it is readable but not highly readable due to parameter bloat and complex class attributes.

Run 1

Code Structure: The class is logically organized into field declarations, initialization, and focused decorator methods, though the extensive imports distract from this excerpt. Nesting: Shallow conditionals and a single comprehension keep nesting manageable. Clarity of intent: Descriptive names and informative docstrings explain attribute ordering and decorator behavior; external helpers and the converter lambda require some context. Code length: Repeated Attribute configuration and the long constructor add verbosity, although most lines directly represent necessary state. Action granularity: Assignments and operations generally occupy separate lines, making changes easy to follow. Reading flow: Consistent formatting and straightforward method bodies support natural reading, but the large metadata declaration delays the core behavior, and names such as repr, hash, and type overlap Python built-ins.

Run 2

Code Structure: The class logically groups attribute metadata, initialization, and decorator methods, though the broad import block and large class-level declaration add overhead. Nesting: Control flow is shallow, with simple conditional branches; the nested tuple expansion and generator expression require more attention. Clarity of intent: Descriptive names and focused docstrings clearly explain attribute ordering and decorator behavior, although external helpers and sentinel values require context. Code length: Methods are concise, but repeated Attribute arguments and the lengthy constructor make the class verbose. Action granularity: Statements generally perform one action per line, and multiline calls are consistently formatted. Reading flow: The progression from metadata to initialization to behavior is natural, with useful whitespace; however, the dense __attrs_attrs__ construction and numerous configuration fields slow scanning.

Run 3

Code Structure: The class is logically organized into slots, attribute metadata, initialization, and focused decorator methods, though numerous imports appear unrelated to this excerpt. Nesting: Methods remain shallow; the nested tuple expansion and Attribute construction are the main complexity. Clarity of intent: Descriptive method names and docstrings clearly explain behavior, but external symbols and many configuration flags require library context. Code length: Methods are concise, while repetitive Attribute arguments and the lengthy initializer add boilerplate. Action granularity: Statements generally perform one action per line, making state changes easy to follow. Reading flow: Consistent formatting and straightforward conditionals support natural reading, but the large metadata declaration delays the behavioral code, and names such as repr, hash, and type shadow built-ins.