Sample

pyint-67c9e20606c6-I11

Split eligible integer literals into pairs of short-named intermediate variables

Matched original source

Lines31

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.850–1; higher is more readable
Mi0.5730–1; higher is more readable
LLOC20Logical lines; fewer is more readable
DeepSeek V4 Pro17.670–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.5640–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): 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.373−6.559

Intercept 8.87 + feature contributions = -9.628 (log-odds).
Score = sigmoid(-9.628) = 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.05+0.454
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.88−0.062
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.31−0.061
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.30.775+0.02

Intercept 0.07 + feature contributions = 1.735 (log-odds).
Score = sigmoid(1.735) = 0.85.

Score0.573
Score20
Run 1

The code is well-structured with a single class definition containing a clear purpose. Nesting is minimal with one try-except block and an if statement. The intent is obvious: validate that a value belongs to a set of allowed options. The code is concise with no unnecessary verbosity. Action granularity is good—each logical operation is on its own line, like the try block, error message construction, and exception raising. Reading flow is natural: initialize, check membership, handle errors, raise exception if needed. The only minor deduction is the lack of type hints and a docstring, which would clarify the parameter types and the validator's contract for maintainers.

Run 2

The code is highly readable with a clear, logical structure. It uses a single class with a focused responsibility, avoiding unnecessary complexity. Nesting is minimal, with only one try/except block that handles a specific edge case concisely. Intent is explicit through descriptive naming (`_InValidator`, `_original_options`) and a clear error message. Code length is appropriate, with no redundant verbosity. Action granularity is well-balanced, with single-purpose code lines and a clean exception handling flow. Reading flow is natural, guiding the reader from validation logic to error handling, then to a concise repr. Overall, the code demonstrates strong adherence to readability best practices.

Run 3

The code is well-structured and readable. It uses clear naming conventions, follows a logical layout, and maintains flat nesting with only one try/except and one conditional. Each action is on its own line, and the flow is natural: validate membership, handle TypeError, raise if invalid, then provide a clean repr. The use of attrs decorators reduces boilerplate and clarifies class design. Minor deductions: inline comment on the except line slightly disrupts flow, and the __call__ method could benefit from a docstring to clarify intent. Overall, the code is concise, purposeful, and easy to follow.

Run 1

Code Structure: The validator is logically organized into attributes, validation behavior, and representation, although several imports appear unused in this snippet. Nesting: Shallow try/except and conditional blocks keep complexity low. Clarity of intent: Membership validation is clear, and the TypeError comment explains an important edge case; the distinction between options and _original_options is not fully explained. Code length: Compact overall, though the multiline ValueError construction is slightly verbose. Action granularity: Statements generally perform one action per line, with a clearly separated error-message assignment. Reading flow: Execution proceeds naturally from membership checking to error handling, followed by representation; the decorator and framework-specific attributes require some familiarity.

Run 2

Code Structure: The validator is logically organized into attributes, validation logic, and representation. Nesting: A shallow try/except and a single conditional keep complexity low. Clarity of intent: Descriptive names, a helpful TypeError comment, and an informative error message make membership validation clear; the decorator and attribute configuration require some framework familiarity. Code length: The implementation is concise, although several imports are unused in this snippet. Action granularity: Each statement performs one clear action, and the multiline exception construction is easy to scan. Reading flow: Execution progresses naturally from checking membership to handling invalid input, with __repr__ cleanly separated.

Run 3

Code Structure: The validator is logically organized into attributes, validation behavior, and representation, though numerous unused imports add clutter. Nesting: Shallow try/except and conditional blocks make control flow easy to follow. Clarity of intent: Descriptive names, a helpful TypeError example, and an informative error message clearly communicate membership validation; the distinction between options and _original_options is not explained. Code length: The implementation is concise, although the multiline exception construction is slightly verbose. Action granularity: Each statement performs one clear action without compressed expressions or chained operations. Reading flow: Validation proceeds naturally from checking membership to handling invalid values, followed by representation; spacing between imports and the class could be improved.