Sample

pyint-42eab0f8a7e8-I05

Rewrite eligible decimal integer literals in hexadecimal notation

Matched original source

Lines40

Scores

MethodScoreScale
Posnett0.0010–1; higher is more readable
Dorn0.8560–1; higher is more readable
Mi0.7480–1; higher is more readable
LLOC22Logical lines; fewer is more readable
DeepSeek V4 Pro13.330–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.6740–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, ) @attrs(slots=True, unsafe_hash=True) class _AndValidator: """ Compose many validators to a single one. """ _validators = attrib() def __call__(self, inst, attr, value): for v in self._validators: v(inst, attr, value)

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.765.065−25.247
Source linesThe number of non-empty source lines.40+16
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.657−6.986

Intercept 8.87 + feature contributions = -7.363 (log-odds).
Score = sigmoid(-7.363) = 0.001.

Feature contributions

FeatureValueContribution
(log-odds)
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.44.829+1.766
Indentation frequencyHow rapidly indentation changes from line to line.38+0.577
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.38−0.451
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.053+0.428
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.41−0.415
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.28.976−0.337
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.39.826+0.147

Intercept 0.07 + feature contributions = 1.785 (log-odds).
Score = sigmoid(1.785) = 0.856.

Score0.748
Score22
Run 1

The code is generally well-structured and follows clear conventions. Imports are organized into logical groups: standard library, third-party/relative, and specific module imports. The module-level import of `attrib`, `attrs`, and `setters` from the package is clear. The `_AndValidator` class has a concise docstring explaining its purpose, and the `__call__` method is easy to follow with a flat loop and a single action per line. The use of `slots=True` and `unsafe_hash=True` is idiomatic for attrs. Minor deductions: the import of `setters` and `attrib` appear without explicit listing in the provided snippet, relying on implicit wildcard or prior context, which could reduce clarity if the reader lacks context. Overall, it is readable, maintainable, and adheres to typical style guides.

Run 2

The code is generally clean and well-structured. Imports are logically grouped (stdlib, third-party/local), aliases are used effectively, and the class definition is concise with a clear purpose. The decorator attributes like `slots=True` and `unsafe_hash=True` are clear. However, the `__call__` method uses single-letter variables (`v`, `inst`, `attr`) which slightly hampers immediate clarity, and `_validators = attrib()` lacks context without seeing the full attrs setup. Despite this, the flat nesting, one-action-per-line style, and minimal docstring keep the code straightforward. Overall readability is high but not perfect due to minor naming and dependency ambiguity.

Run 3

The code is difficult to evaluate fully as it appears to be an incomplete snippet. The imports are organized but numerous, with some unused imports likely (e.g., enum, abc, contextlib). The decorator '@attrs' and functions like 'attrib()' are used without visible imports or definitions in the snippet, making intent unclear. The class _AndValidator has a clear purpose but lacks type hints and docstring for parameters. Nesting is flat, which is good, but the incomplete context and missing definitions reduce readability. The code length is concise for what it shows, but extraneous imports add noise. Action granularity is fine, with one action per line in the method. Reading flow is disrupted by the disconnect between imports and actual usage, plus the undefined names. Without surrounding context, the snippet is ambiguous and hard to follow, leading to a low score.

Run 1

Code Structure: Imports are grouped logically, followed by a small, focused class, although many imports are unused in this snippet. Nesting: Minimal nesting makes execution easy to follow. Clarity of intent: The class name and docstring clearly convey validator composition; however, attrs and attrib are not imported or defined in the shown code, and abbreviated names such as v and inst reduce clarity slightly. Code length: The implementation is concise, but the extensive import block outweighs the actual functionality. Action granularity: Each statement performs a single action. Reading flow: The class flows naturally from stored validators to sequential invocation, though missing spacing between import groups and before the decorator slightly weakens visual organization.

Run 2

Code Structure: Imports and the validator class are logically separated, although the many imports appear unrelated to this short excerpt. Nesting: A single loop inside the method keeps nesting shallow. Clarity of intent: The class name, docstring, and straightforward iteration clearly convey validator composition; abbreviated names such as v, inst, and attr slightly reduce clarity. The attrs and attrib definitions are not visible in the excerpt. Code length: The implementation is concise, but the import block dominates the snippet. Action granularity: Each line performs a single clear action. Reading flow: The class reads naturally from its purpose to its stored validators and invocation behavior, though additional spacing between import groups would improve scanning.

Run 3

Code Structure: Imports and validator class are logically separated, though many imports are unused in this excerpt and attrs/attrib are not visibly imported. Nesting: Only a simple loop inside a method, making control flow easy to follow. Clarity of intent: The class name, docstring, and straightforward validator calls clearly communicate composition; abbreviated names such as v and inst slightly reduce clarity. Code length: The implementation is concise, but the large import block overwhelms the small class. Action granularity: Each statement performs one clear action. Reading flow: The class reads naturally from declaration to stored validators to invocation, although the extensive imports delay reaching the relevant logic.