Sample

pyint-954ed110648b-I03

Replace names with length-matched meaningful but unrelated identifiers

Matched original source

Lines28

Scores

MethodScoreScale
Posnett0.0010–1; higher is more readable
Dorn0.840–1; higher is more readable
Mi0.2640–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro160–20; mean of three runs
GPT-6.1 Sol15.330–20; mean of three runs
BTTF0.5040–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, flag, item, batch): """ We use a callable class to be able to change the ``__repr__``. """ if not issubclass(batch, self.type): age = f"'{item.name}' must be a subclass of {self.type!r} (got {batch!r})." raise TypeError( age, item, self.type, batch, ) 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.423−6.634

Intercept 8.87 + feature contributions = -7.529 (log-odds).
Score = sigmoid(-7.529) = 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.264
Score17
Run 1

The code is generally well-structured and readable. It uses clear naming and logical organization, with a single class encapsulating validator behavior. Nesting is minimal, and each line performs one action, contributing to good action granularity. The intent is mostly clear, though the variable name 'age' for an error message is ambiguous and likely a typo for 'msg' or 'message'. The use of a docstring and repr method aids clarity. The code is concise and avoids unnecessary length. Overall, readability is high; the main deduction is due to the unclear variable name and the slightly unconventional multi-line TypeError arguments, which slightly disrupt reading flow.

Run 2

The code is mostly readable with clear intent and logical structure. The class has a single responsibility and uses attrs decorators to reduce boilerplate. Nesting is minimal, with only one conditional block. Action granularity is reasonable, though the error-raising block could be slightly more concise. The variable name 'age' is misleading, which harms clarity. Imports are organized cleanly. The docstring is helpful but brief. The __repr__ method is straightforward. Overall, the code is readable but could be improved with better variable naming and minor simplification of the exception-raising section.

Run 3

The code is generally well-structured and readable. It uses a single class with clear attributes and a focused __call__ method. Nesting is minimal, and the intent is straightforward: validate that a given object is a subclass of a specified type. The __repr__ method improves debuggability. However, there are some clarity issues: the variable name 'age' is misleading and unrelated to its content (an error message), which hurts readability. The __call__ method handles multiple actions (validation, message construction, raising) in a few lines, but each is reasonably distinct. The reading flow is natural, though the error message construction could be extracted for clarity. Overall, the code is concise and maintainable with minor naming improvements needed.

Run 1

Code Structure: The validator is logically organized into a field, validation method, and representation method, but numerous unused imports add clutter. Nesting: A single conditional keeps the code shallow and easy to follow. Clarity of intent: The class name, issubclass check, and error message clearly communicate validation, while names such as flag, item, batch, and especially age obscure parameter roles and the error-message variable. The __call__ docstring explains the callable-class design rather than the method's behavior. Code length: The implementation is short, although unused imports and the expanded exception construction make it longer than necessary. Action granularity: Statements generally perform one action each, with error-message creation separated from raising the exception. Reading flow: The progression from declaration to validation to representation is natural, but misleading names and irrelevant imports interrupt comprehension.

Run 2

Code Structure: Imports and a small validator class are logically organized, but numerous unused imports add clutter. Nesting: Shallow nesting makes the validation path easy to follow. Clarity of intent: The class name, issubclass check, and error message clearly communicate subclass validation; however, flag, item, batch, and especially age are misleading or vague names, and the docstring explains implementation rather than behavior. Code length: The class is concise, though the unused imports and expanded exception arguments add unnecessary length. Action granularity: Each statement performs a single action, with no compressed multi-action lines. Reading flow: Construction, validation, and representation follow a natural sequence, but unfamiliar attrs helpers and inconsistent naming slightly interrupt comprehension.

Run 3

Code Structure: The validator class is logically organized into its attribute, 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 error message clearly convey subclass validation, but parameter names such as flag and batch, and the error-message variable age, are misleading. The docstring explains the callable-class design rather than the method's behavior. Code length: The implementation is compact, although unused imports and the expanded exception call add unnecessary length. Action granularity: Each statement performs one clear action. Reading flow: The progression from configuration to validation to representation is natural, but inconsistent naming and import clutter interrupt comprehension.