Sample

pyint-e6c6b601f20d-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines28

Scores

MethodScoreScale
Posnett0.0010–1; higher is more readable
Dorn0.8460–1; higher is more readable
Mi0.2570–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol17.330–20; mean of three runs
BTTF0.550–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, ins, att, val): """ We use a callable class to be able to change the ``__repr__``. """ if not issubclass(val, self.type): msg2 = f"'{att.name}' must be a subclass of {self.type!r} (got {val!r})." raise TypeError( msg2, att, self.type, val, ) 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.421−6.632

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.84.828+0.564
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.05+0.457
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.85+0.065
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.27.826−0.021
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.705 (log-odds).
Score = sigmoid(1.705) = 0.846.

Score0.257
Score17
Run 1

The code is structured clearly with a single class, flat nesting, and explicit purpose. Each action is on its own line, and the use of a class-based validator with a docstring and a __repr__ method makes the intent clear. The only minor deduction is for unused imports and the slightly unclear variable name 'msg2', but overall it is highly readable.

Run 2

The code is well-structured and readable. It uses clear imports, including specific modules and context managers, and defines a single-purpose class with a clear role: validating subclass relationships. The class uses the attrs library for concise definition, with slots and hash configuration clearly visible. The validation method is flat, with no deep nesting, and performs one logical check. The error message construction is clear and the raised TypeError includes helpful context. The __repr__ method is short and improves debuggability. Minor deductions arise from the short variable names (ins, att, val, msg2) which, while conventional in attrs validators, slightly reduce immediate clarity for new readers. The overall flow follows a natural order: imports, class definition, validation logic, then representation. The code is concise, with no unnecessary complexity or duplication, making it easy to understand at a glance.

Run 3

The code is generally readable with a clear class-based validator pattern. Structure is logical: imports are organized, the class is well-defined with a single responsibility, and the `__call__` method contains straightforward validation logic. Nesting is minimal—only one conditional block. Variable naming is clear except for `msg2`, which is slightly ambiguous. The code is concise without unnecessary verbosity. Action granularity is mostly one action per line, though the error message construction combines an f-string with variable assignment. Reading flow is natural: imports, class definition, validation, then representation. Minor issues: the `msg2` variable name lacks context ('what happened to msg1?'), and the `@attrs` decorator parameters are terse. Overall, this is professional, idiomatic Python that most developers would understand quickly, though small naming improvements could push it higher.

Run 1

Code Structure: Imports and a small validator class are logically organized, though several imports appear unused in this snippet. Nesting: A single conditional keeps nesting shallow. Clarity of intent: The class name, issubclass check, error message, and custom representation clearly communicate purpose; abbreviated parameters ins, att, and val and the name msg2 slightly reduce clarity. Code length: The implementation is concise, although the multiline TypeError arguments and explanatory docstring add modest verbosity. Action granularity: Each statement performs one clear action. Reading flow: The progression from class configuration to validation and representation is natural and easy to follow.

Run 2

Code Structure: Imports and a small 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, subclass check, error message, and custom representation clearly communicate the purpose; abbreviated parameters and the name 'msg2' reduce clarity slightly. 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 progression from configuration to validation to representation is natural, but the __call__ docstring explains the callable-class design rather than the method's validation behavior.

Run 3

Code Structure: The validator is logically organized into an attribute declaration, validation method, and representation method, though numerous unused imports add clutter. Nesting: A single conditional keeps nesting shallow. Clarity of intent: The class name, issubclass check, and descriptive error message make its purpose clear; abbreviated parameters and the name msg2 are less expressive. The __call__ docstring explains the callable-class design rather than the method's validation behavior. Code length: The implementation is concise, although the multiline exception construction is somewhat verbose. Action granularity: Each statement performs one clear action. Reading flow: Validation proceeds naturally from checking the value to constructing and raising an error, followed by representation logic.