Sample

pyint-8b34b4e53a9c-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines195

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.3420–1; higher is more readable
Mi0.7380–1; higher is more readable
LLOC58Logical lines; fewer is more readable
DeepSeek V4 Pro6.670–20; mean of three runs
GPT-6.1 Sol130–20; mean of three runs
BTTF0.4760–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, def3, val2, rep, cmp, has, ini, con2, met, typ, kw, eq2, eq3, ord, order2, on, ali, ): _CountingAttr.cls_counter += 1 self.counter = _CountingAttr.cls_counter self._default = def3 self._validator = val2 self._converter = con2 self.repr = rep self.eq = eq2 self.eq_key = eq3 self.order = ord self.order_key = order2 self.hash = has self.init = ini self.metadata = met self.type = typ self.kw_only = kw self.on_setattr = on self.alias = ali def val(self, met2): """ Decorator that adds *meth* to the list of validators. Returns *meth* unchanged. .. versionadded:: 17.1.0 """ if self._validator is None: self._validator = met2 else: self._validator = and_(self._validator, met2) return met2 def def2(self, met3): """ 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(met3, takes_self=True) return met3 def con(self, met4): """ Decorator that appends *meth* to the list of converters. Returns *meth* unchanged. .. versionadded:: 26.2.0 """ decorated = Converter( lambda value, _self, field: met4(_self, field, value), takes_self=True, takes_field=True, ) if self._converter is None: self._converter = decorated else: self._converter = pipe(self._converter, decorated) return met4

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.3925.211−129.532
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.028−6.042

Intercept 8.87 + feature contributions = -48.704 (log-odds).
Score = sigmoid(-48.704) = 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.962+2.315
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.75.342+0.411
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.055+0.408
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.98+0.405

Intercept 0.07 + feature contributions = -0.655 (log-odds).
Score = sigmoid(-0.655) = 0.342.

Score0.738
Score58
Run 1

This code is difficult to read due to poor naming conventions and unclear structure. Parameters like 'def3', 'val2', 'rep', 'cmp', 'has', 'ini', 'con2', 'met', 'typ', 'kw', 'eq2', 'eq3', 'ord', 'order2', 'on', and 'ali' are cryptic and do not convey intent. Method names such as 'val', 'def2', and 'con' are equally ambiguous. The class __attrs_attrs__ construction is tangled and repetitive, making the logical organization hard to follow. While the code is not deeply nested, the lack of clarity and the use of abbreviated, non-descriptive identifiers severely impair readability. The reading flow is disorganized, and the action granularity is mixed, with some lines doing too much conceptually. Overall, the code appears to be a low-level internal structure but lacks sufficient documentation or clear naming to support comprehension.

Run 2

The code has a clear underlying purpose (attribute representation in the attrs library) and some structure, but readability is significantly undermined by extremely poor naming conventions. Parameter names like `def3`, `val2`, `con2`, `met2`, `eq2`, `eq3`, and `ord` are cryptic and obscure intent, making the `__init__` and decorator methods hard to follow. The `__init__` method takes 16 positional parameters, requiring readers to mentally map abbreviations to their true meaning. The class-level `__attrs_attrs__` construction combines generator expressions with tuple unpacking, which is clever but impairs clarity. The methods `val`, `def2`, and `con` are also non-descriptive. Positively, logical organization is reasonable, indentation is flat, and comments/docstrings exist, but the abstracted naming and dense multi-action lines (especially in `__attrs_attrs__`) reduce overall readability. The code assumes deep domain knowledge, and while concise in places, it sacrifices self-documentation. It reads as optimized for internal use rather than maintainability by newcomers.

Run 3

The code is extremely difficult to read due to heavily obfuscated naming (e.g., def3, val2, met2, con2, eq2, ord) that obscures intent. The class structure mixes metadata definitions with logic and uses abbreviated parameter names throughout, making it hard to follow. While the module-level imports and some docstrings are clear, the core methods like val(), def2(), and con() are cryptic and inconsistently named. Nesting is moderate, but the long tuple initialization inside __attrs_attrs__ is dense and hard to parse. Action granularity is reasonable in most methods, but the tuple comprehension and unpacking reduce clarity. Overall, the code lacks self-documenting structure and consistent naming, making maintenance difficult.

Run 1

1. Code Structure: Logically organized around a single attribute representation class, with initialization and separate decorator methods; the lengthy metadata declaration adds visual weight. 2. Nesting: Mostly flat, with simple conditionals and one comprehension, making control flow easy to follow. 3. Clarity of intent: The class docstring and descriptive instance attributes help, but cryptic parameters such as def3, eq2, and met4 and method names like def2 and con obscure meaning. Docstrings referring to meth rather than actual parameter names further weaken clarity. 4. Code length: Repetitive Attribute configuration, a large constructor signature, and numerous imports unused in this excerpt reduce concision. 5. Action granularity: Assignments and operations generally occupy separate lines, supporting readability. 6. Reading flow: Methods follow straightforward sequences, but decoding abbreviated names and navigating verbose class-level declarations interrupt otherwise natural reading.

Run 2

Code Structure: The class is logically organized into attribute declarations, initialization, and decorator helpers, but numerous imports and external definitions obscure standalone understanding. Nesting: Control flow is shallow, with simple conditionals; the tuple construction adds only moderate nesting. Clarity of intent: The class docstring and descriptive instance attributes explain the purpose, but cryptic names such as def3, val2, eq3, met4, and def2 substantially weaken readability. Docstrings referring to meth rather than actual parameter names add inconsistency. Code length: Explicit metadata declarations and the long constructor are verbose, although most lines serve a recognizable purpose. Action granularity: Assignments and operations are consistently separated, making individual steps easy to follow. Reading flow: Methods proceed naturally from checks to updates and returns, but the large metadata block and opaque constructor parameters interrupt comprehension.

Run 3

Code Structure: The class is logically organized into metadata, initialization, and decorator methods, though numerous imports and external dependencies add clutter. Nesting: Control flow is shallow, with simple conditionals; the metadata comprehension is moderately layered. Clarity of intent: The class docstring and descriptive instance attributes explain its purpose, but cryptic names such as def3, eq2, met4, val, and con obscure parameter meanings and method roles. Some docstrings reference meth rather than actual parameter names. Code length: Methods are concise, but repetitive Attribute configuration and a lengthy constructor make the class verbose. Action granularity: Statements generally perform one action per line, making state changes easy to follow. Reading flow: Consistent formatting and sequential assignments support scanning, but readers must repeatedly map abbreviated arguments to meaningful attributes and resolve definitions absent from the snippet.