Sample

pyint-7c95dadf55d8-I03

Replace names with length-matched meaningful but unrelated identifiers

Matched original source

Lines28

Scores

MethodScoreScale
Posnett0.0010–1; higher is more readable
Dorn0.7770–1; higher is more readable
Mi0.0770–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro10.670–20; mean of three runs
GPT-6.1 Sol15.330–20; mean of three runs
BTTF0.4610–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, slots=True, unsafe_hash=True) class _InstanceOfValidator: type = attrib() def __call__(self, flag, user, price): """ We use a callable class to be able to change the ``__repr__``. """ if not isinstance(price, self.type): key = f"'{user.name}' must be {self.type!r} (got {price!r} that is a {price.__class__!r})." raise TypeError( key, user, self.type, price, ) def __repr__(self): return f"<instance_of validator for type {self.type!r}>"

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.635.312−20.965
Source linesThe number of non-empty source lines.28+11.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.42−6.63

Intercept 8.87 + feature contributions = -7.525 (log-odds).
Score = sigmoid(-7.525) = 0.001.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.103+0.857
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.103−0.697
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.048+0.472
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Indentation frequencyHow rapidly indentation changes from line to line.26+0.162
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.27.779−0.022
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.29+0.01

Intercept 0.07 + feature contributions = 1.25 (log-odds).
Score = sigmoid(1.25) = 0.777.

Score0.077
Score17
Run 1

The code has some clear structure with imports grouped at the top and a single class definition. However, there are several readability issues. The method signature `__call__(self, flag, user, price)` is confusing—`flag` is unused and parameter names (`user`, `price`) are misleading in a validator context. The nested f-string error message is hard to parse, and the error raising spans multiple lines unnecessarily. The class is small and concise, but intent is unclear due to poor naming. Action granularity is mixed; the `if` block contains multiple operations, reducing clarity. Reading flow suffers from the odd parameter choices and the dense error construction.

Run 2

The code is moderately readable but has several issues. It uses clear class naming and type hints, and the __call__ method is straightforward, though it confusingly names parameters 'flag' and 'user' when the actual validation target appears to be 'price'. The error message construction is verbose and breaks natural reading flow by splitting a simple string across multiple lines without need. The multiple imports are fine, but unused ones (operator, re, Pattern, contextmanager, etc.) appear present, suggesting code bloat. Nesting is minimal, which is good, and action granularity is acceptable, but the parameter naming obscures intent. The __repr__ method is clear but could be a simple f-string in a dataclass-like setup. Overall, the structure is logical but hindered by unclear parameter names and unnecessary verbosity in error handling.

Run 3

The code has some readable elements (clear class purpose, reasonable docstring, concise type validation logic), but suffers from several issues. The variable naming is confusing: parameters 'flag' and 'user' do not match their actual usage—'flag' is unused, and 'user' appears to represent an attribute/field, not a user. The error message uses 'user.name' without clarity about what 'user' is, making intent ambiguous. The 'flag' parameter is never used, creating dead complexity. The error construction spans multiple lines unnecessarily, and the exception arguments appear to mix error semantics. The overall structure is acceptable, but the misleading names, unused parameter, and ambiguous error messaging reduce readability significantly. The code is relatively short and flat, which helps, but the clarity and intent are undermined by poor naming and inconsistent abstraction.

Run 1

Code Structure: A small, logically organized validator class cleanly separates validation and representation, though numerous unused imports add clutter. Nesting: Minimal nesting, with only one conditional inside the validation method. Clarity of intent: The class name and isinstance check clearly communicate type validation, but parameter names such as flag, user, and price are misleading for a generic validator; key is also an unclear name for an error message. The docstring explains the callable-class design rather than the method's behavior. Code length: The implementation is concise, although unused imports and the expanded exception call add visual overhead. Action granularity: Statements generally perform one action each. Reading flow: Execution follows a natural check-and-raise sequence, followed by a straightforward representation method; ambiguous naming and the long error-message line slightly interrupt readability.

Run 2

Code Structure: The validator class is logically organized, though numerous unused imports clutter the snippet. Nesting: A single conditional keeps control flow shallow and easy to follow. Clarity of intent: The class name, isinstance check, and representation communicate type validation clearly, but parameter names flag, user, and price obscure their roles; key is also a misleading name for an error message. The docstring explains the callable-class design rather than the method's validation behavior. Code length: The implementation is compact, although unused imports and the expanded exception arguments add visual overhead. Action granularity: Each statement performs one clear action. Reading flow: Imports, class configuration, validation, and representation follow a natural sequence, but inconsistent domain-oriented naming interrupts comprehension.

Run 3

Code Structure: Imports and a small validator class are logically organized, though several unused imports add clutter. Nesting: A single conditional keeps nesting shallow. Clarity of intent: The class name, isinstance check, and representation clearly identify a type validator, but parameter names such as flag, user, and price obscure their roles; key is also an unclear name for an error message. The docstring explains the callable-class design rather than the method's behavior. Code length: The implementation is compact, although the long error-message line is harder to scan. Action granularity: Each statement performs a distinct action, with the exception arguments clearly separated across lines. Reading flow: Validation followed by error reporting reads naturally, and __repr__ is straightforward; unused imports and misleading names slightly disrupt comprehension.