Sample

pyint-5397de885c36-I04

Replace names with deterministic minifier-style shortest identifiers

Matched original source

Lines23

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.840–1; higher is more readable
Mi0.3670–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol15.670–20; mean of three runs
BTTF0.6260–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, a, b, c): """ We use a callable class to be able to change the ``__repr__``. """ if len(c) > self.max_length: d = f"Length of '{b.name}' must be <= {self.max_length}: {len(c)}" raise ValueError(d) 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.613−6.919

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

Feature contributions

FeatureValueContribution
(log-odds)
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.051+0.443
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
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.78+0.361
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.68.667+0.303
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.823−0.091
Indentation frequencyHow rapidly indentation changes from line to line.21−0.011

Intercept 0.07 + feature contributions = 1.661 (log-odds).
Score = sigmoid(1.661) = 0.84.

Score0.367
Score17
Run 1

The code is generally readable and well-structured. It has a clear purpose: defining a max-length validator. Imports are organized, and the class uses sensible decorators. The __call__ method checks length and raises ValueError with a descriptive message, though single-letter parameter names (a, b, c) reduce clarity. The docstring explains why a class is used, which helps intent. Nesting is minimal. The custom __repr__ is helpful. However, the parameter names harm readability, and the conditional check could be slightly more explicit. Code length is concise and appropriate. Overall, it is readable but could be improved with better naming.

Run 2

The code demonstrates good readability with clear structure and low nesting (single-level if). The class is logically organized with minimal methods and clear intent. However, variable names (a, b, c) are very poor and cryptic, obscuring their purpose despite docstrings. The __call__ method signature would benefit from descriptive parameters. The action granularity is good—one action per line (length check, format, raise). The reading flow is natural: import, class definition, call method, repr. The use of attrs decorators is clean. The f-string is readable but variably named. Code length is appropriate for the task. Overall, strong structural clarity undermined by opaque parameter names, preventing a higher score.

Run 3

The code is generally readable: it has a logical structure, minimal nesting, clear intent, and concise length. Each logical action (length check, error message creation, exception raise) is separated appropriately. However, the use of single-letter variable names (a, b, c, d) in the __call__ method and the import of re/Pattern without usage in this snippet slightly reduce clarity. The error message construction also crams a conditional expression into one line, hurting action granularity.

Run 1

Code Structure: The validator class is logically organized, with configuration, validation, and representation separated into small 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, max_length attribute, and error message clearly communicate the validation purpose, but parameter names a, b, c and temporary variable d obscure their roles. The docstring explains the callable-class design rather than the method's behavior. Code length: The implementation is concise, although unused imports unnecessarily lengthen the snippet. Action granularity: Each statement performs one clear action, and message construction is separated from raising the exception. Reading flow: The class follows a natural progression, but cryptic names and import noise slightly interrupt comprehension.

Run 2

Code Structure: The validator is logically organized into an attribute, validation method, and representation method, though numerous unused imports add clutter. Nesting: A single conditional keeps nesting shallow. Clarity of intent: The class name, max_length attribute, and error message make the purpose clear, but parameter names a, b, c and temporary variable d obscure their roles. The docstring explains the callable-class design rather than the validation behavior. Code length: The implementation is concise, although imports could be reduced and the temporary error-message variable is unnecessary. Action granularity: Each line generally performs one action. Reading flow: The sequence is natural and easy to follow, with minor friction from vague names and unexplained decorator options.

Run 3

Code Structure: The validator is logically organized into initialization metadata, validation, and representation, though numerous unused imports add clutter. Nesting: A single conditional keeps the code shallow and easy to follow. Clarity of intent: The class name, max_length attribute, and error message clearly communicate length validation, but parameter names a, b, c and temporary variable d obscure their roles. The docstring explains the callable-class design rather than the method's behavior. Code length: The implementation is concise, although unused imports increase unnecessary length. Action granularity: Each line performs a distinct action, making individual operations easy to identify. Reading flow: The sequence from checking length to constructing an error and raising it is natural, followed by a straightforward representation method; more descriptive names and cleaner imports would improve readability.