Sample

pyint-01fa3dbc4d7e-I06

Invert eligible conditions and exchange their branches

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 Pro160–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 well-structured and follows common Python conventions. Imports are grouped logically (standard library, third-party, relative), and the module-level class definition is clear with a concise docstring. The `_AndValidator` class has a single, obvious responsibility and uses attrs decorators cleanly, avoiding boilerplate. However, several imported names (e.g., `_get_annotations`, `_lazy_is_generator`, `get_generic_base`, `PY_3_11_PLUS`) are used elsewhere, so the import block feels slightly cluttered without visible context. The conditional imports and compatibility shims add noise for a reader only looking at this snippet. Naming is clear, and action granularity is one action per line. Overall readability is strong but slightly reduced by the dense import section and reliance on external library context.

Run 3

The code is generally readable with a clear structure: imports are organized into logical groups, and the class/function definitions are concise and focused. The `_AndValidator` class clearly demonstrates its purpose through the docstring and straightforward `__call__` method. Nesting is minimal, and each action is on its own line, contributing to good clarity. However, the score is tempered by the large number of imports, some of which are private or beta-flagged (e.g., `_AnnotationExtractor`, `PY_3_13_PLUS`), which can obscure intent for unfamiliar readers. The use of decorators like `@attrs(slots=True, unsafe_hash=True)` is standard for the library but may require prior knowledge. Overall, the code is maintainable and logically organized, but its reliance on internal imports slightly hinders immediate comprehension.

Run 1

Code Structure: Imports are grouped logically, followed by a small, cohesive validator class, although attrs and attrib are not defined or imported in the excerpt. Nesting: Shallow nesting makes execution easy to follow. Clarity of intent: The class name, docstring, and straightforward loop clearly communicate validator composition; abbreviated names such as v, inst, and attr slightly reduce clarity. Code length: The implementation is concise, but the extensive imports appear unused in this excerpt and distract from its purpose. Action granularity: Each line performs one clear action. Reading flow: The class reads naturally from declaration to stored validators to invocation, though additional blank lines between import groups and before the class would improve visual separation.

Run 2

Code Structure: Imports are grouped sensibly, followed by a small, focused validator class, though many imports are unused in this excerpt. Nesting: Minimal nesting makes the execution path easy to follow. Clarity of intent: The class name, docstring, and straightforward loop clearly convey validator composition; however, attrs and attrib are not defined or imported in the excerpt, and abbreviated names such as v and inst slightly reduce clarity. Code length: The implementation is concise, but the extensive import block is disproportionate to the functionality shown. Action granularity: Each statement performs a single action, with no compressed or compound lines. Reading flow: The class reads naturally from its stored validators to their invocation, although the import-heavy opening and limited spacing between sections mildly interrupt the flow.

Run 3

Code Structure: Imports are grouped before a small, logically organized validator class, although many imports are unused in this excerpt. Nesting: Minimal nesting makes execution easy to follow. Clarity of intent: The class name and docstring clearly communicate validator composition, but the abbreviated names inst, attr, and v and the missing definitions or imports of attrs and attrib reduce self-contained clarity. Code length: The class implementation is concise, while the extensive import section is disproportionate to the shown functionality. Action granularity: Each statement performs one action, with no compressed or compound lines. Reading flow: The progression from class declaration to stored validators to sequential invocation is natural; the large import block and limited spacing between top-level sections slightly interrupt that flow.