Sample

pyint-19ce79017e60-I11

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

Matched original source

Lines28

Scores

MethodScoreScale
Posnett0.0010–1; higher is more readable
Dorn0.840–1; higher is more readable
Mi0.2620–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol17.670–20; mean of three runs
BTTF0.5730–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): msg = f"'{attr.name}' must be a subclass of {self.type!r} (got {value!r})." raise TypeError( msg, 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.635.312−20.965
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.411−6.617

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.86.931+0.598
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.049+0.463
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 (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.27.739−0.022
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.87−0.02
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.659 (log-odds).
Score = sigmoid(1.659) = 0.84.

Score0.262
Score17
Run 1

The code is highly readable with clear structure, minimal nesting, and concise length. It demonstrates logical organization with a single class defined using the attrs decorator. The nesting depth is shallow (one conditional within one method), maintaining an easy-to-follow flow. Intent is unambiguous — a validator ensuring a value is a subclass of a specified type. Action granularity is appropriate; the conditional check, exception raising, and repr methods each perform coherent actions. Reading flow is natural, with type hints, docstring, and f-strings improving clarity. Minor points could be made about one-line methods or slightly more descriptive parameter names, but overall it is excellent.

Run 2

The code is highly readable. It has a clear, logical structure with a single class definition following imports. Nesting is minimal. The class and method names clearly convey intent (e.g., `_SubclassOfValidator`, `__call__` with `issubclass` check). The code is concise, avoiding unnecessary verbosity. Each line performs one action (type assignment, `if` check, message creation, `raise`). Reading flow is natural: class definition, attribute, method, then helper `__repr__`. The only minor deduction is the inline `issubclass` condition, which slightly reduces granularity, but overall the code is clean and maintainable.

Run 3

The code is generally well-structured and readable. It has a clear purpose: defining a validator class. The `__call__` method includes a docstring, and the logic is straightforward with minimal nesting. The error message is descriptive, and `__repr__` is concise. However, the score is limited by some minor issues: the multi-line `raise TypeError` call spreads a single action across four lines, slightly reducing action granularity clarity. The import block is a bit dense and could be separated from the class definition. Type annotations could improve clarity of intent. The code is flat and avoids unnecessary complexity, but the exception handling could be more explicit about why four arguments are passed to `TypeError`. Overall, it’s readable but not exemplary.

Run 1

Code Structure: Imports and a single validator class are logically organized, though several imports are unused in this snippet. Nesting: A single conditional keeps nesting shallow. Clarity of intent: The class name, issubclass check, descriptive error message, and custom representation clearly convey the purpose; abbreviated parameter names and a docstring focused on implementation rather than behavior slightly reduce clarity. Code length: The implementation is concise, although the multiline exception construction is somewhat verbose. Action granularity: Each statement performs one clear action. Reading flow: The sequence from stored configuration to validation and representation is natural, with consistent indentation and helpful spacing.

Run 2

Code Structure: The validator class logically groups its configuration, validation behavior, and representation, though several unused imports add clutter. Nesting: A single conditional keeps the implementation shallow and easy to follow. Clarity of intent: The class name, issubclass check, and descriptive error message clearly communicate the purpose; however, the __call__ docstring explains the callable-class design rather than the method's behavior, and inst is unused. Code length: The implementation is concise, although the multiline exception construction is somewhat verbose. Action granularity: Each statement performs one clear action, with message creation separated from raising the exception. Reading flow: Configuration followed by validation and representation provides a natural progression; limited spacing around the top-level class slightly weakens visual organization.

Run 3

Code Structure: Imports and a small validator class are logically organized, although many imports are unused in this snippet. Nesting: Only one conditional is used, keeping control flow shallow. Clarity of intent: The class name, issubclass check, error message, and custom representation clearly communicate the purpose; the __call__ docstring explains the callable-class design rather than the method's behavior. Code length: The implementation is concise, though the multiline exception construction is slightly verbose. Action granularity: Each statement performs one clear action. Reading flow: The sequence from field declaration to validation and representation is natural, with clean formatting; attrs-specific declarations require some framework familiarity.