Sample

pyint-9414a97e403d-I01

Remove comments and docstrings

Matched original source

Lines21

Scores

MethodScoreScale
Posnett0.0010–1; higher is more readable
Dorn0.7110–1; higher is more readable
Mi0.5080–1; higher is more readable
LLOC16Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.6360–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 _OptionalValidator: validator = attrib() def __call__(self, inst, attr, value): if value is None: return self.validator(inst, attr, value) def __repr__(self): return f"<optional validator for {self.validator!r} or None>"

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.546.833−18.045
Source linesThe number of non-empty source lines.21+8.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.502−6.753

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.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.69+0.743
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.059+0.364
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.22+0.257
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.20.886−0.118
Indentation frequencyHow rapidly indentation changes from line to line.21−0.011

Intercept 0.07 + feature contributions = 0.899 (log-odds).
Score = sigmoid(0.899) = 0.711.

Score0.508
Score16
Run 1

The code is well-structured with clear logical organization: imports are separated from the class definition, and the class uses the attrs decorator to concisely define its single attribute. Nesting is minimal, with only one level of indentation inside the __call__ method. The intent of _OptionalValidator is immediately clear—it wraps another validator to allow None values. The code is concise but not overly compressed; each logical action (checking for None, delegating to the wrapped validator) is on its own line. Reading flow is natural: class definition, then callable logic, then string representation. The only minor drawbacks are the leading underscore in the class name (signaling private API) and the slightly terse use of attrs decorators, which may be unfamiliar to some readers, but these do not significantly hinder readability.

Run 2

This code is highly readable. It's well-structured with clear imports and class definition. Nesting is minimal with flat, straightforward logic. The intent is clear: an optional validator wrapper that skips validation for None values. Code length is concise and appropriate. Action granularity is good - each line performs a single logical action. Reading flow is natural, from imports to class definition to methods. The only minor issue is the lack of docstrings, which would enhance clarity, but the code is self-explanatory. Naming is descriptive and consistent with Python conventions.

Run 3

The code is fairly readable overall. It has a clear structure: imports are grouped logically, and the class definition is short with a single responsibility. Nesting is flat, with only one level inside the `__call__` method. Intent is mostly explicit: the class name and docstring-like repr make its purpose (optional validation) understandable. Code length is concise and actions are well-separated per line. The reading flow is mostly natural, though a few minor points reduce clarity: the `__call__` method could use a short comment explaining why `None` bypasses validation, and the use of `attrib()` and `attrs` decorator without visible context assumes familiarity with the attrs library. The import aliasing (`from re import Pattern`) is slightly redundant but harmless. Overall, it is clean and maintainable code with only minor opportunities for added clarity.

Run 1

Code Structure: Imports and a small validator class are logically organized, although several imports are unused in this snippet. Nesting: Minimal nesting and an early return keep the code flat. Clarity of intent: The class name, None check, and delegation clearly express optional validation; framework-specific decorators and abbreviated parameters require some familiarity. Code length: The implementation is concise without unnecessary logic. Action granularity: Each statement performs one clear action. Reading flow: Initialization, validation behavior, and representation follow a natural order, with whitespace separating responsibilities.

Run 2

Code Structure: The validator is logically organized into initialization metadata, validation behavior, and representation. Nesting: A single conditional with an early return keeps the code flat. Clarity of intent: The class name, delegated validation, and representation clearly express that None is permitted; abbreviated parameters and implicit decorator-generated initialization require some familiarity. Code length: The implementation is concise, but numerous unused imports add unnecessary clutter to the provided snippet. Action granularity: Each line performs one clear action. Reading flow: Imports, class declaration, and short methods follow a natural order, with whitespace separating the conditional from validation.

Run 3

Code Structure: Imports and a compact validator class are logically organized, although several imports are unused in this snippet. Nesting: Minimal nesting and an early return keep control flow flat. Clarity of intent: The class name, explicit None check, delegated validation, and descriptive repr clearly communicate optional validation; framework-specific decorators and inst/attr abbreviations require some familiarity. Code length: The implementation is concise, with no unnecessary logic, though unused imports add clutter. Action granularity: Each statement performs one clear action. Reading flow: Methods follow a natural progression from the validator attribute to invocation behavior and representation, supported by sensible whitespace.