Sample

pyint-c236b24c4374-I05

Rewrite eligible decimal integer literals in hexadecimal notation

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 Pro150–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 and readable. It uses clear class and method names, maintains a flat structure with minimal nesting, and follows consistent formatting. The docstring clearly explains the purpose of using a callable class. Line lengths are reasonable, and the __repr__ method is logically organized with a clear flow. Minor deductions: the conditional logic in __call__ and __repr__ could be slightly more explicit, and the f-string concatenation in __repr__ is a bit unusual, though not confusing.

Run 3

The code is generally readable but has some weaknesses. Structure is logical with a class-based validator approach, but the class name and purpose are somewhat ambiguous without context. Nesting is minimal and flat, which is good. Clarity of intent is moderate: the __call__ method is straightforward, but the __repr__ method could be clearer. Code length is concise, which helps readability. Action granularity is reasonable, with one action per line in most cases. Reading flow is natural, though the f-string concatenation in __repr__ could be simplified. The use of type hints is good, but the conditional logic in __repr__ could be more explicit. Overall, it's readable but not exceptional, with minor room for improvement in naming and string formatting.

Run 1

Code Structure: The class logically groups validator configuration, execution, 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 clearly convey iterable and member validation; however, is_callable() and optional() are not defined or imported in the shown code, and the __call__ docstring explains representation customization rather than validation behavior. Code length: The implementation is concise, although the multiline attribute declaration and representation construction add minor visual overhead. Action granularity: Each statement performs one clear action, making behavior easy to follow. Reading flow: Configuration naturally precedes execution and representation, with helpful whitespace; external helpers and decorator semantics require some contextual knowledge.

Run 2

Code Structure: The class logically separates configuration, validation, and representation, although several imports are unused in this snippet. Nesting: Shallow conditionals and a simple loop make control flow easy to follow. Clarity of intent: Descriptive validator names communicate the purpose well, but abbreviated parameters and the externally defined is_callable() and optional() helpers require context. The docstring explains the callable-class design rather than validation behavior. Code length: The implementation is concise, with modest formatting overhead in __repr__. Action granularity: Each statement performs one clear action. Reading flow: Configuration followed by execution and representation provides a natural progression; multiline conditional formatting slightly interrupts an otherwise smooth flow.

Run 3

Code Structure: The class cleanly separates validator configuration, validation behavior, and representation, though several imports appear unused in this excerpt. Nesting: Control flow is shallow, with one conditional and one straightforward 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 shown code, and the docstring explains implementation rather than behavior. Code length: The implementation is concise, although the representation formatting is somewhat spread out. Action granularity: Each statement performs one clear action. Reading flow: Configuration naturally precedes validation and representation, with whitespace aiding scanning; the multiline conditional expression in __repr__ adds a small amount of reading effort.