Sample

pyint-a24480f22eab-SRC

Unmodified source class

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 Pro180–20; mean of three runs
GPT-6.1 Sol17.670–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 exceptionally readable. It has a single, clear responsibility: validating that a value exists within a set of allowed options. The class is short and flat, with only one minimal nesting level used for an explicit exception fallback. Variable names like `in_options` and `_original_options` clearly communicate their purpose. The logic is broken into distinct steps (membership test, error message construction, exception raising), preserving natural reading flow. The `TypeError` handling includes a helpful comment explaining a non-obvious edge case. The `__repr__` provides useful debugging context. Overall, the structure, granularity, and clarity are excellent, with no unnecessary complexity.

Run 2

The code is highly readable due to its clear structure, minimal nesting, and concise implementation. The class has a single responsibility, with logical attribute definitions and a straightforward __call__ method. Nesting is minimal, with only one try/except block and one conditional. Intent is evident: validate that a value is within a set of options. The code is concise without sacrificing clarity, avoiding unnecessary verbosity. Each action generally occupies its own line, and the flow is natural—attempting membership, handling errors, then validating and raising. Variable names like `in_options` and `_original_options` are descriptive. The `__repr__` method is simple and informative. Minor clarity enhancements could include comments or type hints, but overall the code is exceptionally clean.

Run 3

The code is highly readable with clear structure and purpose. It defines a single validator class with a focused responsibility. Naming is descriptive (_InValidator, options, _original_options). The __call__ method is flat with minimal nesting: a try/except and a single if statement. Error handling is explicit and the error message is informative. Each logical action is on its own line, maintaining good action granularity. The __repr__ method provides useful debugging output. The file imports only necessary modules and uses modern attrs features (slots, unsafe_hash) correctly. Minor deductions: the try/except block could be simplified, and the error message formatting is slightly verbose, but overall the code follows idiomatic Python patterns and flows naturally from top to bottom.

Run 1

Code Structure: The validator class cleanly separates configuration, validation, and representation, though several unused imports add clutter. Nesting: Shallow try/except and conditional blocks are easy to follow. Clarity of intent: Descriptive names, the membership check, and a helpful TypeError example clearly communicate the purpose; framework-specific decorators and attributes require some familiarity. Code length: The implementation is concise, although the multiline exception construction is slightly verbose. Action granularity: Each statement performs one clear action. Reading flow: Execution proceeds naturally from checking membership to handling invalid values, with __repr__ logically placed afterward.

Run 2

Code Structure: The class logically groups configuration, validation, and representation methods, though several imports are unused in this snippet. Nesting: Shallow try/except and a single conditional keep complexity low. Clarity of intent: Membership validation is clear, aided by descriptive names and the TypeError example; the distinction between options and _original_options is not explained. Code length: Concise overall, although the multiline ValueError call is somewhat verbose. Action granularity: Each statement performs one clear action. Reading flow: Execution proceeds naturally from the membership check to error handling, with whitespace separating stages. Framework-specific decorators and attribute declarations require some familiarity.

Run 3

Code Structure: The validator is logically organized into attributes, validation behavior, and 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 is explicit, with a helpful comment explaining TypeError handling; the distinction between options and _original_options is not explained. Code length: The implementation is concise, although the multiline exception construction could be shorter. Action granularity: Statements generally perform one action each, making execution easy to follow. Reading flow: Validation proceeds naturally from membership testing to failure reporting, followed by a clear representation method. Framework-specific decorators and attribute declarations require some prior knowledge.