Sample

pyint-1e98067322a5-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines25

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8330–1; higher is more readable
Mi0.7290–1; higher is more readable
LLOC18Logical lines; fewer is more readable
DeepSeek V4 Pro14.330–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.6110–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 not (len(value) < self.min_length): pass else: 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.621.528−20.51
Source linesThe number of non-empty source lines.25+10
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.548−6.822

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.86.923+0.598
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.051+0.444
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.26+0.116
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.24.818−0.063
Indentation frequencyHow rapidly indentation changes from line to line.23+0.058
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.923−0.016

Intercept 0.07 + feature contributions = 1.605 (log-odds).
Score = sigmoid(1.605) = 0.833.

Score0.729
Score18
Run 1

The code is fairly readable but has some awkward spots. Structure is logical, with a single small frozen attrs class and a clear __call__ validator method. Nesting is flat, which is good. Clarity of intent is decent: the class name and error message make the purpose clear, though the inverted 'if not...else' is confusing. Code length is appropriate—no bloat. Action granularity is mixed: the validation logic is split across multiple lines, but the 'if/else' pattern is inverted and could be simplified to a single guard clause. Reading flow is interrupted by the odd branching style and the pointless 'pass' branch. Overall, the code works but would be more readable with a direct 'if len(value) < self.min_length: raise ValueError(...)'. The docstring adds useful context but interrupts flow slightly.

Run 2

The code is generally readable but has some questionable choices. The class and method names clearly convey intent, and the use of attrs reduces boilerplate. However, the `if`/`else` structure in `__call__` is inverted and unnecessarily awkward: `if not (condition): pass else: raise` is harder to parse than a simple `if condition: raise`. The `msg` line is long, reducing readability. The `__repr__` is clear. Imports are organized but include an unused-looking `Pattern` import. Overall, structure is logical and nesting is shallow, but the conditional logic harms clarity and flow.

Run 3

The code is fairly readable with clear intent: it defines a frozen attrs class implementing a minimum-length validator. Structure is logical, with imports grouped, a single class, and a well-placed docstring. Nesting is shallow — the main method contains one if/else, though the negative condition followed by 'pass' reduces clarity and could be simplified to 'if len(value) < self.min_length: raise ...'. Granularity is good: one operation per line in the core logic. Length is concise. Reading flow is natural, though line 5's 'from re import Pattern' is unused, and the import of 'Pattern' adds minor noise. The __repr__ is clear. Overall, the code is easy to follow but could improve readability by inverting the if/else condition, removing the pass, and dropping unused imports.

Run 1

Code Structure: The validator is logically organized into state, validation, and representation methods, but numerous unused imports distract from this small snippet. Nesting: Shallow, though the unnecessary if/pass/else structure adds avoidable branching. Clarity of intent: Class and attribute names communicate minimum-length validation clearly, and the error message is informative. However, the negated comparison makes the condition harder to parse, and the call-method docstring explains representation design rather than validation behavior. Code length: Mostly concise, but unused imports and the empty success branch add clutter; a direct 'if len(value) < self.min_length' would be shorter and clearer. Action granularity: Each statement performs a single action, with message construction separated from raising the exception. Reading flow: The class reads naturally overall, but the inverted condition and pass interrupt the straightforward validation flow.

Run 2

Code Structure: The validator is logically organized into initialization, validation, and representation methods, but numerous unused imports distract from the small implementation. Nesting: Nesting is shallow, although the empty success branch and else block add unnecessary structure. Clarity of intent: Names and the error message clearly communicate minimum-length validation; the negated comparison is less direct than testing len(value) < self.min_length. The __call__ docstring explains a class-design choice rather than the method's behavior. Code length: The class is concise, but unused imports and the pass branch inflate it unnecessarily. Action granularity: Each line generally performs one clear action. Reading flow: The class reads naturally overall, but the inverted condition interrupts the straightforward check-and-raise flow.

Run 3

Code Structure: The validator class logically groups its configuration, validation behavior, and representation, but numerous unused imports add clutter. Nesting: Shallow overall, though the pass/else branch introduces unnecessary control flow. Clarity of intent: Class and field names communicate minimum-length validation clearly; however, the negated comparison obscures a simple failure condition, and the __call__ docstring explains representation rather than validation. Code length: Compact, but unused imports and the empty success branch are unnecessary. Action granularity: Statements generally perform one action per line, with error-message construction separated from raising the exception. Reading flow: The class reads naturally from configuration to validation to representation, but 'if not ...: pass; else ...' interrupts that flow. A direct 'if len(value) < self.min_length:' would improve readability.