Sample

pyint-e922c86de360-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines32

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.6250–1; higher is more readable
Mi0.070–1; higher is more readable
LLOC21Logical lines; fewer is more readable
DeepSeek V4 Pro120–20; mean of three runs
GPT-6.1 Sol14.670–20; mean of three runs
BTTF0.4450–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 ((0xb884 ^ 0xb884) != 0): raise AssertionError() 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): if ((0x10db ^ 0x10db) != 0): raise AssertionError() 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.828.27−27.333
Source linesThe number of non-empty source lines.32+12.8
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.468−6.702

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

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.062+0.344
Indentation frequencyHow rapidly indentation changes from line to line.30+0.301
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.30−0.268
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.33−0.132
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.31.74+0.034

Intercept 0.07 + feature contributions = 0.509 (log-odds).
Score = sigmoid(0.509) = 0.625.

Score0.07
Score21
Run 1

The code has a clear structure with appropriate use of decorators and a callable class. However, it includes dead code with XOR checks and AssertionError raises that serve no purpose and harm readability. The __call__ method has moderate nesting and multiple actions per line in message construction, reducing action granularity. The import block is somewhat disorganized—'operator' and 'contextmanager' are unused, 'Pattern' is unused, and 're' is unused—adding noise. The class is concise overall, but these extraneous elements obscure intent and disrupt reading flow.

Run 2

The code is reasonably structured but contains unnecessary obfuscation that severely hurts readability. The validator class is logically organized with clear method separation, and the type check logic in __call__ is straightforward with good error message formatting. However, the dead code checks like 'if ((0xb884 ^ 0xb884) != 0): raise AssertionError()' add noise and confusion without purpose. The imports are mostly clean but unused imports (operator, re, Pattern, contextmanager, etc.) suggest tangled dependencies. Nesting is flat and the reading flow is natural for the validator logic, but the irrelevance of the XOR checks breaks clarity of intent. The __repr__ is concise and clear. Overall, the code would be readable if the spurious assertion checks and unused imports were removed, but currently they create ambiguity and unnecessary length.

Run 3

The code is generally readable: it has a clear class structure, a single public method with an obvious purpose, and only one level of nesting inside the method. The use of a callable class is explained in a docstring, and type checking and error messaging are clear. However, there are several dead-code lines like `if ((0xb884 ^ 0xb884) != 0): raise AssertionError()` that add noise and confuse intent. Imports include unused items (`operator`, `re`, `Pattern`, `contextmanager`, `get_run_validators`, `set_run_validators`, `_AndValidator`, `and_`, `attrs`, `default_if_none`, `NotCallableError`) which unnecessarily lengthens the file. The error-raising logic is concise, but the presence of dead code and unused imports reduces clarity and reading flow.

Run 1

Code Structure: Imports and a small validator class are logically organized, though several imports are unused in this snippet. Nesting: Shallow conditionals make control flow easy to follow. Clarity of intent: Class and method names clearly communicate instance validation, and the error message is informative; however, the constant-false hexadecimal XOR checks are unexplained distractions. Code length: Mostly concise, but dead assertion branches and the verbose formatting of TypeError arguments add unnecessary length. Action granularity: Statements generally perform one action per line, with error-message construction separated from raising the exception. Reading flow: Validation followed by error reporting reads naturally, and representation logic is cleanly separated, but the redundant checks interrupt both methods.

Run 2

Code Structure: Imports and a small validator class are logically organized, although several imports are unused in this snippet. Nesting: Shallow conditional blocks are easy to follow. Clarity of intent: The isinstance check, descriptive error, and custom representation communicate the validator's purpose, but constant-false hexadecimal XOR checks introduce misleading, unexplained noise. Code length: The class is reasonably concise, yet the dead assertion blocks and unused imports add unnecessary length. Action granularity: Each statement performs a single action; the multiline exception construction is readable. Reading flow: Validation proceeds naturally from checking the value to constructing and raising an error, but irrelevant checks interrupt both methods. The docstring explains the callable-class design rather than the method's validation behavior.

Run 3

Code Structure: The validator class logically separates validation from representation, although several imports appear unused in this snippet. Nesting: Control flow is shallow and easy to follow. Clarity of intent: The isinstance check, descriptive error message, and __repr__ make the main purpose clear; however, constant-false XOR conditions and unreachable AssertionError statements introduce confusing noise. Code length: The implementation is reasonably short, but removing those redundant checks would make it more concise. Action granularity: Statements generally perform one action each, and the multiline TypeError construction is easy to scan. Reading flow: Imports, class declaration, validation, and representation follow a natural order, but the pointless checks interrupt that flow, and the __call__ docstring explains representation customization rather than the method's validation behavior.