Sample

pyint-66f8adc13010-I04

Replace names with deterministic minifier-style shortest identifiers

Matched original source

Lines43

Scores

MethodScoreScale
Posnett0.1050–1; higher is more readable
Dorn0.7580–1; higher is more readable
Mi0.6280–1; higher is more readable
LLOC20Logical lines; fewer is more readable
DeepSeek V4 Pro140–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.7270–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 _CacheHashWrapper(int): """ An integer subclass that pickles / copies as None This is used for non-slots classes with ``cache_hash=True``, to avoid serializing a potentially (even likely) invalid hash value. Since `None` is the default value for uncalculated hashes, whenever this is copied, the copy's value for the hash should automatically reset. See GH #613 for more details. """ def __reduce__(self, a=type(None), b=()): # noqa: B008 return a, b

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.638.793−21.08
Source linesThe number of non-empty source lines.43+17.2
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.755−7.133

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

Feature contributions

FeatureValueContribution
(log-odds)
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.034+0.607
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.44−0.522
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.75.977+0.447
Indentation frequencyHow rapidly indentation changes from line to line.33+0.404
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.33−0.336
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.67.455+0.284
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.42.805+0.189

Intercept 0.07 + feature contributions = 1.143 (log-odds).
Score = sigmoid(1.143) = 0.758.

Score0.628
Score20
Run 1

The code is well-structured with clear logical organization: imports are grouped by source (futures, stdlib, third-party/local), and constants/functions are ordered sensibly. Minimal nesting is present with flat if/return patterns. Intent is evident through descriptive names and comments explaining non-obvious behavior like the _CacheHashWrapper pickling workaround. Code is concise without unnecessary verbosity. Action granularity follows Python conventions—one logical operation per expression while maintaining readability. Reading flow is natural, though the import section is long due to many dependencies, which slightly impacts initial scanning. Overall, the module demonstrates strong adherence to clean code principles with only minor room for improvement in import organization clarity.

Run 2

The code is modular and organized well at a high level, with imports grouped logically and a single class defined. However, readability is significantly impacted by unclear intent: the class `_CacheHashWrapper` subclasses `int` but pickles as `None`, which is non-obvious from the name alone and requires extensive comments to explain. The `__reduce__` method uses mutable default arguments (`a=type(None)`, `b=()`) which is misleading despite the noqa comment, and parameter names `a` and `b` are ambiguous. Annotation extraction and compatibility imports add cognitive overhead without immediate clarity. Nesting is flat and action granularity is good, but they don't offset the lost clarity. The reading flow is interrupted by needing to cross-reference the comment to understand behavior. The length is appropriate, but the code relies heavily on implicit behavior, making it less approachable for developers unfamiliar with the internal logic.

Run 3

The code is well-structured and readable. It opens with a logical import grouping (standard library, third-party, local modules), uses clear naming conventions, and includes a docstring that explains the purpose and rationale of `_CacheHashWrapper`. The class has a single responsibility, low nesting, and concise implementation. A minor deduction is applied because the `__reduce__` method uses non-descriptive parameter names (`a`, `b`) and includes a `# noqa` comment without clarifying why the warning is suppressed. The `extend` of `int` with a custom reduce logic is slightly abstract, but overall the intent is clear and the code flow is natural.

Run 1

Code Structure: Imports are grouped sensibly, followed by a small, self-contained class. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The descriptive class name and detailed docstring clearly explain why cached hashes reset during copying or pickling; however, the parameter names a and b obscure the reduction mechanism. Code length: The implementation is concise, although the import list is extensive relative to the shown functionality. Action granularity: Each statement performs one action, with no compressed multi-action lines. Reading flow: The progression from imports to documentation to implementation is natural. Additional blank lines around import groups and the top-level class would improve visual separation.

Run 2

Code Structure: Imports are grouped before a small, focused class, although the extensive import list adds clutter relative to the shown functionality. Nesting: Minimal, with only one method inside the class. Clarity of intent: The descriptive class name and detailed docstring clearly explain why cached hashes reset during copying or pickling; however, the terse parameter names and specialized __reduce__ defaults require familiarity with Python serialization. Code length: The implementation is concise, and the documentation provides useful context. Action granularity: Each statement performs one action, with no compressed multi-operation lines. Reading flow: The progression from imports to class documentation to implementation is natural, though extra spacing between import groups and the class would improve visual separation.

Run 3

Code Structure: Imports are grouped logically, followed by a focused class definition. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The descriptive class name and detailed docstring clearly explain why cached hashes reset during copying or pickling; however, the parameters a and b obscure the implementation slightly. Code length: The implementation is concise, though the extensive imports are unrelated to the displayed class. Action granularity: Each statement performs a single action. Reading flow: The progression from imports to documentation to the short method is natural, with minor readability costs from the specialized __reduce__ protocol and compact parameter naming.