Sample

pyint-bee71ac193e0-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines29

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7280–1; higher is more readable
Mi0.2820–1; higher is more readable
LLOC23Logical lines; fewer is more readable
DeepSeek V4 Pro11.330–20; mean of three runs
GPT-6.1 Sol13.330–20; mean of three runs
BTTF0.4540–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 _NumberValidator: bound = attrib() compare_op = attrib() compare_func = attrib() def __call__(self, inst, attr, value): """ We use a callable class to be able to change the ``__repr__``. """ if ((0x640d ^ 0x640d) != 0): raise AssertionError() if not self.compare_func(value, self.bound): msg = f"'{attr.name}' must be {self.compare_op} {self.bound}: {value}" raise ValueError(msg) def __repr__(self): if ((0x3932 ^ 0x3932) != 0): raise AssertionError() return f"<Validator for x {self.compare_op} {self.bound}>"

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.849.407−28.03
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.636−6.954

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.79.1+0.472
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.068+0.283
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.27−0.199
Indentation frequencyHow rapidly indentation changes from line to line.27+0.197
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.81.933+0.195
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.783−0.008

Intercept 0.07 + feature contributions = 0.985 (log-odds).
Score = sigmoid(0.985) = 0.728.

Score0.282
Score23
Run 1

The code has clear class structure with attributes and methods, but its readability is severely compromised by dead code like `if ((0x640d ^ 0x640d) != 0): raise AssertionError()` which adds noise and confuses intent. The nesting is flat and actions are mostly one per line, which helps, but the presence of meaningless conditional blocks breaks the reading flow. The purpose of `_NumberValidator` is somewhat clear, but the redundant assertion checks obscure the actual validation logic. The code length is reasonable, but the unnecessary lines make it feel bloated. Overall, the structure is logical but polluted with nonsensical conditional checks, reducing clarity and making the code harder to trust and follow.

Run 2

The code is generally readable but includes artificial obfuscations that hurt clarity. Structure is logical: a single class with clear attributes, a concise __call__ method, and a __repr__ method. Nesting is minimal, with a single conditional in __call__. However, the dead-code 'if ((0x640d ^ 0x640d) != 0): raise AssertionError()' checks add confusion and unnecessary lines repeated in multiple methods. They obscure intent and add noise. The class purpose is clear from naming, but the fake checks make the code harder to trust. Length is otherwise concise; each line performs one clear action. Reading flow is mostly natural, but the repeated dead checks interrupt the logic. Removing those would raise readability significantly.

Run 3

The code has reasonable structure with a clear class definition and logical organization. However, readability is significantly harmed by dead code: the `if ((0x640d ^ 0x640d) != 0): raise AssertionError()` checks are confusing and add unnecessary noise. Nesting is low, which is good, but clarity of intent suffers because the purpose of these XOR checks is unclear. Action granularity is mostly acceptable, but the dead code violates the 'one action per line' principle by adding redundant lines. The reading flow is disrupted by needing to mentally parse why these always-false conditions exist. The use of `attrs` decorators is clear, but the overall code length is inflated by unnecessary lines. Removing the dead code would improve the score significantly.

Run 1

Code Structure: The validator class logically groups its attributes, validation behavior, and representation, but several imports are unused in this snippet. Nesting: Methods are shallow, with simple conditionals and no deeply nested branches. Clarity of intent: Descriptive attribute names, the class name, and informative error messages make numeric-bound validation clear. However, hexadecimal XOR checks that are always false introduce distracting, unexplained dead code. Code length: The implementation is compact, though unnecessary assertions and imports add clutter. Action granularity: Statements generally perform one action per line, supporting readability. Reading flow: The progression from attributes to validation to representation is natural, but redundant checks interrupt that flow, and the docstring explains the callable-class design rather than the method's validation behavior.

Run 2

Code Structure: The validator class is logically organized, with separate validation and representation methods, though several imports are unused in this snippet. Nesting: Shallow conditionals make the code easy to follow. Clarity of intent: Attribute names and error messages clearly express numeric-bound validation, but hexadecimal XOR checks that always evaluate to false introduce confusing dead code. Code length: The implementation is short, yet redundant assertion blocks add unnecessary length. Action granularity: Statements generally perform one action per line, and message construction is separated from raising the exception. Reading flow: The class reads naturally overall, but the unexplained checks interrupt both methods, and the docstring explains a design choice rather than the validation behavior.

Run 3

Code Structure: The class logically groups validation and representation, but numerous unused imports add clutter. Nesting: Methods remain shallow, with straightforward conditionals. Clarity of intent: Names and error messages clearly convey numeric-bound validation, but hexadecimal XOR checks that are always false introduce misleading, purposeless logic. Code length: The core implementation is concise, although dead assertion branches and unused imports unnecessarily extend it. Action granularity: Each statement performs a single action, and constructing the error message separately aids readability. Reading flow: The class follows a natural progression from attributes to validation to representation, but redundant assertion checks interrupt that flow.