Sample

pyint-663027115a63-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines29

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8560–1; higher is more readable
Mi0.530–1; higher is more readable
LLOC16Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.5670–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=False, unsafe_hash=True) class _IsCallableValidator: def __call__(self, ins, att, val): """ We use a callable class to be able to change the ``__repr__``. """ if not callable(val): mes = ( "'{name}' must be callable " "(got {value!r} that is a {actual!r})." ) raise NotCallableError( msg=mes.format( name=att.name, value=val, actual=val.__class__ ), value=val, ) def __repr__(self): return "<is_callable validator>"

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.714.305−23.572
Source linesThe number of non-empty source lines.29+11.6
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.266−6.398

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

Feature contributions

FeatureValueContribution
(log-odds)
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.967+0.702
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.054+0.42
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.27+0.197
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.51.767+0.031
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.30−0.026
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.28.859−0.006

Intercept 0.07 + feature contributions = 1.785 (log-odds).
Score = sigmoid(1.785) = 0.856.

Score0.53
Score16
Run 1

The code is generally readable: imports are organized, the class and method names are clear, and the validator's purpose is evident. The error message formatting is straightforward and uses a reasonable line-breaking style. However, a few points reduce clarity: the @attrs decorator with multiple boolean flags is terse and may require knowledge of the attrs library; the 'mes' variable is abbreviated; and the multi-line string concatenation inside the if block slightly disrupts reading flow. Nesting is minimal, and each logical action (checking callability, formatting, raising) is separated, but the code could benefit from slightly more descriptive naming and a clearer separation between validation logic and error message construction.

Run 2

The code is generally well-structured and readable. Imports are organized, and the class and method are clearly named. The validation logic is clear, with a helpful error message. However, some minor readability issues: the error message construction spans multiple nested levels (string formatting inside raise), slightly reducing flatness, and the method mixes validation logic with message assembly in one block. The use of a callable class for repr customization is clear, but slightly increases cognitive overhead for beginners. Overall, concise, purposeful, and maintainable.

Run 3

The code is generally readable with a clear structure: imports are organized by source, the class is decorated cleanly with attrs, and the validator's purpose is evident from its name and docstring. The `__call__` method has a single responsibility (validating callability) and constructs an informative error message. The use of a multi-line string for `mes` improves readability, and the `repr` is concise. Minor deductions: the variable `mes` is slightly opaque (could be `message`), and the conditional structure, while simple, could benefit from an early return or guard clause to reduce nesting. Overall, the code is flat, reasonably concise, and follows natural reading flow, but a few naming and structural refinements would improve clarity.

Run 1

Code Structure: The validator is logically organized into validation and representation methods, although numerous unused imports distract from the small example. Nesting: Shallow nesting makes control flow easy to follow; multiline exception construction remains manageable. Clarity of intent: The class name, callable check, and descriptive error clearly communicate the purpose, but abbreviated parameters and 'mes' reduce clarity, and the docstring explains the class design rather than the method's behavior. Code length: The implementation is concise, though the imports add unnecessary length in this snippet. Action granularity: Each statement performs a single clear action, with readable multiline formatting. Reading flow: The code proceeds naturally from validation to error reporting and representation, with minor friction from terse names and unexplained decorator options.

Run 2

Code Structure: Imports and a small validator class are logically organized, with validation and representation separated. Nesting: A single conditional keeps control flow shallow; nested formatting adds little difficulty. Clarity of intent: The class name, callable check, and descriptive exception clearly convey the purpose, though abbreviated parameters (ins, att, val) and mes reduce clarity, and the decorator requires library knowledge. Code length: The implementation is concise, but several imports are unused in this snippet, and the docstring explains the class design rather than the method's behavior. Action granularity: Each statement performs one main action, with readable multiline error construction. Reading flow: Execution proceeds naturally from checking the value to raising an informative error, followed by a simple representation method.

Run 3

1. Code Structure: Imports and a small validator class are logically organized, although several imports are unused in this snippet. 2. Nesting: Shallow control flow makes the validation easy to follow; multiline formatting adds little complexity. 3. Clarity of intent: The class name, callable check, and descriptive exception clearly communicate the purpose, but abbreviated names such as ins, att, val, and mes reduce clarity. The docstring explains the class design rather than the method's behavior. 4. Code length: Concise overall, with some unnecessary imports and slightly verbose message construction. 5. Action granularity: Each statement performs one clear action, and exception arguments are separated cleanly. 6. Reading flow: The progression from checking callability to raising an informative error is natural, followed by a straightforward representation method.