Sample

pyint-be063c5f97a4-I01

Remove comments and docstrings

Matched original source

Lines26

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.5680–1; higher is more readable
Mi0.240–1; higher is more readable
LLOC16Logical lines; fewer is more readable
DeepSeek V4 Pro160–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.5570–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): 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.626.468−20.673
Source linesThe number of non-empty source lines.26+10.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.408−6.612

Intercept 8.87 + feature contributions = -8.015 (log-odds).
Score = sigmoid(-8.015) = 0.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.055+0.403
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
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.26+0.116
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.25.75−0.05
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

Intercept 0.07 + feature contributions = 0.275 (log-odds).
Score = sigmoid(0.275) = 0.568.

Score0.24
Score16
Run 1

The code demonstrates strong readability through clear structure and organization. The class has a single cohesive purpose with a well-named validator class. Nesting is minimal with just one level in the conditional. The intent is immediately clear - validating subclass relationships. Code length is appropriate for the task, avoiding unnecessary verbosity. Action granularity is good, with each operation on its own logical line. Reading flow is natural, progressing from imports to class definition to method implementations. The error message construction and exception raising are clear. Minor deductions: some imports could be consolidated, and the blank line after the __call__ method signature seems unnecessary. The f-string formatting and type hints are used effectively. Overall, this is exemplary code that would be easy for any Python developer to understand and maintain.

Run 2

The code is relatively clear but has several readability issues. The class structure is simple and logical, with a single responsibility validator. However, the `__call__` method suffers from excessive blank lines and an unnecessarily verbose error-raising block. The error message construction and `raise` statement each span multiple lines, reducing the reading flow. The `issubclass` check is straightforward, but the code could be more concise and easier to scan. Action granularity is inconsistent — some lines handle one action, while the `raise` statement is split across five lines. The absence of a docstring or comments makes intent less obvious to readers unfamiliar with `attrs` validators. Overall, the code is functional and not deeply nested, but formatting choices and lack of concise expression detract from clarity and readability.

Run 3

The code is well-structured and readable. It follows a clear logical organization with a single class definition and appropriate imports. Nesting is minimal, with only one conditional inside the __call__ method. The intent is clear: validating that a value is a subclass of a given type. The code length is concise and appropriately scoped for the task. Action granularity is good—each line performs one logical action, and the error raising is cleanly separated. Reading flow is natural, with the class definition, method implementations, and repr following a logical order. Minor deductions: the blank line after the function signature in __call__ is slightly unusual, and the multi-line error message construction could be slightly simplified, but these are negligible.

Run 1

Code Structure: The validator class logically groups its configuration, validation behavior, and representation, though several imports are unused in this snippet. Nesting: A single conditional keeps nesting shallow. Clarity of intent: The class name, issubclass check, and descriptive error message clearly communicate subclass validation; abbreviated parameters and the unused inst parameter slightly reduce clarity. Code length: The implementation is concise, although the multiline exception arguments and extra blank line add minor visual overhead. Action granularity: Statements generally perform one action each, with message construction separated from raising the exception. Reading flow: Configuration, validation, and representation follow a natural order, aided by consistent formatting.

Run 2

Code Structure: The validator is logically organized into configuration, validation, and representation methods, though several imports are unused in this snippet. Nesting: A single conditional keeps the code shallow and easy to follow. Clarity of intent: The class name, issubclass check, and descriptive error message clearly communicate its purpose; framework-specific decorators and attrib() require some background knowledge. Code length: The implementation is concise, although unused imports and the expanded exception arguments add minor visual overhead. Action granularity: Each statement performs a distinct action, with message construction separated from raising the exception. Reading flow: The progression from declaring the expected type to checking a value and providing a representation is natural; the extra blank line inside __call__ slightly interrupts the flow.

Run 3

Code Structure: The validator class logically separates validation and representation, though several imports are unused in this snippet. Nesting: A single conditional keeps the implementation shallow and easy to follow. Clarity of intent: Descriptive class naming, issubclass, and a precise error message clearly convey the purpose; attrs-generated initialization requires some library familiarity. Code length: The implementation is concise, although unused imports and the expanded exception arguments add minor visual overhead. Action granularity: Each statement performs one clear action, with message construction separated from raising the exception. Reading flow: Imports, class declaration, validation, and representation follow a natural order; the extra blank line inside __call__ slightly interrupts the flow.