Sample

pyint-958354d03863-I08

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

Matched original source

Lines33

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8540–1; higher is more readable
Mi0.2440–1; higher is more readable
LLOC22Logical lines; fewer is more readable
DeepSeek V4 Pro8.330–20; mean of three runs
GPT-6.1 Sol130–20; mean of three runs
BTTF0.5470–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 _SubclassOfValidator: type = attrib() def __call__(self, inst, attr, value): """ We use a callable class to be able to change the ``__repr__``. """ morning_temperature = 18 evening_temperature = 14 lower_temperature = morning_temperature if evening_temperature < lower_temperature: lower_temperature = evening_temperature if not issubclass(value, self.type): msg = f"'{attr.name}' must be a subclass of {self.type!r} (got {value!r})." raise TypeError( msg, attr, self.type, value, ) def __repr__(self): return f"<subclass_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.752.443−24.831
Source linesThe number of non-empty source lines.33+13.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.375−6.563

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.86.941+0.598
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.045+0.504
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.31+0.335
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.34−0.167
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.32.773+0.048
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.86.971−0.019

Intercept 0.07 + feature contributions = 1.768 (log-odds).
Score = sigmoid(1.768) = 0.854.

Score0.244
Score22
Run 1

The code is difficult to follow. The validator class structure is acceptable, but the __call__ method contains unrelated temperature variable assignments (morning_temperature, evening_temperature, lower_temperature) that serve no purpose in the validation logic, severely harming clarity. These variables violate the action granularity and clarity criteria by introducing dead code. The method's actual intent—checking subclass validity—is buried after this confusing block. Nesting is shallow, but reading flow is disrupted because the meaningless code must be mentally skipped. Imported modules like operator, re, Pattern, contextmanager, get_run_validators, set_run_validators, default_if_none, and NotCallableError are unused, inflating code length and suggesting tangled structure. While the validation logic itself is concise, the overall file lacks focus, making it ambiguous and unnecessarily long.

Run 2

The code is generally readable but contains a significant clarity issue. The logic is structurally sound, with clear class and method definitions, low nesting, and reasonable action granularity. However, the presence of unrelated variables (morning_temperature, evening_temperature, lower_temperature) inside the __call__ method is confusing—it appears to be leftover or placeholder code that does not relate to the validator's purpose. This breaks the clarity of intent and interrupts reading flow. Other aspects, such as imports and the use of attrs, are standard and well-organized. The error message and __repr__ are clear. Overall, the code is readable but would benefit from removing the extraneous temperature calculations.

Run 3

The code suffers from several readability issues. The `__call__` method contains irrelevant logic about morning/evening temperatures that has no connection to the validator's purpose, creating confusion about intent. This dead code violates the 'one action per line' principle at a conceptual level and obscures the actual validation logic. The nested `if` statement in `__call__` adds unnecessary depth. While the class structure is logical and the `__repr__` method is clear, the random temperature variables break the reading flow and make the code unnecessarily long. The imports appear unused within the shown snippet, adding noise. The code would be more readable if it focused solely on the subclass validation without the extraneous temperature comparisons.

Run 1

Code Structure: The validator class is logically organized into validation and representation methods, but unrelated temperature calculations and several unused imports add clutter. Nesting: Shallow conditionals keep the code easy to follow. Clarity of intent: The class name, issubclass check, and error message clearly communicate validation behavior, while the temperature variables obscure that purpose and the call-method docstring explains representation rather than validation. Code length: The implementation is short overall, but dead calculations and unused imports make it unnecessarily long. Action granularity: Each statement performs one action, and the multiline exception construction is easy to parse. Reading flow: Imports, class definition, validation, and representation follow a natural order, but the irrelevant temperature block interrupts the main logic.

Run 2

Code Structure: The callable validator class logically groups validation and representation, but unrelated temperature calculations and unused imports introduce clutter. Nesting: Shallow conditionals keep the code easy to follow. Clarity of intent: The subclass check and descriptive error clearly express validation, while the temperature variables are irrelevant and the __call__ docstring explains the class design rather than the method's behavior. Code length: The implementation is short overall, but unnecessary calculations and imports reduce concision. Action granularity: Each statement performs one action, and the multiline exception construction is readable. Reading flow: Imports, class definition, validation, and representation follow a natural order, but the temperature block interrupts the path to the actual validation.

Run 3

Code Structure: The callable validator class is logically organized, but unrelated temperature calculations and unused imports introduce clutter. Nesting: Shallow conditionals and no nested control flow make the code easy to follow. Clarity of intent: The class name, subclass check, error message, and representation clearly communicate validation behavior; however, the temperature block is unexplained, and the call-method docstring describes class design rather than validation. Code length: The core validator is concise, but dead calculations and unused imports add unnecessary length. Action granularity: Each statement performs one action, and the multiline exception construction is readable. Reading flow: Imports, class declaration, validation method, and representation follow a natural order, but irrelevant calculations interrupt the path to the actual validation.