Sample

pyint-cb8b8de39ac9-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines23

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7690–1; higher is more readable
Mi0.6130–1; higher is more readable
LLOC16Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.6180–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__``. """ if len(value) < self.min_length: raise ValueError((f"Length of '{attr.name}' must be >= {self.min_length}: {len(value)}")) 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.570.029−18.811
Source linesThe number of non-empty source lines.23+9.2
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.598−6.897

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.101+0.825
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.100.958−0.611
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.052+0.434
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.24+0.187
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.22.735−0.092
Indentation frequencyHow rapidly indentation changes from line to line.21−0.011

Intercept 0.07 + feature contributions = 1.2 (log-odds).
Score = sigmoid(1.2) = 0.769.

Score0.613
Score16
Run 1

The code is well-structured and highly readable. It has a single, focused class with clear responsibility (minimum length validation). Nesting is minimal—only one conditional, which is flat and easy to follow. Intent is explicit through the class name, method name, and docstring. The code is concise without being cryptic. Action granularity is appropriate: the validation check, whitespace, and raise statement are separated, improving readability. Reading flow is natural, from definition to call to error handling. Minor deductions: the blank line after the `if` statement is slightly unusual and the `raise` could be on the same line as the condition for tighter flow, but these are stylistic. Overall, it is clean, maintainable, and easy to understand.

Run 2

The code is generally clear and well-structured. It uses modern attrs features like frozen, slots, and dataclass-style attributes, which reduce boilerplate. The class has a single responsibility (minimum length validation) and the intent is obvious from the name and docstring. Nesting is minimal. However, there are some readability issues: an unnecessary blank line inside the method, the import of operator, re, Pattern, default_if_none, and several other items appears unused (dead code), and the raise statement is split over two lines unnecessarily. The docstring phrasing 'We use a callable class...' is slightly awkward. The error message formatting is clear but could be on one line. Overall, it's professional, idiomatic attrs code with minor cleanup opportunities.

Run 3

The code is mostly readable but has some minor issues. Structure is logical and imports are organized, but there's an unused import (Pattern) and the `operator` import isn't used in this snippet. Nesting is flat, which is good, but the `__call__` method has an unnecessary blank line before the raise statement. Clarity of intent is clear; the class name and docstring explain the purpose well. Code length is concise with no unnecessary verbosity. Action granularity is appropriate, with one main action per line. Reading flow is generally natural, though the `__call__` method could be more tightly formatted. The unused imports and blank line slightly reduce overall readability.

Run 1

Code Structure: The validator class is logically organized, with separate validation and representation methods, though many imports are unused in this snippet. Nesting: A single conditional keeps the code shallow and easy to follow. Clarity of intent: Descriptive class and attribute names clearly communicate minimum-length validation; the call method's docstring explains the class design rather than its validation behavior. Code length: The implementation is concise, but unnecessary parentheses, an extra blank line, and unused imports add clutter. Action granularity: Each statement performs one clear action, although the exception line is long. Reading flow: Imports, class configuration, validation, and representation appear in a natural order; minor formatting issues slightly interrupt the flow.

Run 2

Code Structure: The validator class is logically organized into configuration, validation, and representation, though numerous unused imports add clutter. Nesting: A single conditional keeps the code shallow and easy to follow. Clarity of intent: Descriptive names and the error message clearly communicate minimum-length validation; the callable-method docstring explains a design choice rather than its behavior. Code length: The implementation is concise, but unused imports, an empty line before the exception, and redundant parentheses are unnecessary. Action granularity: Each statement performs one clear action. Reading flow: The class reads naturally from its minimum-length attribute through validation to representation, although the long exception line slightly disrupts readability.

Run 3

Code Structure: The small validator class logically groups its configuration, validation logic, and representation, though numerous unused imports add clutter. Nesting: The code is shallow, with only one conditional inside the validation method. Clarity of intent: Class and attribute names clearly communicate minimum-length validation; however, the __call__ docstring explains the callable-class design rather than the method's behavior. Code length: The implementation is concise, but unused imports, an empty line before the exception, and redundant parentheses are unnecessary. Action granularity: Each statement performs a single clear action. Reading flow: Configuration, validation, and representation follow a natural sequence, slightly weakened by inconsistent spacing and the long exception line.