Sample

pyint-d590e6e43a25-I01

Remove comments and docstrings

Matched original source

Lines26

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.4040–1; higher is more readable
Mi0.0670–1; higher is more readable
LLOC16Logical lines; fewer is more readable
DeepSeek V4 Pro16.670–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.5250–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 _InstanceOfValidator: type = attrib() def __call__(self, inst, attr, value): if not isinstance(value, self.type): msg = f"'{attr.name}' must be {self.type!r} (got {value!r} that is a {value.__class__!r})." raise TypeError( msg, attr, self.type, value, ) def __repr__(self): return f"<instance_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.413−6.619

Intercept 8.87 + feature contributions = -8.022 (log-odds).
Score = sigmoid(-8.022) = 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
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.102.963−0.696
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.054+0.415
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.798−0.049

Intercept 0.07 + feature contributions = -0.389 (log-odds).
Score = sigmoid(-0.389) = 0.404.

Score0.067
Score16
Run 1

The code is highly readable with clear imports, a single logical class definition, and a focused __call__ method. Structure is logical: type validation is isolated in a dedicated validator class. Nesting is minimal, with only one conditional block. Clarity of intent is strong—the validator's purpose is evident from naming and docstring-like error messages. Code length is concise; no unnecessary lines exist. Action granularity mostly follows one action per line, though the message construction combines string formatting in one line. Reading flow is natural: the __call__ method follows a validate-and-raise pattern. Minor deductions: the repr could be on one line, and the purpose of __repr__ is implicit rather than documented.

Run 2

The code is generally readable with clear structure and purpose. It follows a logical organization: imports, class definition, and method implementations. Nesting is minimal—only one conditional inside __call__ and a concise context manager import. The intent is explicit: an instance-of validator for attrs. Code length is concise, with no unnecessary verbosity. Action granularity is good, though the error message construction and raise statement could be slightly split for clarity. Reading flow is natural, from imports to validation logic. Minor deductions: the blank line after the __call__ signature is unnecessary, and the error message f-string is long, affecting readability. Overall, it’s clean and maintainable.

Run 3

The code is highly readable with clear structure and intent. It imports only necessary modules, defines a single-purpose class with a clear responsibility, and uses the attrs decorator concisely. The __call__ method has minimal nesting with a single conditional check that raises an exception, making the logic straightforward. Action granularity is good—one primary action per line in most places, though the error message construction is slightly dense. Reading flow is natural: imports, class definition, validator logic, then repr. The code avoids unnecessary length and complexity, using type hints and f-strings effectively. Minor deductions for the multi-line raise statement that could be slightly clearer and the lack of docstrings/comments explaining the validator's purpose beyond the class name.

Run 1

Code Structure: The validator class is logically organized into state, validation, and representation methods, although several imports are unused in this snippet. Nesting: A single conditional keeps nesting shallow. Clarity of intent: Descriptive class and method names, a straightforward isinstance check, and a detailed error message make the purpose clear; attrs-specific declarations require some familiarity. Code length: The implementation is concise, though unused imports and an extra blank line add clutter. Action granularity: Each statement performs one clear action, and the multiline exception construction is easy to inspect. Reading flow: The code follows a natural sequence from imports to class declaration, validation logic, and representation; the long error-message line slightly reduces scanability.

Run 2

Code Structure: Imports and a small validator class are logically organized, although several imports are unused in this snippet. Nesting: A single conditional keeps nesting shallow. Clarity of intent: The class name, isinstance check, and descriptive error message clearly communicate type validation; framework-specific decorators and abbreviated parameters require some familiarity. Code length: The implementation is concise, though unused imports, an extra blank line, and the expanded raise statement add minor clutter. Action granularity: Each statement performs one clear action. Reading flow: The sequence from configuration to validation to representation is natural and easy to follow.

Run 3

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: Class and method names, the isinstance check, and the descriptive error message clearly communicate validation behavior; framework-specific decorators and attributes require some familiarity. Code length: The implementation is concise, with minor excess whitespace and a somewhat verbose multiline exception construction. Action granularity: Each statement performs one clear action, separating message construction from raising the exception. Reading flow: The progression from configuration to validation and representation is natural, although the long error-message line slightly impedes scanning.