Sample

pyint-74d70318bf9a-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines27

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8880–1; higher is more readable
Mi0.6770–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.6340–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 _OrValidator: validators = attrib() def __call__(self, ins, att, val): for v2 in self.validators: try: v2(ins, att, val) except Exception: # noqa: BLE001, PERF203, S112 continue else: return msg2 = f"None of {self.validators!r} satisfied for value {val!r}" raise ValueError(msg2) def __repr__(self): return f"<or validator wrapping {self.validators!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.664.856−21.94
Source linesThe number of non-empty source lines.27+10.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.518−6.777

Intercept 8.87 + feature contributions = -9.047 (log-odds).
Score = sigmoid(-9.047) = 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.72.929+0.576
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.051+0.443
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.73+0.373
Indentation frequencyHow rapidly indentation changes from line to line.26+0.162
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.27+0.08
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.26.851−0.035

Intercept 0.07 + feature contributions = 2.068 (log-odds).
Score = sigmoid(2.068) = 0.888.

Score0.677
Score20
Run 1

The code is generally well-structured and readable. It uses clear imports, decorators, and a single class definition that is concise and focused. The nesting is minimal, with only one level inside the loop and try/except block. The intent of the `_OrValidator` class is evident: it tries each validator in sequence and raises if none pass. The code length is appropriate, and each logical action is broken into distinct lines, aiding readability. The reading flow is natural, starting from imports, class definition, call logic, and ending with representation. Minor deductions for the broad exception handling (which could be more specific) and the slight density of the try/except/else block, but overall this is highly readable Python code.

Run 2

The code is generally well-structured and readable. It uses clear naming conventions, type hints, and decorators from the attrs library, which reduce boilerplate. The class is flat with simple control flow, and the __call__ method follows a clear try/except/else pattern. However, the logic of collecting validators and raising a combined error could be slightly more explicit. The exception handling is broad but justified for validator chaining. Overall, the intent is clear, but a bit of domain knowledge is required.

Run 3

The code is well-structured and readable. Imports are organized logically with standard library, third-party, and local modules separated. The _OrValidator class uses the attrs decorator concisely, avoiding boilerplate. The __call__ method is clear: it iterates through validators, returns early on first success, and raises a descriptive error if all fail. Nesting is minimal (one loop with try/except/else). Intent is evident from naming and docstrings are not needed due to clarity. Line length is appropriate, and each logical action is on its own line. The use of f-strings in error and repr messages improves readability. Minor deductions: the catch-all exception is broad but pragmatically justified, and the absence of a module-level docstring slightly reduces context. Overall, the code is concise, maintainable, and follows common Python idioms.

Run 1

Code Structure: Imports and a single focused class provide logical organization, though several imports are unused in this snippet. Nesting: The loop contains a try/except/else block, adding moderate but manageable nesting. Clarity of intent: The class name, validators attribute, error message, and representation clearly communicate OR-style validation; abbreviated parameters and names such as v2 and msg2 reduce clarity. Catching every Exception also obscures the distinction between validation failures and unexpected errors. Code length: The implementation is concise, with little unnecessary code beyond unused imports. Action granularity: Each line generally performs one action. Reading flow: Methods follow a natural progression from validation to representation, and early return makes success easy to follow.

Run 2

Code Structure: The class logically groups validation behavior and its representation, though numerous unused imports distract from the snippet. Nesting: The loop and try/except/else introduce moderate, manageable nesting. Clarity of intent: The class name, validators attribute, and error message clearly convey that any validator may succeed; abbreviated names such as ins, att, val, and v2 reduce clarity. Catching every Exception obscures whether failures are expected validation errors or unrelated bugs. Code length: The implementation is concise, with little unnecessary logic. Action granularity: Each line generally performs one action. Reading flow: Validation proceeds naturally through candidates, returns on success, and raises after all fail. The try/except/else structure and early return make the control flow easy to follow.

Run 3

Code Structure: The class is logically organized into state, validation behavior, and representation, though numerous unused imports add clutter. Nesting: A loop containing try/except/else introduces moderate nesting, but the short branches remain easy to follow. Clarity of intent: The class name, success return, and final error clearly express OR-style validation; abbreviated names such as ins, att, val, and v2 are less descriptive. Catching every Exception obscures which failures are expected validation failures. Code length: The implementation is concise, although unused imports and the temporary msg2 variable could be removed. Action granularity: Each line performs a single clear action. Reading flow: Validation proceeds naturally through candidate validators, returns on success, and raises after all fail. The noqa codes add minor visual noise.