Sample

pyint-07587f6ac360-I05

Rewrite eligible decimal integer literals in hexadecimal notation

Matched original source

Lines47

Scores

MethodScoreScale
Posnett0.1990–1; higher is more readable
Dorn0.7670–1; higher is more readable
Mi0.6550–1; higher is more readable
LLOC23Logical lines; fewer is more readable
DeepSeek V4 Pro17.670–20; mean of three runs
GPT-6.1 Sol18.670–20; mean of three runs
BTTF0.7360–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 _Nothing(enum.Enum): """ Sentinel to indicate the lack of a value when `None` is ambiguous. If extending attrs, you can use ``typing.Literal[NOTHING]`` to show that a value may be ``NOTHING``. .. versionchanged:: 21.1.0 ``bool(NOTHING)`` is now False. .. versionchanged:: 22.2.0 ``NOTHING`` is now an ``enum.Enum`` variant. """ NOTHING = enum.auto() def __repr__(self): return "NOTHING" def __bool__(self): return False

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.659.075−21.749
Source linesThe number of non-empty source lines.47+18.8
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.877−7.315

Intercept 8.87 + feature contributions = -1.395 (log-odds).
Score = sigmoid(-1.395) = 0.199.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.48−0.663
Indentation frequencyHow rapidly indentation changes from line to line.39+0.612
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.034+0.608
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.74.958+0.49
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.39−0.474
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.68.729+0.304
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.46.855+0.245

Intercept 0.07 + feature contributions = 1.193 (log-odds).
Score = sigmoid(1.193) = 0.767.

Score0.655
Score23
Run 1

The code demonstrates strong readability through clear module organization with logical import grouping, a well-named sentinel class, and appropriate use of enums. The structure is flat with minimal nesting, making the control flow easy to follow. The class purpose is immediately apparent from the docstring, which also includes helpful version annotations. The implementation is concise, using enum.auto() appropriately, and each method contains a single clear action. The reading flow is natural, with imports organized by type (future, stdlib, typing, third-party) followed by the class definition. Minor deductions possible for the large number of imports without immediate context, but this is justified for a foundational module. The code follows idiomatic Python patterns and would be easily understood by experienced developers.

Run 2

The code is highly readable. Imports are grouped logically (standard library, third-party, local), and the `_Nothing` sentinel class is well-documented with clear version notes. The class structure uses enum appropriately, keeps actions concise (one behavior per line or short block), and exhibits flat nesting. Intent is clear through descriptive naming and docstrings, and reading flow is natural. Minor deductions only for import breadth potentially obscuring specific dependencies.

Run 3

The code demonstrates excellent structure with clear separation of concerns: imports are logically grouped (stdlib, third-party-ish, local), and the module-level class is well-organized. Nesting is minimal—the only nested block is a single method within the enum class. Intent is unambiguous due to descriptive naming (_Nothing, NOTHING, sentinel docstring) and comprehensive documentation. Code length is concise for the functionality provided. Each line performs a single action, maintaining clean granularity. Reading flow is natural: module docstring-like comments, version notes, then the class definition with simple methods. Minor deductions for the slightly long import list and relative import complexity, but overall this is highly readable Python code that follows idiomatic patterns and best practices.

Run 1

Code Structure: Imports are grouped logically, followed by a focused sentinel class. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The descriptive class docstring explains why the sentinel exists, and the small methods clearly define its representation and Boolean behavior. Code length: The implementation is concise; documentation adds useful context without excessive explanation. Action granularity: Each statement occupies its own line, with no compressed or compound actions. Reading flow: The progression from imports to documentation, enum member, and behavior is natural. The extensive imports relative to this small excerpt add some visual overhead, and an extra blank line before the top-level class would improve separation.

Run 2

Code Structure: Imports are grouped logically, followed by a focused enum class. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The class docstring clearly explains the sentinel's purpose, and the methods explicitly define its representation and boolean behavior. Code length: The implementation is concise; version-history documentation adds some reading overhead but useful context. Action granularity: Each statement performs one action, with no compressed multi-action lines. Reading flow: The progression from imports to documentation, enum member, and behavior is natural. Minor readability drawbacks are the extensive import preamble relative to the small implementation and limited blank-line separation between import groups and the class.

Run 3

Code Structure: Imports are grouped logically, followed by a small, cohesive enum class. Nesting: Minimal nesting makes the code easy to scan. Clarity of intent: The descriptive docstring clearly explains the sentinel and why it exists; the special methods define straightforward representation and boolean behavior. Code length: The class is concise, although the extensive import list adds overhead relative to the functionality shown. Action granularity: Each statement occupies its own line, with no compressed or compound actions. Reading flow: The progression from imports to documentation, enum member, and methods is natural. Slightly more spacing between import groups and before the class would improve visual organization.