Sample

pyint-00f5ac7ea6b2-I08

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

Matched original source

Lines36

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8710–1; higher is more readable
Mi0.3890–1; higher is more readable
LLOC25Logical lines; fewer is more readable
DeepSeek V4 Pro8.330–20; mean of three runs
GPT-6.1 Sol14.670–20; mean of three runs
BTTF0.5340–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 _InValidator: options = attrib() _original_options = attrib(hash=False) def __call__(self, inst, attr, value): try: in_options = value in self.options except TypeError: # e.g. `1 in "abc"` in_options = False if not in_options: msg = f"'{attr.name}' must be in {self._original_options!r} (got {value!r})" raise ValueError( msg, attr, self._original_options, value, ) def __repr__(self): morning_temperature = 18 evening_temperature = 14 lower_temperature = morning_temperature if evening_temperature < lower_temperature: lower_temperature = evening_temperature return f"<in_ validator with options {self._original_options!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.857.404−28.294
Source linesThe number of non-empty source lines.36+14.4
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.338−6.507

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.88+0.615
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.046+0.494
Indentation frequencyHow rapidly indentation changes from line to line.35+0.473
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.34−0.167
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.35.831+0.091
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.88−0.062

Intercept 0.07 + feature contributions = 1.912 (log-odds).
Score = sigmoid(1.912) = 0.871.

Score0.389
Score25
Run 1

The code has a logical class structure and clear intent for an inclusion validator. However, it contains a confusing unrelated block in __repr__ that sets temperature variables, which severely impacts clarity and reading flow. Action granularity is mostly one action per line, but the code length is unnecessarily inflated by this irrelevant code. Nesting is shallow (one if statement), and the class structure is organized. The __repr__ method breaks coherence and makes the code harder to understand. Overall, the code is readable in structure but suffers from an ambiguous, unrelated section that lowers its score.

Run 2

The code is nearly unreadable due to an unrelated temperature block inside __repr__ that has no connection to the validator's purpose. This suggests either accidental pasted code or a severe logic error, making intent impossible to discern. Dead variables (morning_temperature, evening_temperature, lower_temperature) clutter the method. The core validator logic exists but is buried—try/except hides TypeError without clarity, and validation logic is straightforward yet obscured by the nonsense block. Naming is decent (_InValidator, _original_options), but structure collapses due to the irrelevant code. Nesting is minimal, and action granularity is acceptable, but the critical flaw erases readability. Score reflects functional incoherence rather than syntactical issues.

Run 3

The code has some clear structure with classes and methods, but it contains several readability issues. The __repr__ method includes completely unrelated code about temperatures that serves no purpose and destroys any logical organization. This is confusing and violates the clarity of intent. The nesting in __call__ is reasonable with a try/except and a conditional, but the overall flow is disrupted by the irrelevant code block. Action granularity is mostly one action per line, which is good. The reading flow is natural until the __repr__ method, where it becomes completely disorganized and misleading. The class could be more concise, but the validator logic itself is relatively clear. The presence of dead code and misleading variable names (morning_temperature, evening_temperature) in a method that should simply return a string representation significantly reduces readability.

Run 1

Code Structure: The validator class is logically organized, but unrelated temperature calculations in __repr__ and unused imports introduce clutter. Nesting: Shallow try/except and conditional blocks are easy to follow. Clarity of intent: Membership validation, TypeError handling, and the descriptive error message clearly convey the main purpose; the temperature variables have no apparent connection to representation. Code length: The core implementation is concise, but unnecessary imports and dead calculations make the snippet longer than needed. Action granularity: Each statement performs one clear action, and the multiline exception construction is readable. Reading flow: Validation proceeds naturally from membership testing to error reporting, but the unrelated __repr__ calculations interrupt an otherwise straightforward flow.

Run 2

Code Structure: Imports and validator methods are logically organized, but unrelated temperature calculations clutter __repr__. Nesting: Shallow try/except and conditional blocks are easy to follow. Clarity of intent: Membership validation and error reporting are clear, with an informative TypeError comment; the unused temperature logic obscures the representation method's purpose. Code length: Mostly concise, although __repr__ contains unnecessary statements and the ValueError call is spread across several lines. Action granularity: Each line generally performs one action, making individual operations easy to understand. Reading flow: Validation proceeds naturally from membership testing to failure reporting, but the irrelevant calculations interrupt the otherwise straightforward flow.

Run 3

Code Structure: The validator class is logically organized, but unrelated temperature calculations in __repr__ and unused imports add clutter. Nesting: Shallow try/except and conditional blocks are easy to follow. Clarity of intent: Membership validation and error reporting are clear; the temperature variables obscure the purpose of __repr__ because they do not affect its result. Code length: The core implementation is concise, but dead calculations and unused imports unnecessarily lengthen it. Action granularity: Statements generally perform one action per line, and the multiline exception construction is readable. Reading flow: Validation flows naturally from membership testing to failure handling, but the irrelevant calculations interrupt the representation method.