Sample

pyint-53c1be945bdd-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines25

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8330–1; higher is more readable
Mi0.3530–1; higher is more readable
LLOC19Logical lines; fewer is more readable
DeepSeek V4 Pro17.670–20; mean of three runs
GPT-6.1 Sol17.330–20; mean of three runs
BTTF0.5370–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, ins, att, val): """ We use a callable class to be able to change the ``__repr__``. """ if not self.compare_func(val, self.bound): msg2 = f"'{att.name}' must be {self.compare_op} {self.bound}: {val}" raise ValueError(msg2) 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.593−6.889

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

Feature contributions

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

Intercept 0.07 + feature contributions = 1.606 (log-odds).
Score = sigmoid(1.606) = 0.833.

Score0.353
Score19
Run 1

The code demonstrates good structure with a single class definition using the attrs decorator pattern. Nesting is minimal with only one conditional inside the __call__ method. Intent is clear - a numeric validator that compares a value against a bound. The code is concise, avoiding unnecessary verbosity. Action granularity is appropriate with one main operation per line. Reading flow is natural, starting with imports, then class definition, methods, and ending with repr. Minor deductions: the docstring could be more descriptive about the validator's purpose, and the error variable 'msg2' suggests possible refactoring needs (why '2'?). The imports appear partially unused in this snippet (operator, re, Pattern, contextmanager, etc.), which could indicate either the snippet is incomplete or there are unused imports. Overall, the code is highly readable with clear separation of concerns and followable logic.

Run 2

The code is highly readable with a clear, focused purpose. Structure is logical: imports are organized, and the class uses the attrs decorator cleanly to define a small validator. Nesting is minimal with only one conditional block. Intent is explicit—a reusable numeric comparison validator. Length is concise for what it does. Each action (comparison, message construction, exception raise) is on its own line, aiding clarity. Reading flow is natural from import to class definition to method logic. Minor deductions: the docstring inside __call__ is slightly redundant and the error message construction could be marginally simplified, but neither harms clarity.

Run 3

The code is highly readable with a clear logical structure. It uses frozen/slotted attrs class, minimizing complexity. The class has a single responsibility (number comparison validation) with clear naming conventions. Nesting is minimal - only one conditional inside __call__. Intent is explicit through descriptive attribute names like compare_op, compare_func, bound. Code length is concise; no unnecessary abstractions or verbose logic. Each action is separated logically: validation check, error message construction, exception raise. Reading flow is natural: imports, class definition, method logic follows Python conventions. The docstring explains the design choice of using a callable class. Minor deductions for the slightly terse variable name 'ins' (unused parameter) and msg2 numbering suggesting possible refactoring history, but overall readability is excellent.

Run 1

Code Structure: Imports and a small validator class are logically organized, though several imports appear unused in this snippet. Nesting: Only a single conditional keeps execution easy to follow. Clarity of intent: The class name, comparison fields, and error message clearly convey numeric-bound validation; abbreviated parameters and the name msg2 slightly reduce clarity. Code length: The implementation is concise, with little unnecessary code beyond the unused imports. Action granularity: Each statement performs one action, with no compressed multi-statement lines. Reading flow: Attribute declarations, validation logic, and representation follow a natural order. The docstring explains the callable-class design rather than the method's validation behavior, and an extra blank line before the decorator would improve visual separation.

Run 2

Code Structure: Imports, class attributes, and methods are logically organized, though several imports are unused in this snippet. Nesting: Very shallow, with only one conditional inside a method. Clarity of intent: The comparison and error handling clearly implement a numeric-bound validator, but abbreviated parameters (ins, att, val), the vague name msg2, and a docstring focused on implementation rather than behavior reduce clarity. Code length: Compact and appropriately sized, aside from unused imports. Action granularity: Each statement performs one clear action. Reading flow: Attributes precede validation and representation methods in a natural order; additional spacing between imports and the class would improve visual separation.

Run 3

Code Structure: Imports and a small validator class are logically organized, although several imports are unused in this snippet. Nesting: Methods are flat, with only one conditional. Clarity of intent: Class and attribute names clearly communicate numeric-bound validation, and the error message is informative. However, abbreviated parameters (ins, att, val), the name msg2, and a docstring focused on representation rather than validation slightly obscure intent. Code length: The implementation is concise, though the unused imports add clutter. Action granularity: Each statement performs one clear action, with no compressed multi-action lines. Reading flow: Attributes, validation behavior, and representation follow a natural sequence; additional spacing between imports and the class would improve visual separation.