Sample

pyint-4c90b995c19f-I11

Split eligible integer literals into pairs of short-named intermediate variables

Matched original source

Lines36

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8620–1; higher is more readable
Mi0.5740–1; higher is more readable
LLOC20Logical lines; fewer is more readable
DeepSeek V4 Pro16.330–20; mean of three runs
GPT-6.1 Sol170–20; mean of three runs
BTTF0.6070–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 _DeepIterable: member_validator = attrib(validator=is_callable()) iterable_validator = attrib( default=None, validator=optional(is_callable()) ) def __call__(self, inst, attr, value): """ We use a callable class to be able to change the ``__repr__``. """ if self.iterable_validator is not None: self.iterable_validator(inst, attr, value) for member in value: self.member_validator(inst, attr, member) def __repr__(self): iterable_identifier = ( "" if self.iterable_validator is None else f" {self.iterable_validator!r}" ) return ( f"<deep_iterable validator for{iterable_identifier}" f" iterables of {self.member_validator!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.919.264−30.336
Source linesThe number of non-empty source lines.36+14.4
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.341−6.512

Intercept 8.87 + feature contributions = -13.577 (log-odds).
Score = sigmoid(-13.577) = 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.973+0.701
Indentation frequencyHow rapidly indentation changes from line to line.34+0.439
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.054+0.413
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.37−0.274
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.35.69+0.089
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.49.649−0.003

Intercept 0.07 + feature contributions = 1.833 (log-odds).
Score = sigmoid(1.833) = 0.862.

Score0.574
Score20
Run 1

The code is generally well-structured and readable. It uses clear naming conventions, logical organization, and flat nesting with minimal indentation levels. The class has a clear purpose, and the methods are concise with appropriate action granularity. The __call__ method is straightforward, and the __repr__ method demonstrates good formatting practices. However, there are minor readability issues: the __call__ method could benefit from a docstring explaining the validation logic, and the conditional in __repr__ could be slightly clearer with a helper method. The code is idiomatic Python with good use of type hints and decorators, but the validation flow could be more explicit. Overall, it strikes a good balance between conciseness and clarity, with minor room for improvement in documentation and separation of concerns within the __repr__ method.

Run 2

The code demonstrates good structure with a well-defined class that has clear responsibilities. The nesting is minimal, with only one level of indentation in the __call__ method. Intent is generally clear, especially with the docstring explaining the design choice of using a callable class. However, the __repr__ method could be clearer about its output format. The code is concise without unnecessary repetition. Action granularity is appropriate - each line performs a distinct operation. Reading flow is somewhat disrupted by the f-string construction in __repr__, which splits the output string across multiple lines. The use of type hints is adequate but could be more explicit. The import structure is organized alphabetically. Overall, the code is readable but could benefit from slightly better documentation and more explicit type annotations.

Run 3

The code is highly readable with clear structure, flat nesting, and logical organization. The class is well-named, uses attrs decorators concisely, and defines two attributes with appropriate validators. The __call__ method performs one action per line, making the control flow obvious: optional iterable validation followed by member iteration and validation. The __repr__ method is clean and readable despite minor string formatting complexity. The code avoids unnecessary length and each component has a clear purpose. Only slight deductions for the conditional f-string construction in __repr__, which requires a moment to parse, and the docstring could be slightly more descriptive. Overall it exemplifies clean, maintainable Python code.

Run 1

Code Structure: The class logically separates configuration, validation, and representation, though several unused imports add clutter. Nesting: Control flow is shallow, with a simple conditional and loop. Clarity of intent: Descriptive names make validation behavior clear, but is_callable() and optional() are not defined or imported in the snippet, and the docstring explains the callable-class design rather than the method's validation behavior. Code length: The implementation is concise; multiline formatting adds some length but keeps expressions readable. Action granularity: Each statement performs one clear action, with no compressed compound statements. Reading flow: Validation proceeds naturally from the iterable itself to its members, followed by representation logic. The conditional expression and split f-string in __repr__ require minor extra parsing.

Run 2

Code Structure: The class cleanly separates attribute definitions, validation behavior, and representation formatting, though several imports appear unused in this snippet. Nesting: Control flow is shallow, with a simple conditional and loop. Clarity of intent: Descriptive names make iterable and member validation clear; however, is_callable() and optional() are not defined or imported in the shown code, and the docstring explains the callable-class design rather than the method's behavior. Code length: The implementation is concise, although representation formatting spans several lines. Action granularity: Each statement performs one clear action, with no compressed multi-action lines. Reading flow: The progression from configuration to execution to representation is natural; the multiline conditional expression slightly interrupts an otherwise straightforward flow.

Run 3

Code Structure: The class logically groups validator configuration, validation behavior, and representation, though several imports appear unused in this excerpt. Nesting: Control flow is shallow, with a simple conditional and loop. Clarity of intent: Descriptive names make iterable and member validation clear; however, is_callable() and optional() are not defined or imported in the shown code, and the docstring explains the class design rather than the method's behavior. Code length: The implementation is concise, with modest extra formatting for the representation. Action granularity: Each statement performs one clear action, without compressed or compound operations. Reading flow: Configuration naturally precedes validation and representation; the multiline conditional expression and split f-string slightly interrupt an otherwise smooth flow.