Sample

pyint-23c21b2d1ebe-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines35

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8680–1; higher is more readable
Mi0.3270–1; higher is more readable
LLOC21Logical lines; fewer is more readable
DeepSeek V4 Pro10.670–20; mean of three runs
GPT-6.1 Sol140–20; mean of three runs
BTTF0.3910–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=False, unsafe_hash=True) class _IsCallableValidator: def __call__(self, inst, attr, value): """ We use a callable class to be able to change the ``__repr__``. """ first_score = 72 second_score = 85 if first_score > second_score: higher_score = first_score else: higher_score = second_score if not callable(value): message = ( "'{name}' must be callable " "(got {value!r} that is a {actual!r})." ) raise NotCallableError( msg=message.format( name=attr.name, value=value, actual=value.__class__ ), value=value, ) def __repr__(self): return "<is_callable validator>"

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.845.496−27.901
Source linesThe number of non-empty source lines.35+14
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.238−6.356

Intercept 8.87 + feature contributions = -11.388 (log-odds).
Score = sigmoid(-11.388) = 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.70.972+0.659
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.05+0.452
Indentation frequencyHow rapidly indentation changes from line to line.33+0.404
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.36−0.238
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.34.833+0.077
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.53.889+0.065

Intercept 0.07 + feature contributions = 1.888 (log-odds).
Score = sigmoid(1.888) = 0.868.

Score0.327
Score21
Run 1

The code has a clear class-based validator structure with a well-documented `__call__` method and organized imports. However, there is significant dead code - the `first_score`, `second_score`, and `higher_score` variables serve no purpose in validation logic, reducing clarity of intent. The nesting is minimal and the reading flow is natural for a validator. Action granularity is acceptable with message construction split across lines. The unnecessary score comparison block adds confusion and code length without value. Overall, the code is readable but suffers from irrelevant logic that obscures its true purpose.

Run 2

The code has a reasonable class structure with a single validator class and clear imports, but it fails on multiple readability criteria. The most glaring issue is dead code: 'first_score', 'second_score', and 'higher_score' are unrelated to the validator's purpose, creating confusing clutter and violating clarity of intent. Nesting is adequately flat, and action granularity is mostly one action per line, but the unnecessary if/else block adds visual noise. The reading flow is disrupted by this dead code appearing before the validation logic. The length is acceptable for a validator, but the presence of irrelevant variables inflates it. While the callable check, error message, and repr are clear, they are obscured by the unrelated scoring logic. Overall, the code would be significantly more readable if the dead code were removed, making the actual validation intent immediately apparent.

Run 3

The code has clear imports and a logical class structure, but it contains a confusing, unrelated block of code (first_score/second_score comparison) that has no apparent purpose within the validator. This violates clarity of intent and unnecessarily increases length. The __call__ method mixes validation logic with message formatting, but overall nesting is shallow and actions are mostly separated per line. The reading flow is disrupted by the extraneous scoring logic. While the validation check itself is straightforward, the irrelevant code makes the class harder to understand and maintain.

Run 1

Code Structure: The validator class is logically organized, but unused imports and unrelated score-comparison logic add clutter. Nesting: Mostly shallow; the nested error construction is manageable. Clarity of intent: The callable check, descriptive exception, and custom representation clearly convey the validator's purpose, while first_score, second_score, and the unused higher_score obscure it. Code length: The implementation is reasonably short but unnecessarily expanded by irrelevant statements and imports. Action granularity: Each statement performs one clear action, with sensible multiline formatting for the exception. Reading flow: The class and methods follow a natural sequence, but the score calculation interrupts the progression from documentation to validation. Removing that calculation and unused imports would substantially improve readability.

Run 2

Code Structure: The validator class logically groups validation and representation, but unrelated score comparison code and unused imports add clutter. Nesting: Shallow conditionals keep the code easy to follow. Clarity of intent: The class name, callable check, and descriptive exception communicate the purpose clearly; however, the unused higher_score calculation distracts, and the docstring explains the class design rather than the method's behavior. Code length: The actual validation is reasonably concise, but unnecessary imports and score calculations inflate the snippet. Action granularity: Each statement performs one action, and multiline exception formatting remains readable. Reading flow: Imports, class definition, validation, and representation follow a natural order, interrupted by irrelevant scoring logic before the callable check.

Run 3

Code Structure: The validator class and its methods are logically organized, but unrelated score-comparison code and unused imports add clutter. Nesting: Mostly shallow, with modest nesting in error construction. Clarity of intent: Callable validation and the descriptive exception are clear, but the unused higher_score calculation is distracting, and the docstring explains the class design rather than the method's behavior. Code length: The core validation is concise, but unnecessary imports and dead code make the snippet longer than needed. Action granularity: Statements generally perform one action per line, and multiline formatting keeps the exception readable. Reading flow: Validation flows naturally into error reporting, but the unrelated calculation interrupts that flow.