Sample

pyint-d7ffacf9f35b-I10

Deterministically remove some optional blank lines and bracketed line breaks

Matched original source

Lines149

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.1610–1; higher is more readable
Mi0.4320–1; higher is more readable
LLOC58Logical lines; fewer is more readable
DeepSeek V4 Pro7.670–20; mean of three runs
GPT-6.1 Sol12.330–20; mean of three runs
BTTF0.3930–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.149+59.6
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.01−6.015

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.150−4.275
Indentation frequencyHow rapidly indentation changes from line to line.127+3.656
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.127−2.493
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.135.973−2.094
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.148.956+1.672
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.135.993+1.39
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.053+0.427

Intercept 0.07 + feature contributions = -1.647 (log-odds).
Score = sigmoid(-1.647) = 0.161.

Score0.432
Score58
Run 1

The code suffers from severe formatting and structural issues that make it difficult to read. While the class has a clear purpose, the implementation is obscured by inconsistent and excessive indentation, particularly in the `__attrs_attrs__` definition and various function/method signatures. This creates a tangled, disorganized reading flow. The nesting is moderate but worsened by the formatting. Action granularity is violated in several places, with multiple assignments or arguments crammed onto single lines, while other lines are broken unnecessarily. Code length is verbose due to the poor formatting. The intent of the class is clear from its docstring, but the clarity of individual components is lost. The import section and use of `__slots__` and `__attrs_attrs__` suggest an internal library construct, but the presentation undermines comprehension.

Run 2

The code is difficult to read due to inconsistent formatting, cramped line groupings, and heavy vertical sprawl. The imports and tuples use erratic spacing and line breaks, making visual scanning confusing. The `__attrs_attrs__` construction is deeply nested and mixes many arguments on single lines, violating action granularity. Method definitions are followed immediately by others without blank lines, reducing separation. Although docstrings exist and intent is somewhat clear, the physical layout obscures logical structure. Long parameter lists and odd indentation patterns further hurt readability. Overall, the code functions but requires significant effort to parse.

Run 3

The code has inconsistent and poor formatting that severely harms readability. While it follows some logical structure (e.g., separating the class definition and using slots), many lines cram multiple attributes into a single line (e.g., __slots__, __attrs_attrs__), and others have excessive whitespace or odd indentation. The __attrs_attrs__ tuple is particularly tangled, mixing generator expressions and multiple function arguments on single lines. Some elements like the imports have unnecessary alignment and line breaks, while method definitions are inconsistently spaced. Intent is often clear in comments and docstrings, but the code length is inflated by scattered formatting. Action granularity is violated: multiple fields and parameters are placed per line, making the control flow difficult to scan. Reading flow is disorganized—readers are forced to jump between dense lines and sparse blocks. Overall, this code would benefit greatly from a consistent formatter (e.g., Black) and more careful line-by-line organization.

Run 1

Code Structure: The class logically groups attribute initialization and decorator methods, but inconsistent spacing and crowded declarations obscure organization. Nesting: Control flow is shallow; the nested tuple comprehension and Attribute construction require more effort to parse. Clarity of intent: Descriptive method names and docstrings explain the purpose well, although external helpers and numerous configuration fields add cognitive load. Code length: Methods are concise, but lengthy metadata declarations and repetitive initialization make the class cumbersome to scan. Action granularity: Most executable statements perform one action per line, while multiple arguments and field names crowded onto single lines reduce visual clarity. Reading flow: Initialization followed by related decorators provides a natural progression, but irregular indentation, excessive inline whitespace, and missing separation between some methods interrupt it.

Run 2

Code Structure: The class logically groups attribute metadata, initialization, and decorator methods, but inconsistent formatting weakens organization. Nesting: Control flow is shallow; only metadata construction introduces moderately nested expressions. Clarity of intent: Descriptive method names and docstrings explain ordering, validators, defaults, and converters, although external symbols and numerous configuration fields increase cognitive load. Code length: Mostly justified by explicit metadata and initialization, but repeated configuration arguments are verbose. Action granularity: Executable statements generally perform one action per line; several imports, arguments, and tuple entries are crowded onto single lines. Reading flow: Methods follow a sensible sequence, but irregular spacing, compressed parameter lists, and inconsistent blank lines interrupt scanning. Overall, the logic is understandable, while presentation noticeably reduces readability.

Run 3

Code Structure: The class logically groups attribute initialization and decorator methods, but inconsistent spacing and crowded declarations obscure that organization. Nesting: Control flow is shallow; the tuple comprehension adds only modest complexity. Clarity of intent: Descriptive method names and useful docstrings explain the purpose, although external helpers and numerous configuration fields require context. Code length: Mostly justified by explicit initialization and metadata definitions, with some repetitive boilerplate. Action granularity: Executable statements generally perform one action per line, but multiple arguments and entries are awkwardly packed together. Reading flow: Methods follow a sensible progression, yet irregular indentation, excessive inline whitespace, and inconsistent blank lines interrupt scanning.