Sample

pyint-555cb46774cb-SRC

Unmodified source class

Lines25

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8390–1; higher is more readable
Mi0.3180–1; higher is more readable
LLOC19Logical lines; fewer is more readable
DeepSeek V4 Pro16.670–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.560–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, inst, attr, value): """ We use a callable class to be able to change the ``__repr__``. """ if not self.compare_func(value, self.bound): msg = f"'{attr.name}' must be {self.compare_op} {self.bound}: {value}" raise ValueError(msg) 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.578−6.867

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.78.731+0.466
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.055+0.41
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.81.923+0.195
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.771−0.064
Indentation frequencyHow rapidly indentation changes from line to line.23+0.058

Intercept 0.07 + feature contributions = 1.65 (log-odds).
Score = sigmoid(1.65) = 0.839.

Score0.318
Score19
Run 1

The code is generally readable. It has a clear structure with a single class definition and logical imports. Nesting is minimal, with only one conditional inside the __call__ method. The intent is clear: a validator that compares values. The __repr__ method provides helpful context. However, the class name is somewhat generic (_NumberValidator), and the attribute names like compare_op and compare_func could be slightly more descriptive (e.g., comparison_operator, comparison_function). The docstring is brief but helpful. Overall, it is concise and follows a natural flow.

Run 2

The code is generally well-structured and readable. It uses clear imports, a frozen attrs class for immutability, and a single-purpose callable validator. The __call__ method has a clear validation flow with a concise error message. However, readability is slightly reduced by the comparison logic being split across two attributes (compare_op for display, compare_func for logic) without explanation, and the __repr__ uses a hardcoded variable name 'x' that may be misleading. The class is short and flat, with minimal nesting, and each action is on its own line. The docstring clarifies the rationale for using a callable class, which aids intent. Overall, it is readable but could benefit from a brief comment or renaming to clarify the relationship between compare_op and compare_func.

Run 3

The code is highly readable. It is well-structured with clear separation of imports and a single class definition. Nesting is minimal (one level in __call__). Intent is explicit: a reusable number validator with clean error messaging and a custom repr. The code is concise and focused, with no unnecessary length. Action granularity is appropriate; each line performs one logical step. Reading flow is natural, from imports to class definition to methods. Minor deductions could be for slight ambiguity in variable names like 'inst' and 'attr' (common in attrs patterns but less self-documenting), and the import of Pattern/re/operator appear unused, which introduces a minor readability distraction.

Run 1

Code Structure: Imports and a small validator class are logically organized, though several imports are unused in this snippet. Nesting: Minimal nesting, with just one conditional inside __call__. Clarity of intent: Descriptive attribute names, the error message, and __repr__ clearly communicate numeric-bound validation; the docstring explains the callable-class design rather than the method's validation behavior. Code length: Concise, with little unnecessary implementation code, although unused imports add clutter. Action granularity: Each line performs a single clear action. Reading flow: The progression from configuration fields to validation and representation is natural; an additional blank line before the class would improve visual separation.

Run 2

Code Structure: Imports and a small validator class are logically organized, though several imports are unused in this snippet. Nesting: Methods are flat, with only one conditional level. Clarity of intent: Descriptive names, the comparison check, and informative error message clearly express numeric-bound validation; the docstring explains the callable-class design rather than the method's behavior. Code length: The implementation is concise, with little unnecessary code beyond unused imports. Action granularity: Each statement performs one clear action, and error construction is separated from raising it. Reading flow: Fields, validation behavior, and representation follow a natural order, although an extra blank line before the class would improve visual separation.

Run 3

Code Structure: The validator is logically organized into attributes, validation behavior, and representation methods, although several imports are unused in this snippet. Nesting: A single conditional keeps control flow shallow and easy to follow. Clarity of intent: Descriptive names and informative error messages clearly communicate numeric-bound validation; the docstring explains the callable-class design rather than the validation behavior. Code length: The implementation is concise without unnecessary logic. Action granularity: Each statement performs one clear action, with message construction separated from raising the exception. Reading flow: The progression from configuration to validation to representation is natural, though additional spacing between imports and the class would improve visual separation.