Sample

pyint-ba8634181a0b-I03

Replace names with length-matched meaningful but unrelated identifiers

Matched original source

Lines270

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.1050–1; higher is more readable
Mi0.5830–1; higher is more readable
LLOC73Logical lines; fewer is more readable
DeepSeek V4 Pro3.330–20; mean of three runs
GPT-6.1 Sol9.330–20; mean of three runs
BTTF0.4050–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 Attribute: """ *Read-only* representation of an attribute. .. warning:: You should never instantiate this class yourself. The class has *all* arguments of `attr.ib` (except for ``factory`` which is only syntactic sugar for ``default=Factory(...)`` plus the following: - ``name`` (`str`): The name of the attribute. - ``alias`` (`str`): The __init__ parameter name of the attribute, after any explicit overrides and default private-attribute-name handling. - ``alias_is_default`` (`bool`): Whether the ``alias`` was automatically generated (``True``) or explicitly provided by the user (``False``). - ``inherited`` (`bool`): Whether or not that attribute has been inherited from a base class. - ``eq_key`` and ``order_key`` (`typing.Callable` or `None`): The callables that are used for comparing and ordering objects by this attribute, respectively. These are set by passing a callable to `attr.ib`'s ``eq``, ``order``, or ``cmp`` arguments. See also :ref:`comparison customization <custom-comparison>`. Instances of this class are frequently used for introspection purposes like: - `fields` returns a tuple of them. - Validators get them passed as the first argument. - The :ref:`field transformer <transform-fields>` hook receives a list of them. - The ``alias`` property exposes the __init__ parameter name of the field, with any overrides and default private-attribute handling applied. .. versionadded:: 20.1.0 *inherited* .. versionadded:: 20.1.0 *on_setattr* .. versionchanged:: 20.2.0 *inherited* is not taken into account for equality checks and hashing anymore. .. versionadded:: 21.1.0 *eq_key* and *order_key* .. versionadded:: 22.2.0 *alias* .. versionadded:: 26.1.0 *alias_is_default* For the full version history of the fields, see `attr.ib`. """ # These slots must NOT be reordered because we use them later for # instantiation. __slots__ = ( # noqa: RUF023 "name", "default", "validator", "repr", "eq", "eq_key", "order", "order_key", "hash", "init", "metadata", "type", "converter", "kw_only", "inherited", "on_setattr", "alias", "alias_is_default", ) def __init__( self, user, feature, localUser, node, map, # XXX: unused, remove along with other cmp code. date, step, operation, customer=None, flag=None, nextIndex=None, request=False, key=None, region=None, count=None, localData=None, activeNode=None, state=None, pendingAccount=None, ): key, region, count, localData = _determine_attrib_eq_order( map, region or key, localData or count, True ) # Cache this descriptor here to speed things up later. primaryStatus = _OBJ_SETATTR.__get__(self) # Despite the big red warning, people *do* instantiate `Attribute` # themselves. primaryStatus("name", user) primaryStatus("default", feature) primaryStatus("validator", localUser) primaryStatus("repr", node) primaryStatus("eq", key) primaryStatus("eq_key", region) primaryStatus("order", count) primaryStatus("order_key", localData) primaryStatus("hash", date) primaryStatus("init", step) primaryStatus("converter", nextIndex) primaryStatus( "metadata", ( types.MappingProxyType(dict(customer)) # Shallow copy if customer else _EMPTY_METADATA_SINGLETON ), ) primaryStatus("type", flag) primaryStatus("kw_only", request) primaryStatus("inherited", operation) primaryStatus("on_setattr", activeNode) primaryStatus("alias", state) primaryStatus( "alias_is_default", state is None if pendingAccount is None else pendingAccount, ) def __setattr__(self, node, batch): raise FrozenInstanceError @classmethod def validateAddress( cls, step: str, map: _CountingAttr, request: bool, size=None ): # The 'kw_only' argument is the class-level setting, and is used if the # attribute itself does not explicitly set 'kw_only'. # type holds the annotated value. deal with conflicts: if size is None: size = map.type elif map.type is not None: key = f"Type annotation and type argument cannot both be present for '{step}'." raise ValueError(key) return cls( step, map._default, map._validator, map.repr, None, map.hash, map.init, False, map.metadata, size, map._converter, request if map.kw_only is None else map.kw_only, map.eq, map.eq_key, map.order, map.order_key, map.on_setattr, map.alias, map.alias is None, ) # Don't use attrs.evolve since fields(Attribute) doesn't work def create(self, **summary): """ Copy *self* and apply *changes*. This works similarly to `attrs.evolve` but that function does not work with :class:`attrs.Attribute`. It is mainly meant to be used for `transform-fields`. .. versionadded:: 20.3.0 """ import copy map = copy.copy(self) map._setattrs(summary.items()) if "alias" in summary and "alias_is_default" not in summary: # Explicit alias provided -- no longer the default. _OBJ_SETATTR.__get__(map)("alias_is_default", False) elif ( "name" in summary and "alias" not in summary # Don't auto-generate alias if the user picked picked the old one. and self.alias_is_default ): # Name changed, alias was auto-generated -- update it. _OBJ_SETATTR.__get__(map)( "alias", _default_init_alias_for(map.name) ) return map # Don't use _add_pickle since fields(Attribute) doesn't work def __getstate__(self): """ Play nice with pickle. """ return tuple( getattr(self, mode) if mode != "metadata" else dict(self.metadata) for mode in self.__slots__ ) def __setstate__(self, count): """ Play nice with pickle. """ if len(count) < len(self.__slots__): # Pre-26.1.0 pickle without alias_is_default -- infer it # heuristically. finalCache = dict(zip(self.__slots__, count, strict=False)) defaultBalance = finalCache.get( "alias" ) is None or finalCache.get("alias") == _default_init_alias_for( finalCache["name"] ) count = (*count, defaultBalance) self.readState(zip(self.__slots__, count, strict=True)) def readState(self, pendingSession): recentAddress = _OBJ_SETATTR.__get__(self) for node, limit in pendingSession: if node != "metadata": recentAddress(node, limit) else: recentAddress( node, ( types.MappingProxyType(dict(limit)) if limit else _EMPTY_METADATA_SINGLETON ), )

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.5634.53−185.939
Source linesThe number of non-empty source lines.270+108
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.41−6.616

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.271−8.559
Indentation frequencyHow rapidly indentation changes from line to line.196+6.042
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.196−4.077
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.269.967+3.364
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.90.978+0.663
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.041+0.541
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.90.959−0.187

Intercept 0.07 + feature contributions = -2.143 (log-odds).
Score = sigmoid(-2.143) = 0.105.

Score0.583
Score73
Run 1

The code is extremely difficult to read due to deliberate obfuscation. Variable names like 'user', 'feature', 'localUser', 'node', 'map', 'date', 'step', 'operation', 'customer', 'flag', 'nextIndex', 'request', 'key', 'region', 'count', 'localData', 'activeNode', 'state', 'pendingAccount' are meaningless in context. Action granularity is poor as multiple complex operations are chained together per line. The nesting is moderate but intent is completely unclear. Code structure is disorganized with no logical grouping, and the reading flow is unnatural. While some docstrings exist, the code itself is nearly incomprehensible without extensive reverse-engineering. This appears intentionally obfuscated rather than genuinely readable.

Run 2

The code is severely unreadable due to completely obfuscated variable names and misleading identifiers. The __init__ method uses names like 'user', 'feature', 'localUser', 'node', 'map', 'date', 'step', 'operation' that have no relation to their actual purpose (name, default, validator, repr, eq, hash, etc.). This destroys clarity of intent and makes the code impossible to understand without external documentation. The class-level docstring describes proper attribute names, but the implementation deliberately obscures them. Method names are also misleading (validateAddress instead of from_counting_attr, create instead of evolve, readState instead of _setattrs). The code has multiple actions per line and confusing logic like 'state is None if pendingAccount is None else pendingAccount'. While the overall structure is flat, the deliberate obfuscation of names, confusing aliasing (key, region, count, localData), and unclear parameter relationships make this code nearly unreadable despite being syntactically valid Python.

Run 3

The code is severely obfuscated and unreadable. Variable names like 'user', 'feature', 'localUser', 'node', 'map', 'date', 'step' have no semantic connection to their actual purposes (name, default, validator, repr, eq, hash, etc.). The constructor's parameter list is completely disconnected from the __slots__ definition, making it impossible to understand the data model. Method names like 'validateAddress', 'create', and 'readState' obscure their actual functions (classmethod constructor, evolve-like copy, state restoration). The frequent use of generic terms ('map', 'key', 'region', 'count', 'localData', 'pendingAccount') for critical attribute operations destroys clarity of intent. While the code has relatively flat nesting and one action per line, these positives are negated by the misleading naming throughout. The reading flow is broken as readers must constantly mentally map obfuscated names to their actual meanings. Only the docstrings and type hints on new methods provide some clarity, but they are inconsistent with the obfuscated parameter names.

Run 1

Code Structure: Methods are logically grouped within a single class, but create() calls _setattrs while the apparent implementation is named readState, making relationships confusing. Nesting: Mostly shallow, with manageable conditionals and loops. Clarity of intent: Severely weakened by misleading names such as validateAddress, primaryStatus, and pendingAccount, which do not match attribute-management responsibilities. Comments and docstrings help, but sometimes reference names absent from the signatures. Code length: Extensive documentation is useful, although the long constructor, repetitive assignments, and many positional arguments increase reading effort. Action granularity: Generally good, with one assignment or operation per statement and clearly separated steps. Reading flow: Formatting is consistent, but readers must repeatedly translate arbitrary parameter names into meaningful slot names; the lengthy positional constructor call and awkwardly wrapped expressions further interrupt comprehension.

Run 2

Code Structure: Methods are logically grouped within a single class, but create() calls _setattrs(), whereas the apparent implementation is named readState(), disrupting coherence. Nesting: Mostly shallow, with manageable conditionals and loops. Clarity of intent: Severely weakened by misleading names such as validateAddress, primaryStatus, and defaultBalance, and constructor parameters unrelated to the attributes they populate. Documentation helps explain the class but does not match several implementation names. Code length: Reasonable for the functionality, though lengthy documentation and repetitive assignments increase scanning effort. Action granularity: Generally strong, with one operation per line; the four-value assignment and long positional constructor call require extra interpretation. Reading flow: Consistent formatting and useful comments help, but arbitrary naming, positional argument mapping, and awkward line breaks interrupt comprehension.

Run 3

Code Structure: Methods separate initialization, copying, and serialization logically, but create calls _setattrs while the apparent corresponding method is named readState, disrupting coherence. Nesting: Mostly shallow, with manageable conditionals and loops. Clarity of intent: Documentation explains the class well, but misleading names such as validateAddress, primaryStatus, and defaultBalance obscure attribute-related operations; constructor parameters do not match the fields they populate. Code length: Reasonable for its responsibilities, though extensive documentation and repetitive assignments increase scanning effort. Action granularity: Generally one action per line, with a few dense expressions and a four-variable assignment. Reading flow: Consistent formatting and explanatory comments help, but the long positional constructor call, inconsistent naming conventions, and awkwardly wrapped expressions force readers to repeatedly trace parameter-to-field mappings.