Sample

pyint-d9e69932261e-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines31

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8480–1; higher is more readable
Mi0.5210–1; higher is more readable
LLOC19Logical lines; fewer is more readable
DeepSeek V4 Pro16.670–20; mean of three runs
GPT-6.1 Sol17.330–20; mean of three runs
BTTF0.5580–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: raise ValueError( (f"'{attr.name}' must be in {self._original_options!r} (got {value!r})"), attr, self._original_options, value, ) def __repr__(self): 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.728.451−24.039
Source linesThe number of non-empty source lines.31+12.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.373−6.559

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.89+0.632
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.052+0.433
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.30+0.301
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.89−0.104
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.30−0.026
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.30.7+0.019

Intercept 0.07 + feature contributions = 1.722 (log-odds).
Score = sigmoid(1.722) = 0.848.

Score0.521
Score19
Run 1

The code is generally readable with clear structure and intent. The class has a single responsibility (validating membership in options), and method names are descriptive. Nesting is minimal (one try/except block), and action granularity is appropriate—each line performs one logical operation. The f-strings used for error messages and __repr__ are clear and informative. However, readability could be improved by removing the blank line before the raise statement, and the use of `_original_options` alongside `options` creates slight ambiguity about why both exist. The `__call__` signature is straightforward, but the TypeError comment is helpful though terse. Overall, it's concise, well-organized, and easy to follow.

Run 2

The code is generally clear and well-structured. It defines a single-purpose validator class with a focused responsibility, keeping the logic simple and readable. Nesting is minimal, with only one exception-handling block and a single conditional, making the flow easy to follow. Intent is clear from the class name and method implementation—the validator checks membership and raises a meaningful error if invalid. The code is concise but includes a confusing blank line before the `raise` statement, slightly disrupting flow. Action granularity is appropriate; most lines perform one logical action. However, the constructor and `__call__` could be marginally clearer with a docstring or type hints. Overall, it is very readable and maintainable.

Run 3

The code is highly readable with clear logical organization, minimal nesting, and consistent action granularity. It follows a straightforward validator pattern with an __init__-like attribute declaration, a single public method, and a clean __repr__. The try/except handles a specific edge case (TypeError from `in` with incompatible types) without adding nesting complexity. Variable names are descriptive, and error messages are informative with proper f-string formatting. The blank line after the conditional is a minor style inconsistency but does not detract from clarity. Overall, this is well-structured, concise, and easy to follow.

Run 1

Code Structure: The validator class is logically organized, with attributes, validation behavior, and representation clearly separated. Nesting: Shallow try/except and conditional blocks keep complexity low. Clarity of intent: Descriptive names and the TypeError example make the membership check and failure handling easy to understand, although attrs-specific declarations require framework knowledge. Code length: The implementation is concise, but several imports are unused in the provided snippet, and the error-message expression has unnecessary parentheses. Action granularity: Each statement performs a single clear action; the multiline exception construction is easy to scan. Reading flow: Validation proceeds naturally from checking membership to handling invalid input, followed by representation. An extra whitespace-only line slightly disrupts formatting.

Run 2

Code Structure: The validator class is logically organized, separating validation from representation, though several imports are unused in this snippet. Nesting: Shallow try/except and a single conditional keep complexity low. Clarity of intent: Membership validation and its error behavior are clear, with descriptive names and a helpful TypeError example; the distinction between options and _original_options is not explained. Code length: Concise overall, with minor clutter from unused imports, redundant parentheses around the error message, and an extra blank line. Action granularity: Each statement performs one action, and the multiline exception arguments are easy to scan. Reading flow: Execution proceeds naturally from membership checking to failure reporting, followed by representation.

Run 3

Code Structure: Imports, class attributes, validation logic, and representation are logically organized, though several imports are unused in this snippet. Nesting: Shallow try/except and a single conditional keep the code easy to follow. Clarity of intent: Membership validation is clear, supported by descriptive names and a helpful TypeError example; the distinction between options and _original_options is not explained. Code length: The implementation is concise, with minor clutter from unused imports, redundant parentheses around the error message, and an extra blank line. Action granularity: Each statement performs one clear action, and the multiline exception construction is readable. Reading flow: The progression from membership check to failure reporting is natural, followed by a straightforward representation method.