Sample

pyint-bf36b7a4506a-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines31

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8550–1; higher is more readable
Mi0.6330–1; higher is more readable
LLOC20Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol16.670–20; mean of three runs
BTTF0.5330–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, ins, att, val): try: in2 = val in self.options except TypeError: # e.g. `1 in "abc"` in2 = False if not in2: msg2 = f"'{att.name}' must be in {self._original_options!r} (got {val!r})" raise ValueError( msg2, att, self._original_options, val, ) 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.737.534−24.339
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.386−6.579

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.86+0.583
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.052+0.437
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
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.31−0.061
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+0.023
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.30.759+0.02

Intercept 0.07 + feature contributions = 1.77 (log-odds).
Score = sigmoid(1.77) = 0.855.

Score0.633
Score20
Run 1

The code demonstrates clear structure and intent. The single class with two attributes and three methods is logically organized. Nesting is minimal — only one try/except block. Variable names are descriptive; `msg2` and `in2` are slightly odd but understandable in context. The code is concise with each method performing a focused task. Action granularity is good: one meaningful operation per line, except for the multi-line `raise ValueError` which is formatted for readability. Reading flow is natural — validation logic reads top-down, errors are raised explicitly, and the `__repr__` communicates the validator state clearly. Minor deductions: `msg2` could be renamed to `message`, and the boolean variable `in2` would be clearer as `is_in`. Overall highly readable.

Run 2

The code is well-structured and readable. It has a clear class definition with a focused purpose—validating membership. The __call__ method is flat with minimal nesting (one try/except and one conditional), making the logic easy to follow. Naming is explicit and descriptive (_InValidator, _original_options, ins, att, val). The error message is clear and informative. Action granularity is appropriate—each significant step is on its own line. The exception handling is concise and handles only the specific TypeError scenario. Imports are organized, though a few imports (operator, re, Pattern, and_, etc.) appear unused in this snippet, which slightly reduces clarity. Overall, the code is concise, intention-revealing, and follows Pythonic conventions.

Run 3

The code is generally readable with clear structure, minimal nesting, and a reasonable level of conciseness. It imports only what is needed, and the class name and method names are descriptive. The `__call__` method follows a logical flow, and the error handling is explicit. However, a few minor issues slightly reduce readability: the variable names `ins`, `att`, and `val` are terse and could be more descriptive (e.g., `instance`, `attribute`, `value`). The `try/except` is flat, but the comment inside the except helps explain intent. The `__repr__` is clear. Overall, the code is easy to follow, with good action granularity and a natural reading flow. The brevity of the code is a plus, but the abbreviated parameter names are the main drawback.

Run 1

Code Structure: The validator is logically organized into attributes, validation logic, and representation, although several imports are unused in this snippet. Nesting: Shallow try/except and conditional blocks keep control flow easy to follow. Clarity of intent: Membership validation and the informative error message make the purpose clear, but names such as in2, msg2, ins, and att are less descriptive. Code length: The implementation is concise, though the multiline ValueError construction is somewhat verbose. Action granularity: Each statement performs one clear action, with no compressed or compound operations. Reading flow: Execution proceeds naturally from membership testing to error handling, followed by representation; the TypeError comment usefully explains an edge case.

Run 2

Code Structure: The validator class logically groups its state, validation behavior, and representation, although numerous unused imports clutter the snippet. Nesting: Shallow try/except and a single conditional make control flow easy to follow. Clarity of intent: Membership validation and the informative error message clearly convey the purpose, but names such as in2, msg2, ins, and att are less descriptive, and the distinction between options and _original_options is unexplained. Code length: The implementation is concise; the multiline exception construction is slightly verbose but readable. Action granularity: Each statement performs one action, with no compressed or compound lines. Reading flow: Validation proceeds naturally from membership testing to error handling, followed by representation; the TypeError comment helps explain an edge case.

Run 3

Code Structure: The validator is logically organized into attributes, validation, and representation, though many imports are unused in this snippet. Nesting: Shallow try/except and a single conditional make control flow easy to follow. Clarity of intent: Membership validation and error handling are clear, but names such as in2, msg2, ins, att, and val are less descriptive, and the distinction between options and _original_options is unexplained. Code length: The implementation is concise; the multiline exception construction is slightly verbose but readable. Action granularity: Statements generally perform one action per line. Reading flow: Validation proceeds naturally from membership testing to failure reporting, followed by representation; unfamiliar attrs decorators and attribute configuration add some cognitive overhead.