Sample

pyint-633d91296807-I02

Shorten method, parameter, and local names without collisions

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 Pro12.670–20; mean of three runs
GPT-6.1 Sol16.670–20; mean of three runs
BTTF0.6980–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, ins, att, val): for v2 in self._validators: v2(ins, att, val)

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.671−7.007

Intercept 8.87 + feature contributions = -7.384 (log-odds).
Score = sigmoid(-7.384) = 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.78+1.769
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.424
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.739+0.146

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

Score0.748
Score22
Run 1

The code is generally well-structured with clear imports, a clean class definition, and a docstring. The decorator usage is concise, and the single method has clear intent. However, it lacks context for how `@attrs` and `attrib()` are defined, which slightly impacts clarity for unfamiliar readers. The action granularity and nesting are good, with a flat structure and one action per line. Overall, it is readable but could benefit from type hints on parameters and return type to improve intent.

Run 2

The code demonstrates good logical organization, starting with future annotations, standard library imports, then grouped third-party/local imports, followed by exception imports. The class _AndValidator is concise with clear intent, using attrs decorators for declarative behavior and a simple loop for composed validation. Nesting is flat, action granularity is appropriate, and the reading flow is natural. However, readability is slightly reduced by incomplete context - the example ends abruptly, and the mixing of import styles (explicit names vs wildcard-like grouped imports) could be more consistent. The docstring and type hints are present but limited. Overall, the code is readable, maintainable, and logically structured.

Run 3

This code is a partial snippet missing its main class/function definitions, making evaluation incomplete. Structure is poor due to excessive unused imports, unclear imports (e.g., 'attrib' used but not imported), and an incomplete class definition. Nesting is minimal, but action granularity is hard to assess from such a fragment. Intent is ambiguous because the class name '_AndValidator' suggests a validator composition pattern, but without surrounding context, the purpose remains unclear. Code length is unnecessarily bloated with many unused imports (e.g., enum, itertools, linecache). Reading flow is broken by the abrupt cut-off. The snippet appears to be from a library (attrs-related), and the use of slots, unsafe_hash, and a private validator class shows some design intent, but overall the fragment is unreadable as-is. It needs surrounding code and pruning of unused imports to be readable. The missing import for 'attrib' is a major defect.

Run 1

Code Structure: Imports and the validator class are logically organized, though the many unused imports distract in this snippet. Nesting: Shallow, with only a loop inside the method. Clarity of intent: The class name and docstring clearly explain validator composition, but abbreviated parameters (ins, att, val) and v2 reduce clarity; attrs and attrib are not visibly imported. Code length: The implementation is concise, although the import block is disproportionate to the shown functionality. Action granularity: Each line performs a single action. Reading flow: The class reads naturally from documentation to stored validators to invocation, but the lengthy imports delay reaching the core logic.

Run 2

Code Structure: Imports are grouped before a small, logically organized validator class, though many imports are unrelated to the shown functionality. Nesting: Only one shallow loop, making control flow easy to follow. Clarity of intent: The class name and docstring clearly describe validator composition, but abbreviated parameters (ins, att, val) and the variable v2 reduce clarity. The attrs and attrib definitions are not visible in this excerpt. Code length: The class is concise, although the lengthy import section overwhelms its implementation. Action granularity: Each line performs a single clear action. Reading flow: The class flows naturally from configuration to stored validators to invocation, with minor friction from import clutter and abbreviated names.

Run 3

Code Structure: Imports and the validator class are logically separated, though the extensive import list distracts from this small excerpt. Nesting: Minimal; the method contains only a single loop. Clarity of intent: The class name and docstring clearly communicate validator composition, but abbreviated names such as ins, att, val, and v2 reduce clarity. Code length: The implementation is concise, although most imports are unused in the shown code. Action granularity: Each statement performs one action, with no compressed or compound lines. Reading flow: The class reads naturally from declaration to stored validators to execution; however, attrs and attrib are not defined or imported in the excerpt, requiring external context.