Sample

pyint-b98456e13625-I11

Split eligible integer literals into pairs of short-named intermediate variables

Matched original source

Lines43

Scores

MethodScoreScale
Posnett0.1060–1; higher is more readable
Dorn0.7610–1; higher is more readable
Mi0.7070–1; higher is more readable
LLOC20Logical lines; fewer is more readable
DeepSeek V4 Pro160–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.7520–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, _none_constructor=type(None), _args=()): # noqa: B008 return _none_constructor, _args

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.746−7.119

Intercept 8.87 + feature contributions = -2.129 (log-odds).
Score = sigmoid(-2.129) = 0.106.

Feature contributions

FeatureValueContribution
(log-odds)
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.033+0.619
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.44−0.522
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.75.364+0.412
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
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.78.977+0.32
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.42.913+0.19

Intercept 0.07 + feature contributions = 1.157 (log-odds).
Score = sigmoid(1.157) = 0.761.

Score0.707
Score20
Run 1

The code is generally well-structured and readable. It demonstrates clear organization with logical import grouping (stdlib, third-party, local), explicit future annotations import, and a focused single-class definition. The class has a clear docstring explaining its purpose and non-obvious behavior, which significantly improves clarity. Nesting is flat with no conditional logic. Action granularity is appropriate - each line performs one clear operation. The reading flow is natural: imports, then class definition, then method. The use of type hints (int subclass, annotations) adds to clarity. Minor deductions: the import section is somewhat long but follows Python conventions. The default argument pattern (_none_constructor=type(None), _args=()) is slightly unconventional and may require readers to pause. The blanket noqa comment suppresses linting checks without specifying which rule is being disabled. Overall, this is readable code appropriate for a library implementation.

Run 2

The code is well-structured and readable. Imports are organized logically, grouped by stdlib, third-party, and local modules. The single class definition is clear, with a concise docstring explaining its purpose and rationale. Nesting is minimal, with only one method and no deep indentation. Each line has a clear purpose, and the use of type hints and future annotations enhances clarity. The action granularity is appropriate; defaults in the method signature are separated lines? No, they are inline but still readable. The reading flow is natural: module docstring? (none), imports, then class with explanation. Minor deductions: the `# noqa: B008` comment is terse without explanation, and the long import list could be slightly more compact, but overall the code is highly readable.

Run 3

The code is generally readable with clear structure and intent. Imports are logically grouped (stdlib, third-party, local) with sensible alphabetical ordering. The single class _CacheHashWrapper has a concise docstring explaining its purpose, and the __reduce__ method is flat and straightforward. However, the function signature for __reduce__ uses slightly awkward default arguments (_none_constructor=type(None), _args=()) and includes a noqa comment, which adds minor cognitive overhead. The code is relatively short and maintains good action granularity. Reading flow is natural, though the long import block slightly interrupts flow before reaching the class definition. The intent of the cache hash wrapper is clear thanks to the docstring, even if the implementation detail requires domain knowledge.

Run 1

Code Structure: Imports are grouped logically, followed by a focused class and method. 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; __reduce__ defaults are somewhat specialized. Code length: The implementation is concise, although the many imports add visual overhead relative to the shown functionality. Action granularity: Each import or return occupies its own logical statement, with no compressed operations. Reading flow: The progression from imports to class documentation to implementation is natural. Additional blank lines between import groups and before the top-level class would improve visual separation.

Run 2

Code Structure: Imports are grouped logically, followed by a small, focused class. Nesting: Minimal nesting makes the implementation 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 special-method behavior and captured default arguments require some Python knowledge. Code length: The implementation is concise, although the import list is disproportionately long for the displayed functionality. Action granularity: Each statement performs a single action, with a straightforward return value. Reading flow: The progression from imports to class documentation to implementation is natural. Additional blank lines between import groups and before the class would improve visual separation.

Run 3

Code Structure: Imports are grouped logically, followed by a small, focused class, although many imports are unused in this excerpt. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The class docstring clearly explains why cached hashes must reset during copying or pickling; the private names and specialized __reduce__ defaults require some Python knowledge. Code length: The implementation is concise, and the longer docstring provides useful context rather than unnecessary repetition. Action granularity: Each statement performs a single action, with a straightforward tuple return. Reading flow: The progression from imports to class documentation to implementation is natural, though the extensive import block slightly outweighs the tiny implementation.