Sample

pyint-7690a341d6d8-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines33

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8520–1; higher is more readable
Mi0.690–1; higher is more readable
LLOC21Logical lines; fewer is more readable
DeepSeek V4 Pro140–20; mean of three runs
GPT-6.1 Sol13.670–20; mean of three runs
BTTF0.5520–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 (not in_options): pass else: 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): 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.779.111−25.711
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.334−6.501

Intercept 8.87 + feature contributions = -10.142 (log-odds).
Score = sigmoid(-10.142) = 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.051+0.442
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.32+0.37
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.33−0.132
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
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.32.809+0.049

Intercept 0.07 + feature contributions = 1.749 (log-odds).
Score = sigmoid(1.749) = 0.852.

Score0.69
Score21
Run 1

The code is moderately readable but has some unnecessary complexity. Structure is logical with clear separation of validator class components, but the `__call__` method contains an awkward conditional: `if not (not in_options): pass else: ...` is a double negative that should be `if in_options: pass else: ...` or better yet `if not in_options: ...`. The error handling for TypeError is good practice. Variable naming is mostly clear, though `_original_options` vs `options` distinction could be confusing without context. The code is relatively flat with minimal nesting (try/except plus one conditional). Action granularity is good with single-purpose lines. Length is concise. Import of `Pattern` appears unused, suggesting dead code. The `__repr__` is clear. The boolean logic is unnecessarily convoluted, which hurts clarity of intent. Overall, the validator pattern is understandable but the double-negative conditional and unused imports reduce readability.

Run 2

The code is generally well-structured with a clear class definition and logical attribute setup. The nesting is minimal, which is good. However, the conditional logic in `__call__` is unnecessarily convoluted: `if not (not in_options): pass else: raise...` obscures intent and should simply be `if not in_options: raise...`. Action granularity is mixed—most lines perform one action, but some, like the conditional and message construction, could be clearer. Reading flow is somewhat natural but interrupted by that awkward conditional. The use of type hints or docstrings would improve clarity. Overall, the code is understandable but has notable readability issues that prevent it from being highly readable.

Run 3

The code is generally readable but has some awkward constructs. The structure is logical with clear class definition and method organization. The `if not (not in_options)` is unnecessarily convoluted; using `if not in_options` would be simpler and clearer. The `else` clause with a pass statement is redundant and adds noise - simply removing the `else` would improve readability. The nested try/except is appropriate and shallow. Variable naming is clear (`in_options`, `_original_options`). The code is concise and mostly follows one-action-per-line. The reading flow is mostly natural, though the double negative in the condition interrupts the reader. The error handling and message formatting are straightforward. The code would benefit from flattening the if/else structure and removing redundancy, which would improve clarity and readability. Overall, it's serviceable but has avoidable complexity in the condition check and control flow.

Run 1

Code Structure: The class logically groups its fields, validation behavior, and representation, although several imports are unused in this snippet. Nesting: Mostly shallow, but the conditional adds unnecessary branching. Clarity of intent: Membership validation and its error message are clear; however, `if not (not in_options): pass` obscures a simple failure check that could be written as `if not in_options`. Code length: Generally concise, with avoidable lines from the empty success branch and unused imports. Action granularity: Statements perform one action each, and the multiline exception construction is easy to scan. Reading flow: Setup, membership testing, and error reporting follow a natural sequence, but the double negation and no-op branch interrupt it.

Run 2

Code Structure: The validator is logically organized into attributes, validation, and representation methods, but numerous unused imports add clutter. Nesting: Mostly shallow, although the empty success branch and else block introduce unnecessary branching. Clarity of intent: Membership validation and TypeError handling are clear, but 'if not (not in_options)' obscures a straightforward condition. Code length: Fairly concise, yet unused imports, the pass branch, and double negation are unnecessary. Action granularity: Statements generally perform one action per line, and the multiline exception arguments are easy to scan. Reading flow: Validation proceeds naturally from membership testing to error reporting, but the inverted conditional interrupts that flow; 'if not in_options: raise ...' would be simpler.

Run 3

Code Structure: The class is logically organized into attributes, validation, and representation, but unused imports add clutter. Nesting: Nesting is shallow overall, though the empty success branch and else block introduce unnecessary structure. Clarity of intent: Membership validation and the error message are clear, but `if not (not in_options)` obscures a simple condition; `if not in_options` would express the failure case directly. Code length: The implementation is fairly concise, but redundant branching and unused imports make it longer than necessary. Action granularity: Each statement performs a single action, and the multiline exception construction is easy to scan. Reading flow: The membership check, TypeError handling, and validation error follow a natural sequence, but the double negation and pass interrupt that flow.