Sample

pyint-081adf221478-I04

Replace names with deterministic minifier-style shortest identifiers

Matched original source

Lines25

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8410–1; higher is more readable
Mi0.3660–1; higher is more readable
LLOC19Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol15.330–20; mean of three runs
BTTF0.4860–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 _NumberValidator: bound = attrib() compare_op = attrib() compare_func = attrib() def __call__(self, a, b, c): """ We use a callable class to be able to change the ``__repr__``. """ if not self.compare_func(c, self.bound): d = f"'{b.name}' must be {self.compare_op} {self.bound}: {c}" raise ValueError(d) def __repr__(self): return f"<Validator for x {self.compare_op} {self.bound}>"

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.655.551−21.633
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.571−6.856

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

Feature contributions

FeatureValueContribution
(log-odds)
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.72.846+0.58
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.056+0.393
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.57.115+0.117
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.743−0.064
Indentation frequencyHow rapidly indentation changes from line to line.23+0.058

Intercept 0.07 + feature contributions = 1.668 (log-odds).
Score = sigmoid(1.668) = 0.841.

Score0.366
Score19
Run 1

The code is generally readable with clear structure and intent. It uses a frozen attrs class for immutable validators, and the __call__ method is concise. However, variable names like 'a', 'b', 'c', and 'd' are ambiguous and reduce clarity—they obscure what the method parameters represent (instance, attribute, value). The nested f-string and conditional inside __call__ are fine, but the error message construction could be on multiple lines for better readability. The docstring explains why a callable class is used, which aids understanding. Overall, the logic is straightforward, but better naming would improve the score.

Run 2

The code is well-structured and readable. It uses clear naming (though generic for a small class), logical organization with attrs decorators, and keeps nesting minimal with only one if statement. The class has a single responsibility and the validation logic is concise. The one-argument-per-line pattern in the init is clean, and the __call__ method uses a simple guard clause. The __repr__ method enhances debuggability. Minor deductions: variable names like 'a', 'b', 'c', and 'd' reduce clarity despite the docstring explaining only the repr purpose. The import block also has unrelated imports that puzzle without context. Overall, the code is clear, flat, and demonstrates good action granularity.

Run 3

The code is generally well-structured with clear separation of concerns: imports are organized, and the _NumberValidator class has a single responsibility. The use of attrs decorators is concise and reduces boilerplate. However, readability suffers in a few areas: the __call__ method uses single-letter variable names (a, b, c) that obscure their purpose, and the error message construction mixes intent with implementation. The __repr__ method is clear but slightly dense. Nesting is minimal, which is good. The class-level attributes are flat and readable, but the overall action granularity in __call__ could be improved by extracting the validation logic into a named helper method. The code imports several unused symbols (operator, Pattern, contextmanager, get_run_validators, etc.), which adds noise. Overall, the logic is understandable but could benefit from better naming and removal of unnecessary imports.

Run 1

Code Structure: The validator is logically organized into attributes, validation behavior, and representation, although many imports are unused in this snippet. Nesting: A single conditional keeps the code flat and easy to follow. Clarity of intent: The class name, comparison fields, and error message communicate numeric validation, but parameters 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, with little unnecessary logic. Action granularity: Each statement performs one clear action. Reading flow: Attributes followed by __call__ and __repr__ form a natural sequence, though more descriptive parameter names and cleaner imports would improve readability.

Run 2

Code Structure: Imports and a compact validator class are logically organized, although several imports appear unused in this snippet. Nesting: Minimal nesting makes the validation logic easy to follow. Clarity of intent: The class name, comparison fields, error message, and representation communicate numeric-bound validation, but parameters a, b, c and temporary variable d obscure their roles. The __call__ docstring explains the callable-class design rather than the method's behavior. Code length: The implementation is concise, with little unnecessary logic; unused imports add clutter. Action granularity: Each statement performs one clear action. Reading flow: Field declarations, validation, and representation follow a natural sequence, though more descriptive parameter names and an additional blank line before the decorator would improve readability.

Run 3

Code Structure: Imports and a focused validator class are logically organized, although many imports are unused in this snippet. Nesting: Minimal nesting makes the control flow easy to follow. Clarity of intent: The class name, comparison fields, and error message clearly convey numeric 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 validation behavior. Code length: Compact and mostly purposeful, with unnecessary imports adding clutter. Action granularity: Each statement performs one action, and error construction is separated from raising the exception. Reading flow: The progression from configuration fields to validation and representation is natural, though descriptive parameter names and better spacing around the class would improve readability.