Sample

pyint-ecbea86cc1eb-I01

Remove comments and docstrings

Matched original source

Lines21

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.540–1; higher is more readable
Mi0.2470–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.6070–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, frozen=True, slots=True) class _MinLengthValidator: min_length = attrib() def __call__(self, inst, attr, value): if len(value) < self.min_length: msg = f"Length of '{attr.name}' must be >= {self.min_length}: {len(value)}" raise ValueError(msg) def __repr__(self): return f"<min_len validator for {self.min_length}>"

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.570.029−18.811
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.607−6.911

Intercept 8.87 + feature contributions = -8.452 (log-odds).
Score = sigmoid(-8.452) = 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
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.057+0.39
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.784−0.119
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
Indentation frequencyHow rapidly indentation changes from line to line.21−0.011

Intercept 0.07 + feature contributions = 0.162 (log-odds).
Score = sigmoid(0.162) = 0.54.

Score0.247
Score16
Run 1

The code is generally readable with clear structure and intent. It starts with organized imports, though some unused imports (operator, re, Pattern, contextmanager, get_run_validators, set_run_validators, _AndValidator, and_, default_if_none, NotCallableError) reduce clarity. The class definition uses a clean decorator pattern, and the validator method has a logical flow: check condition, raise error with informative message. Nesting is minimal with only one conditional block. Action granularity is good—each line performs one operation. The __repr__ method provides helpful debugging output. Minor improvements could include removing unused imports and possibly breaking the long f-string in the error message across multiple lines for better readability. The empty line after the method signature is slightly unusual but not problematic. Overall, the code follows Python best practices and is easy to understand.

Run 2

The code is highly readable due to its clear structure, minimal nesting, and concise implementation. The class definition is logical, with a single method that performs one validation action. Naming is explicit (_MinLengthValidator, min_length) and intent is unambiguous. The use of f-strings makes the error message clear. Type hints are absent but acceptable given the context of attrs. The import block is slightly redundant (import re and from re import Pattern), and one blank line after the method signature is unnecessary, but these are minor issues. Overall, the code follows good practices and is easy to understand.

Run 3

The code is highly readable with clear structure, minimal nesting, and strong intent. It organizes imports logically, separates concerns cleanly via decorators, and defines a focused validator class. The `__call__` method performs a single check with straightforward error messaging, and `__repr__` is concise. Flat flow and single-action lines improve scannability. Minor points: a trailing blank line inside the method is unnecessary, and the imports include unused names (`operator`, `re`, `Pattern`, `set_run_validators`, etc.), suggesting incomplete context.

Run 1

Code Structure: Imports and a small validator class are logically organized, though several imports are unused in this snippet. Nesting: Only one conditional level keeps the code easy to follow. Clarity of intent: Descriptive class and field names, a direct length check, and an informative error message make the purpose clear; abbreviated parameters and framework-specific decorators require some familiarity. Code length: The implementation is concise, with only minor unnecessary whitespace and imports. Action granularity: Each statement performs one clear action, and separating message construction from raising the exception improves readability. Reading flow: Configuration, validation behavior, and representation appear in a natural order, although an additional blank line before the class would improve formatting.

Run 2

Code Structure: Imports and a focused validator class are logically organized, though several imports are unused in this snippet. Nesting: Only one conditional inside a method keeps nesting shallow. Clarity of intent: Descriptive class and attribute names, a straightforward length check, and a helpful error message make the purpose clear; unused inst and abbreviated attr parameters are minor distractions. Code length: The implementation is concise, with only a stray blank line and unnecessary imports adding clutter. Action granularity: Each statement performs one clear action, and message construction is separated from raising the exception. Reading flow: The progression from configuration to validation to representation is natural and easy to follow.

Run 3

Code Structure: The validator is logically organized into configuration, validation, and representation methods, though several unused imports add clutter. Nesting: A single conditional keeps nesting minimal. Clarity of intent: Descriptive class and attribute names, a straightforward length check, and a helpful error message make the purpose clear; abbreviated parameters and library-specific decorators require some familiarity. Code length: The implementation is concise, with only minor excess from unused imports and an unnecessary blank line. Action granularity: Each statement performs one clear action. Reading flow: Imports followed by the class and its methods create a natural progression, although cleaner spacing and trimmed imports would improve readability.