Sample

pyint-92df7fddb91c-I12

Inline all eligible single-use intermediate local 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 is well-structured with clear separation of concerns, using a class-based approach for validation. Import statements are organized, though the regex import ('re') appears unused. The class has appropriate decorators and attribute definitions with sensible defaults. Nesting is minimal - only two levels in the __call__ method. The docstring helps clarify intent, and method names are descriptive. Code length is concise and avoids unnecessary verbosity. Action granularity is good, with one logical operation per line. Reading flow is natural and progresses logically from imports to class definition to methods. Minor deductions: the unused 're' import creates slight ambiguity, and the conditional validator check could be slightly more explicit about intent. Overall, the code demonstrates strong readability practices with good type hints and clear naming conventions.

Run 3

The code is well-structured with clear separation into imports, class definition, and methods. Nesting is minimal, with only one conditional block inside the __call__ method. Intent is clear: the class validates deeply iterable structures with optional validation of the container itself. Code is concise, with each method focused on a single responsibility. Action granularity is appropriate—each line performs one logical operation, like assigning, validating, or formatting. Reading flow is natural: imports, class definition, constructor attributes, then methods in logical order. Minor readability limitations include the slightly dense __repr__ method using nested f-strings and the conditional expression, which could benefit from intermediate variables for clarity. Overall, the code is highly readable for experienced Python developers familiar with attrs patterns.

Run 1

Code Structure: Imports, class attributes, validation behavior, and representation are logically organized. Nesting: The conditional and loop are shallow and easy to follow. Clarity of intent: Descriptive names clearly distinguish iterable-level validation from member validation, though is_callable() and optional() are undefined in the supplied snippet, and the docstring explains the class design rather than the method's behavior. Code length: The class is concise, but several imports appear unused in this excerpt. Action granularity: Each statement performs one clear action. Reading flow: Validation proceeds naturally from the container to its members; the multiline conditional and split representation string introduce minor visual fragmentation. Overall, the code is highly readable with small context and presentation limitations.

Run 2

Code Structure: The class cleanly separates 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 easy to understand; however, is_callable and optional are not defined or imported in the excerpt, and the docstring explains the class design rather than the method's behavior. Code length: The implementation is concise, although formatting spreads some short expressions across multiple lines. Action granularity: Each statement performs a distinct action, with no compressed multi-action lines. Reading flow: Configuration followed by callable behavior and representation is natural; the multiline conditional expression in __repr__ slightly interrupts the otherwise straightforward flow.

Run 3

Code Structure: The class cleanly separates attribute configuration, validation behavior, and representation, although several imports appear unused in this snippet. Nesting: Shallow conditionals and a single loop make control flow easy to follow. Clarity of intent: Descriptive validator names clearly communicate iterable and member validation; however, is_callable() and optional() are not defined or imported in the excerpt, and the docstring explains the class design rather than validation behavior. Code length: Compact overall, with slightly verbose formatting for the optional attribute and representation string. Action granularity: Each statement performs a distinct action, with no crowded multi-action lines. Reading flow: Configuration followed by execution and representation is natural; the multiline conditional expression in __repr__ requires a little extra attention.