Sample

pyint-ce56dabf6fe8-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines28

Scores

MethodScoreScale
Posnett0.0010–1; higher is more readable
Dorn0.7940–1; higher is more readable
Mi0.1170–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro15.330–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.5120–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, ins, att, val): """ We use a callable class to be able to change the ``__repr__``. """ if not isinstance(val, self.type): msg2 = f"'{att.name}' must be {self.type!r} (got {val!r} that is a {val.__class__!r})." raise TypeError( msg2, att, self.type, val, ) 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.635.312−20.965
Source linesThe number of non-empty source lines.28+11.2
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.424−6.637

Intercept 8.87 + feature contributions = -7.532 (log-odds).
Score = sigmoid(-7.532) = 0.001.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.99+0.793
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.99−0.528
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.049+0.465
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
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.27.83−0.021
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.29+0.01

Intercept 0.07 + feature contributions = 1.349 (log-odds).
Score = sigmoid(1.349) = 0.794.

Score0.117
Score17
Run 1

The code is highly readable with a clear, focused structure. It defines a single-purpose validator class with logical organization, only one level of nesting, and no tangled logic. The intent is explicit through the class name, docstring, and descriptive variable names like 'ins', 'att', and 'val'. The code is concise and avoids unnecessary length, though it could benefit from slightly more descriptive parameter names for clarity. Action granularity is mostly one action per line, except for the error message construction which combines formatting and assignment onto one line. Reading flow is natural, with the class definition, __call__ method, and __repr__ method following a standard, predictable order. Minor deductions are for the use of 'msg2' instead of a more descriptive name, and the fact that 'ins' is unused, which could confuse readers about intent.

Run 2

The code has clear structure, low nesting, and generally follows PEP8. Imports are organized, the class uses attrs decorators correctly, and the `__call__` method has a clear purpose with a docstring. However, readability is slightly reduced by inconsistent f-string usage (defining `msg2` instead of inlining), a somewhat ambiguous variable name (`ins` unused), and the immediate raise within the conditional adds minor cognitive load. The class is concise but could be more readable with direct error raising and clearer naming.

Run 3

The code is generally readable with clear intent, logical structure, and mostly one action per line. However, there are several issues: an unused import (operator), ambiguous variable names (ins, att, msg2), a long f-string error message that reduces clarity, and a nested f-string call (val.__class__.__repr__) inside another f-string, which is hard to read. The class structure is flat and straightforward, but the error message formatting could be more concise and clearer. Overall, the code is maintainable but would benefit from better naming and string construction.

Run 1

Code Structure: Imports and a small validator class are logically organized, though several imports appear unused in this snippet. Nesting: Minimal nesting makes control flow easy to follow. Clarity of intent: The class name, isinstance check, descriptive exception message, and custom representation clearly communicate the validator's purpose; abbreviated parameters (ins, att, val) and the name msg2 reduce clarity. Code length: The implementation is concise, although the multiline exception construction is somewhat verbose. Action granularity: Each statement performs one clear action, with message creation separated from raising the exception. Reading flow: The sequence from configuration to validation to representation is natural, but the __call__ docstring explains the callable-class design rather than the method's behavior.

Run 2

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 and easy to follow. Clarity of intent: The class name, isinstance check, descriptive error message, and custom representation clearly convey the purpose. However, abbreviated parameters (ins, att, val) and the variable name msg2 reduce clarity slightly. Code length: The implementation is concise; the multiline exception construction is somewhat verbose but readable. Action granularity: Each statement performs one clear action, with message construction separated from raising the exception. Reading flow: The progression from configuration to validation to representation is natural, although the docstring explains the callable-class design rather than the method's validation behavior.

Run 3

Code Structure: Imports and a small validator class are logically organized, though several imports are unused in this snippet. Nesting: Minimal nesting, with a single conditional inside __call__. Clarity of intent: The class name, isinstance check, and descriptive error message clearly communicate validation behavior; abbreviated parameters (ins, att, val) and the name msg2 reduce clarity slightly. Code length: The implementation is concise, although the multiline TypeError call is somewhat verbose for four arguments. Action granularity: Each statement performs one clear action, separating message construction from exception raising. Reading flow: The progression from configuration to validation and representation is natural. The docstring explains the callable-class design rather than the method's validation behavior, and the unused ins parameter may require framework knowledge.