Sample

pyint-916070f65c16-I12

Inline all eligible single-use intermediate local variables

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 Pro16.670–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 has a clear, organized structure with imports grouped logically and a well-named class. The class uses decorators and a docstring, which aid clarity. Nesting is flat, with a single loop inside the __call__ method. Intent is clear from the class name, docstring, and concise validator implementation. Length is minimal, though some imports appear unused (e.g., linecache, sys, types, unicodedata) which could signal cruft. Each line is focused on one action, and reading flow is natural. Minor deductions: unused imports and reliance on external decorators like @attrs and attrib() without local definition may obscure intent slightly for readers unfamiliar with the attrs library. Overall, the snippet is highly readable but not perfect due to potential import noise and implicit conventions.

Run 3

The code is highly readable with clear structure and organization. Imports are grouped logically by Python standard library, third-party, and relative modules, with `__future__` import placed correctly. The class definition is concise, uses the popular attrs library with sensible parameters, and has a clear docstring explaining purpose. The validator method is flat with a single loop, one action per line, showing clear intent. Names are descriptive and consistent with common Python patterns. The code is appropriately short, avoiding unnecessary complexity. The overall reading flow is natural, making it easy for developers to understand the class's role as a composite validator with minimal cognitive overhead.

Run 1

Code Structure: Imports are grouped coherently, followed by a small, focused class, though attrs and attrib are not defined or imported in the snippet. Nesting: Minimal, with only a straightforward loop inside a method. Clarity of intent: The class name and docstring clearly explain validator composition; abbreviated parameters and the loop variable v slightly reduce clarity. Code length: The class is concise, but the extensive imports are unused in the shown code and distract from its purpose. Action granularity: Each line performs a single action. Reading flow: The class reads naturally from declaration to stored validators to invocation, although the large import section delays reaching the relevant logic.

Run 2

Code Structure: Imports are grouped logically and followed by a small, focused class, although many imports are unused in this excerpt. Nesting: Shallow; the method contains only a single loop. Clarity of intent: The class name and docstring clearly describe validator composition, but abbreviated names such as v, inst, and attr slightly reduce clarity. The origins of attrs and attrib are not shown. Code length: The implementation is concise, though the extensive import block dominates the excerpt. Action granularity: Each statement performs one action, with no compressed multi-statement lines. Reading flow: The progression from imports to class declaration, stored validators, and invocation is natural and easy to follow.

Run 3

Code Structure: Imports and the validator class are logically separated, though the numerous imports are disproportionate to the small excerpt. Nesting: Only a single loop inside a method keeps nesting shallow. Clarity of intent: The class name and docstring clearly explain validator composition; abbreviated names such as v, inst, and attr slightly reduce clarity. Code length: The implementation is concise, but most imports are unused in the shown code. Action granularity: Each line performs one clear action. Reading flow: The class reads naturally from declaration to stored validators to invocation, although the lengthy import section delays the relevant logic. The undefined-in-excerpt attrs and attrib names also require external context.