Sample

pyint-ff03f511f80e-SRC

Unmodified source class

Lines23

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8310–1; higher is more readable
Mi0.2610–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro16.670–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.6210–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: 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.578.587−19.093
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.597−6.895

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.86.917+0.598
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.05+0.46
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.784−0.091
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.958−0.018
Indentation frequencyHow rapidly indentation changes from line to line.21−0.011

Intercept 0.07 + feature contributions = 1.592 (log-odds).
Score = sigmoid(1.592) = 0.831.

Score0.261
Score17
Run 1

The code is well-structured and follows clear logical organization. It imports only necessary modules, uses the attrs decorator cleanly, and defines a single validator class with a clear purpose. Nesting is minimal: the __call__ method has one conditional block, and __repr__ returns immediately. Intent is explicit through class naming, attribute defaults, docstring, and inline comments. Code length is appropriate—no unnecessary lines. Action granularity is strong: one action per line in critical sections, with the exception of the f-string message and raise combined logically. Reading flow is natural: class definition, validation check, then error message construction. Minor deductions: the comment in __call__ explains the class-based approach but could reference the repr override directly; the regex and operator imports appear unused, which slightly reduces clarity. Overall, it is a concise, maintainable, and highly readable snippet from the attrs library.

Run 2

The code is generally readable with clear intent. It defines a validator class using attrs, with a docstring explaining why a class is used. The structure is logical - import, class definition, validator method, repr. Nesting is minimal (single if statement). The score is slightly lower because: the __call__ method could be more concise; there's potential ambiguity around why 'inst' parameter is unused; the docstring placement inside __call__ rather than at class level is slightly unusual. However, the code is flat, concise, and each line performs one clear action. The variable names are mostly descriptive (msg, min_length). The repr clearly shows validator information. Minor improvements could include documenting the unused parameters or using _ for unused args, but overall it's quite readable.

Run 3

The code is well-structured in a single class with clear purpose. It uses a dataclass-style decorator (@attrs) to reduce boilerplate. The __call__ method has one level of nesting for validation, which is minimal. Naming is clear and consistent. The docstring and __repr__ improve clarity and debugging. The class is concise, with one action per line in the validation logic. Reading flow is natural: definition, operation, representation. Minor considerations: the import block is slightly long but standard; regex and contextmanager imports are unrelated to this snippet. No excessive nesting or ambiguity. Overall, highly readable.

Run 1

Code Structure: The validator is logically organized into configuration, validation, and representation methods, though numerous unused imports add clutter. Nesting: A single conditional keeps the code flat and easy to follow. Clarity of intent: The class name, min_length attribute, and descriptive error message clearly convey the purpose; the __call__ docstring explains implementation rather than validation behavior. Code length: The implementation is concise, but the unused imports are unnecessary for this snippet. Action granularity: Each line performs one clear action. Reading flow: The progression from attribute declaration to validation and representation is natural, although additional spacing between imports and the class would improve visual separation.

Run 2

Code Structure: The validator is logically organized into configuration, validation, and representation methods, although many imports are unused in this snippet. Nesting: Minimal nesting makes the control flow easy to follow. Clarity of intent: Descriptive class and attribute names, a straightforward condition, and a clear error message communicate the purpose well; the __call__ docstring explains the class design rather than the method's validation behavior. Code length: Compact and appropriately sized, aside from unnecessary imports. Action granularity: Each statement performs a single clear action. Reading flow: Natural progression from imports to class definition and methods, though an additional blank line before the top-level class would improve formatting.

Run 3

Code Structure: A small, logically organized validator class separates validation from representation. Nesting: Only one conditional level, making control flow easy to follow. Clarity of intent: Descriptive class and field names, a direct length comparison, and a helpful error message clearly communicate the purpose; the docstring explains the callable-class design rather than the validation behavior. Code length: The implementation is concise, although many imports are unused in this snippet. Action granularity: Statements generally perform one action per line, with error-message creation separated from raising the exception. Reading flow: Imports, class configuration, validation, and representation follow a natural order. Minor readability drawbacks include abbreviated parameter names and the unexplained attrs-specific decorator and field declaration.