Sample

pyint-273c22b4fe1e-I03

Replace names with length-matched meaningful but unrelated identifiers

Matched original source

Lines23

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8310–1; higher is more readable
Mi0.2590–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro14.330–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.5660–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 _MaxLengthValidator: max_length = attrib() def __call__(self, path, data, count): """ We use a callable class to be able to change the ``__repr__``. """ if len(count) > self.max_length: age = f"Length of '{data.name}' must be <= {self.max_length}: {len(count)}" raise ValueError(age) def __repr__(self): return f"<max_len validator for {self.max_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.61−6.915

Intercept 8.87 + feature contributions = -7.939 (log-odds).
Score = sigmoid(-7.939) = 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.259
Score17
Run 1

The code is moderately readable. It uses a clear class-based validator with a concise __call__ method, but has some issues: the parameter names ('path', 'data', 'count') are ambiguous — 'data' and 'count' likely mean 'attribute' and 'value'; the variable 'age' is odd and unrelated to the error message; a typo in 'max_len' vs 'max_length' in __repr__; and import of 're' is unused. The structure is logical but could be flatter. Overall, it's understandable but needs cleanup.

Run 2

The code is mostly readable due to its clear structure and intent. It uses a single-purpose class with a focused `__call__` method, and the import block is well-organized. The use of `attrs` to define a frozen, slotted validator keeps the code concise and idiomatic. However, there are readability issues: the variable name `age` is confusing (likely a typo for 'msg' or 'error'), which obscures the error message's purpose. The `__call__` method receives `path` and `data` parameters that are unused, which is misleading. The nesting level is low, and each action is on its own line, which aids readability. The `count` parameter name is also vague; it likely represents an iterable but could be clearer. Overall, the structure is good, but minor naming and unused parameters reduce clarity.

Run 3

The code has a clear structure and purpose, but contains issues that reduce readability. The function naming (`path`, `data`, `count`) is misleading—`count` suggests an integer but is actually a sequence (its length is checked). The error message uses vague 'age' instead of something meaningful. The class-based validator approach is understandable, but the mixing of unrelated imports and nested imports without explanation adds confusion. Some lines are too long, and the string formatting is inconsistent ('f"Length of..."' vs `f"<max_len validator for {self.max_length}>"`). The code is not deeply nested, which is positive, but the overall clarity of intent could be improved with better parameter names and more explicit error messaging.

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 and length comparison clearly express maximum-length validation, but 'count' misleadingly names a sized value, 'age' names an error message, and the docstring explains representation customization rather than validation behavior. The unused 'path' parameter is also unexplained. Code length: The implementation is concise, although unused imports unnecessarily lengthen it. Action granularity: Each line generally performs one clear action; constructing the error message separately from raising the exception improves readability. Reading flow: Configuration, validation, and representation follow a natural sequence, but inconsistent naming, minimal spacing between imports and the class, and limited parameter documentation interrupt comprehension.

Run 2

Code Structure: The validator is logically organized into configuration, validation, and representation methods, although numerous unused imports add clutter. Nesting: A single conditional keeps the code flat and easy to follow. Clarity of intent: The class name and length comparison communicate the purpose, but parameter names such as count and data are vague, path is unused, and age is a misleading name for an error message. The docstring explains the callable-class design rather than validation behavior. Code length: The implementation is concise, but unused imports unnecessarily increase its length. Action granularity: Each statement performs one clear action. Reading flow: The progression from the maximum-length attribute to validation and representation is natural, though inconsistent naming and limited spacing slightly interrupt readability.

Run 3

Code Structure: Imports, class definition, and methods are logically organized, though numerous unused imports add clutter. Nesting: Minimal nesting makes control flow easy to follow. Clarity of intent: The class name, max_length attribute, comparison, and error message clearly indicate length validation; however, misleading names such as count for a sized value and age for an error message reduce clarity, while path is unused. Code length: The implementation is concise, but unnecessary imports and a docstring focused on representation rather than validation distract from its purpose. Action granularity: Each line performs a single clear action. Reading flow: The progression from configuration to validation to representation is natural, although unconventional parameter names and limited spacing around the class definition slightly interrupt readability.