Sample

pyint-83ed85f38231-SRC

Unmodified source class

Lines28

Scores

MethodScoreScale
Posnett0.0010–1; higher is more readable
Dorn0.7770–1; higher is more readable
Mi0.0760–1; higher is more readable
LLOC17Logical lines; fewer is more readable
DeepSeek V4 Pro160–20; mean of three runs
GPT-6.1 Sol180–20; mean of three runs
BTTF0.5380–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): """ We use a callable class to be able to change the ``__repr__``. """ 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.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.417−6.626

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.103+0.857
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.103−0.697
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.048+0.472
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.779−0.022
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.25 (log-odds).
Score = sigmoid(1.25) = 0.777.

Score0.076
Score17
Run 1

The code is generally readable and well-structured. It uses clear imports, a sensible class-based validator design, and the __call__ method has a clear purpose. The nested if statement is minimal and the error message is descriptive. The repr method is concise. However, some aspects reduce readability: the error message string is quite long and formatted inline, the raise TypeError call spans multiple lines, and the imports include unused items (e.g., operator, contextmanager, Pattern, and various attrs utilities) which can create confusion. The type hinting is absent for the __call__ parameters, and the docstring is brief. Overall, the code is understandable but could be improved with cleaner import management and slightly more explicit type annotations.

Run 2

The code is well-structured: a single class with a clear purpose (validating instance types), flat nesting, and a logical flow. The use of the attrs library concisely defines a lightweight class. The __call__ method clearly separates type checking, error message construction, and raising. The __repr__ method improves debuggability. The only slight ambiguity is the comment about using a callable class for __repr__, which could be more explicit, and the multi-line TypeError call is slightly verbose but still readable. Overall, the code is concise, clear, and maintainable.

Run 3

The code is concise and well-structured. It defines a single validator class with clear intent. The constructor uses attrs to define a 'type' attribute, and the __call__ method performs type validation with a clear error message. Nesting is minimal, with only one conditional check. The reading flow is natural: class definition, init, call, then repr. The error message construction is slightly verbose but improves clarity. Minor drawbacks: the __call__ method performs both validation and exception raising, slightly reducing action granularity. The __repr__ method is simple and informative. Overall, the code is readable and maintainable, with clear separation of concerns between class definition, validation logic, and representation.

Run 1

Code Structure: The validator class logically groups its configuration, validation behavior, and representation, though several imports are unused in this snippet. Nesting: A single conditional keeps control flow shallow and easy to follow. Clarity of intent: Descriptive class and method behavior make the type-checking purpose clear; the docstring explains the callable-class design rather than validation itself. Code length: The implementation is concise, although the multiline exception construction is slightly verbose. Action granularity: Each statement performs one distinct action, separating message construction from raising the exception. Reading flow: Configuration leads naturally into validation and representation; the long error-message line and limited spacing between imports and the class slightly reduce readability.

Run 2

Code Structure: Imports and a focused validator class are logically organized, though several imports appear unused in this snippet. Nesting: A single conditional keeps control flow shallow. Clarity of intent: Descriptive class and method names, an explicit isinstance check, and a helpful error message clearly convey validation behavior; the attrs-based field declaration requires some library familiarity. Code length: The implementation is concise, although the multiline exception construction is slightly verbose. Action granularity: Each statement performs one clear action, separating message construction from raising the exception. Reading flow: The progression from field declaration to validation and representation is natural. The docstring explains the callable-class design rather than the method's validation behavior, and the long error-message line slightly reduces readability.

Run 3

Code Structure: Imports and a small validator class are logically organized, though several imports are unused in this snippet. Nesting: Only a single conditional keeps the code easy to follow. Clarity of intent: Descriptive class and method names, a straightforward isinstance check, and an informative error message clearly communicate validation behavior; the attrs machinery requires some familiarity. Code length: Concise overall, 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 progression from configuration to validation to representation is natural. Minor drawbacks include the long error-message line and a __call__ docstring that explains the callable-class design rather than the method's validation purpose.