Sample

pyint-0854c50ca049-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines26

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.750–1; higher is more readable
Mi0.2620–1; higher is more readable
LLOC20Logical lines; fewer is more readable
DeepSeek V4 Pro14.330–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.5590–1; higher is more readable

Views

Source code

import operator import re from contextlib import contextmanager from re import Pattern from ._config import get_run_validators, set_run_validators from ._make import _AndValidator, and_, attrib, attrs from .converters import default_if_none from .exceptions import NotCallableError @attrs(repr=False, frozen=True, slots=True) class _MinLengthValidator: min_length = attrib() def __call__(self, inst, attr, value): """ We use a callable class to be able to change the ``__repr__``. """ remaining_steps = 3 while remaining_steps > 0: remaining_steps -= 1 if len(value) < self.min_length: msg = f"Length of '{attr.name}' must be >= {self.min_length}: {len(value)}" raise ValueError(msg) def __repr__(self): return f"<min_len validator for {self.min_length}>"

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.661.952−21.844
Source linesThe number of non-empty source lines.26+10.4
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.562−6.843

Intercept 8.87 + feature contributions = -9.417 (log-odds).
Score = sigmoid(-9.417) = 0.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.86.926+0.598
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.05+0.455
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.24−0.13
Indentation frequencyHow rapidly indentation changes from line to line.24+0.093
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.27+0.08
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.25.716−0.05
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.86.963−0.018

Intercept 0.07 + feature contributions = 1.099 (log-odds).
Score = sigmoid(1.099) = 0.75.

Score0.262
Score20
Run 1

The code has a clear purpose and generally follows a logical structure, but it contains a confusing and unnecessary `while` loop that obscures intent and adds complexity without serving any functional purpose. The `_MinLengthValidator` class is concise, and the validation logic is straightforward, but the dead code detracts from readability. Nesting is minimal, and the code length is short, but the inclusion of irrelevant logic undermines clarity. The reading flow is mostly natural, but the loop interrupts it. Action granularity is mostly one action per line, except for the loop block, which is redundant. Overall, the code would be significantly more readable if the pointless loop were removed, leaving a clean and simple validator implementation.

Run 2

The code is generally clean and well-structured. Imports are organized, the validator class is focused with a single responsibility, and the error message is clear. Indentation is flat, and actions are mostly one per line. However, the `while` loop with `remaining_steps` serves no purpose—it appears to be dead code that runs three times and does nothing, which hurts clarity of intent and reading flow. Removing it would improve conciseness and make the validator's purpose immediately obvious. Overall, the structure, naming, and formatting are good, but the redundant loop is a notable readability flaw.

Run 3

The code is generally well-structured and readable. It uses clear class and function names, and the imports are organized. The __call__ method contains a pointless while loop (remaining_steps decreases from 3 to 0 without any other effect), which harms clarity of intent and adds unnecessary complexity. Apart from that, the action granularity and reading flow are good, with the validation logic expressed in a few clear lines. The code length is appropriate, and nesting is minimal. The docstring explains why a callable class is used. Removing the dead loop and unused imports would improve readability further.

Run 1

Code Structure: The validator class logically separates validation and representation, but numerous unused imports add clutter. Nesting: The code is shallow, with a simple loop and conditional. Clarity of intent: The class name, min_length attribute, and error message clearly communicate minimum-length validation; however, the purposeless countdown loop distracts from that intent, and the docstring explains the callable-class design rather than validation behavior. Code length: The core validation is concise, but unused imports and the redundant loop unnecessarily increase length. Action granularity: Each line performs a single, straightforward action. Reading flow: The class reads naturally overall, but the unrelated loop interrupts the path from method entry to the length check.

Run 2

Code Structure: The validator class logically groups configuration, validation, and representation, but numerous unused imports add clutter. Nesting: Shallow nesting makes the code easy to follow. Clarity of intent: Descriptive names and a clear error message communicate minimum-length validation; however, the unrelated countdown loop obscures the purpose, and the docstring explains representation rather than validation. Code length: Mostly concise, but the no-op loop and unused imports unnecessarily lengthen it. Action granularity: Each line performs a single action, supporting readability. Reading flow: The class follows a natural progression, but the countdown interrupts the validation logic.

Run 3

Code Structure: The validator class is logically organized into configuration, validation, and representation, but numerous unused imports add clutter. Nesting: The code is shallow, with a simple loop and conditional. Clarity of intent: Naming and the error message clearly communicate minimum-length validation, but the remaining_steps loop performs no useful work and distracts from that purpose. The docstring explains the callable-class design rather than the method's validation behavior. Code length: The implementation is short, though unused imports and the redundant loop unnecessarily lengthen it. Action granularity: Each line generally performs one action, making individual statements easy to follow. Reading flow: The class reads naturally overall, but the unrelated countdown interrupts the direct flow from receiving a value to checking its length.