Sample

pyint-07a38e1f22c4-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines28

Scores

MethodScoreScale
Posnett0.0010–1; higher is more readable
Dorn0.8340–1; higher is more readable
Mi0.5530–1; higher is more readable
LLOC16Logical lines; fewer is more readable
DeepSeek V4 Pro16.670–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.6290–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 _SubclassOfValidator: type = attrib() def __call__(self, inst, attr, value): """ We use a callable class to be able to change the ``__repr__``. """ if not issubclass(value, self.type): raise TypeError( (f"'{attr.name}' must be a subclass of {self.type!r} (got {value!r})."), attr, self.type, value, ) def __repr__(self): return f"<subclass_of validator for type {self.type!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.626.468−20.673
Source linesThe number of non-empty source lines.28+11.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.41−6.614

Intercept 8.87 + feature contributions = -7.218 (log-odds).
Score = sigmoid(-7.218) = 0.001.

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.052+0.44
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.26+0.162
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.27.742−0.022
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.29+0.01

Intercept 0.07 + feature contributions = 1.611 (log-odds).
Score = sigmoid(1.611) = 0.834.

Score0.553
Score16
Run 1

The code is highly readable due to its clear structure, flat nesting, and concise implementation. It follows a logical organization with imports, class definition, and methods in a natural order. The single-level nesting in __call__ keeps the logic straightforward, and the use of a docstring clarifies intent. The __repr__ method is concise and informative. Minor deductions arise from the slightly verbose error message formatting that could be split for readability and the unused imports (operator, re, Pattern, contextmanager, and get_run_validators) that add noise without affecting function. Overall, the code is well-structured and easy to understand.

Run 2

The code is generally readable with clear structure and intent. It uses a class as a validator, imports are organized, and the __call__ method has a straightforward flow. Nesting is minimal, and action granularity is reasonable. However, there is an unnecessary blank line before the raise statement, and the TypeError arguments could be slightly clearer. The docstring is helpful but concise. The code length is appropriate, and the reading flow is natural. Overall, it is fairly readable but could benefit from minor formatting cleanup and slightly more explicit error handling context.

Run 3

The code is well-structured and readable. Import organization is clean, with standard library, third-party, and local imports grouped logically. The class definition is concise with appropriate use of the `attrs` decorator for boilerplate reduction. The `__call__` method has a clear single responsibility: validating subclass relationships. Nesting is minimal—only one conditional with an early raise, maintaining flat structure. The error message is informative and readable, though the multi-line f-string with tuple arguments could be slightly flattened. Action granularity is appropriate, with one logical action per line except for the raise statement which bundles several related values. The docstring succinctly explains the design choice of using a callable class. The `__repr__` method is clear and returns a descriptive string. Minor deductions are for the unnecessary blank line before the raise and the slightly dense error message construction, but overall this is well-crafted, maintainable code with clear intent.

Run 1

Code Structure: The validator is logically organized into initialization metadata, validation behavior, and representation, though several imports are unused in this snippet. Nesting: Minimal nesting makes the control flow easy to follow. Clarity of intent: The class name, issubclass check, and descriptive error clearly communicate its purpose; however, the call-method docstring explains representation customization rather than validation, and abbreviated parameters slightly reduce clarity. Code length: The implementation is concise, with minor unnecessary parentheses and whitespace. Action granularity: Each statement performs a single clear action, and the multiline exception arguments remain readable. Reading flow: The sequence is natural and straightforward, but the blank line before raise and limited separation around top-level definitions slightly weaken formatting consistency.

Run 2

Code Structure: Imports and a small validator class are logically organized, though several imports are unused in this snippet. Nesting: Shallow nesting makes control flow easy to follow. Clarity of intent: Class and method names clearly convey subclass validation, and the error message is informative; however, the __call__ docstring explains the callable-class design rather than the method's validation behavior. Code length: The implementation is concise, with minor clutter from an unnecessary blank line and redundant parentheses around the f-string. Action granularity: Each statement performs one clear action, and the exception arguments are neatly separated. Reading flow: The progression from configuration to validation to representation is natural, although framework-specific decorators and attrib() require some background knowledge.

Run 3

Code Structure: The validator is logically organized into an attribute, validation method, and representation method, though several unused imports add clutter. Nesting: Only one conditional level keeps the code easy to follow. Clarity of intent: The class name, issubclass check, and descriptive error make its purpose clear; however, the __call__ docstring explains the callable-class design rather than validation behavior. Code length: The implementation is concise, with minor unnecessary parentheses and a stray blank line. Action granularity: Each statement performs one clear action, and the multiline exception arguments are readable. Reading flow: The progression from configuration to validation to representation is natural, slightly disrupted by excess imports and inconsistent whitespace.