Sample

pyint-9a611e086c38-I08

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

Matched original source

Lines26

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7470–1; higher is more readable
Mi0.4840–1; higher is more readable
LLOC21Logical lines; fewer is more readable
DeepSeek V4 Pro11.330–20; mean of three runs
GPT-6.1 Sol13.330–20; mean of three runs
BTTF0.5290–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 _OptionalValidator: validator = attrib() def __call__(self, inst, attr, value): morning_temperature = 18 evening_temperature = 14 lower_temperature = morning_temperature if evening_temperature < lower_temperature: lower_temperature = evening_temperature if value is None: return self.validator(inst, attr, value) def __repr__(self): return f"<optional validator for {self.validator!r} or None>"

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.661.251−21.821
Source linesThe number of non-empty source lines.26+10.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.422−6.632

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
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.68.926+0.746
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.051+0.445
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.26+0.162
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.25.886−0.048

Intercept 0.07 + feature contributions = 1.084 (log-odds).
Score = sigmoid(1.084) = 0.747.

Score0.484
Score21
Run 1

The code has some issues. The overall structure is mostly clear with a single class, but it includes a nonsensical block of code inside __call__ that calculates a lower temperature: this is unrelated to validation, making the intent confusing. The class naming and docstring are good, but the deep nesting is minimal (two ifs in __call__) yet still unnecessary. There are two actions per line in the temperature block, violating one action per line. Reading flow is disrupted by the unrelated temperature logic. Imports are mostly clear, but some may be unused. Concise portion we can praise is the class definition. Overall, logic clarity suffers due to the irrelevant temperature code that doesn't belong inside the validator method.

Run 2

The code is generally readable but has notable issues. The overall structure is logical, with imports organized and a single class definition. Nesting is mostly flat. However, clarity of intent suffers because the class contains unrelated temperature comparison code (morning_temperature, evening_temperature, lower_temperature) that appears copied from elsewhere and does nothing—it neither affects logic nor relates to the validator's purpose. Code length is slightly inflated due to this dead code, which could confuse readers. Action granularity is acceptable—each line does one thing, though the dead code lines break flow. Reading flow starts well with imports and class definition but is disrupted by the meaningless temperature block inside __call__. The __repr__ is clear and concise. Removing the dead code and adding a brief docstring would improve readability to around 16-17. Overall, the code is understandable for an experienced developer but has a confusing segment that lowers its score.

Run 3

The code is mostly readable but contains an unexplained and irrelevant block of logic. Structure is logical, nesting is minimal, and intent for the validator is clear. However, the temperature variables (morning_temperature, evening_temperature, lower_temperature) are unrelated to the function's purpose, creating ambiguity and harming reading flow. The function could be more concise by removing this dead code. Action granularity is generally one action per line, but the temperature block adds unnecessary length. Clarity suffers due to the misleading code block.

Run 1

1. Code Structure: Imports and a small class provide logical organization, but unrelated temperature calculations disrupt the validator method. 2. Nesting: Shallow conditionals and an early return keep nesting minimal. 3. Clarity of intent: The class name, delegation, and representation clearly describe an optional validator, but unused temperature variables introduce ambiguity. 4. Code length: The class is compact, yet several unused imports and the temperature block add unnecessary length. 5. Action granularity: Each statement performs one action, making individual lines easy to read. 6. Reading flow: The None check followed by validation is natural, but irrelevant calculations preceding it interrupt the flow.

Run 2

Code Structure: The class cleanly separates validation and representation, but unrelated temperature calculations disrupt the validator's organization. Nesting: Both conditionals are shallow and easy to follow. Clarity of intent: The class name, None check, and delegated validator call communicate optional validation clearly; unused temperature variables introduce ambiguity. Code length: The implementation is short, but the temperature block and unused imports add unnecessary length. Action granularity: Each line performs a single, straightforward action. Reading flow: The None check followed by validation provides a natural flow, but irrelevant calculations interrupt it and distract from the method's purpose.

Run 3

Code Structure: The validator class is logically organized into validation and representation methods, but unrelated temperature calculations and unused imports add clutter. Nesting: The code is mostly flat, with simple conditionals and early return. Clarity of intent: The class name, None check, and delegated validator call clearly communicate optional validation, while the temperature variables obscure that purpose. Code length: The implementation is short overall but unnecessarily extended by dead calculations and imports. Action granularity: Each line performs a single action, making individual statements easy to follow. Reading flow: Method ordering and spacing are natural, but irrelevant calculations interrupt the validation flow before the meaningful None check.