Sample

pyint-8309fb2d9360-I04

Replace names with deterministic minifier-style shortest identifiers

Matched original source

Lines29

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8390–1; higher is more readable
Mi0.370–1; higher is more readable
LLOC18Logical lines; fewer is more readable
DeepSeek V4 Pro130–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.5050–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 _MatchesReValidator: pattern = attrib() match_func = attrib() def __call__(self, a, b, c): """ We use a callable class to be able to change the ``__repr__``. """ if not self.match_func(c): d = f"'{b.name}' must match regex {self.pattern.pattern!r} ({c!r} doesn't)" raise ValueError( d, b, self.pattern, c, ) def __repr__(self): return f"<matches_re validator for pattern {self.pattern!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.652.329−21.527
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.38−6.569

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.86.933+0.598
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.052+0.441
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
Indentation frequencyHow rapidly indentation changes from line to line.27+0.197
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.30−0.026
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.87−0.02
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.28.898−0.006

Intercept 0.07 + feature contributions = 1.653 (log-odds).
Score = sigmoid(1.653) = 0.839.

Score0.37
Score18
Run 1

The code is moderately readable but has several issues. It uses single-letter variable names (a, b, c, d) that obscure intent, making it difficult to understand what each parameter represents without domain knowledge. The validator's __call__ method appears to ignore parameter 'a' entirely, which creates confusion. The error message construction is split across multiple lines unnecessarily, although the f-string itself is clear. The class structure is logical and flat, with no problematic nesting. The use of the attrs decorator with frozen=True and slots=True is idiomatic and clear. The __repr__ method is concise and useful for debugging. The docstring explains the design choice of using a callable class, which is helpful. However, the conditional check and error raising could be more explicit about what 'c' represents (the value being validated). Overall, the code is functional and follows some good practices, but the naming choices and unclear parameter usage significantly reduce readability.

Run 2

The code is reasonably structured but has issues. The class is concise and handles one responsibility (regex validation), which is good. However, the parameter names `a`, `b`, `c` are unclear and force the reader to infer their meaning from context. The variable `d` used for the error message also obscures intent. There is an unused import (`operator`, `get_run_validators`, `set_run_validators`, etc.) that suggests tangled organization. The nesting is minimal, but the conditional inside `__call__` could be simpler with an early return. The docstring explains why a callable class is used, but the actual validation logic isn't obvious at first glance. The reading flow is interrupted by the unexplained imports and cryptic names. Length is adequate, but clarity of intent and readability of the validation logic suffer from poor naming and unnecessary variable assignments.

Run 3

The code is moderately readable but has clarity issues. The structure is logical, and nesting is minimal, which is good. However, the use of single-letter parameter names (a, b, c, d) obscures intent, making the code harder to understand at a glance. The docstring in __call__ does not explain the parameters either. The error message construction is clear, though variable d as the message is unnecessary. The class and method names are descriptive, and the __repr__ is clear. Action granularity is acceptable, with one main action per line, but the mixed use of 'a', 'b', 'c' reduces readability. Overall, the code is concise but would benefit significantly from meaningful variable names and a more informative docstring.

Run 1

Code Structure: The validator is logically organized into attributes, validation, and representation methods, though numerous unused imports add clutter. Nesting: A single conditional keeps nesting shallow and easy to follow. Clarity of intent: The class name, pattern, match_func, and error message communicate regex validation, but parameter names a, b, c and temporary variable d obscure their roles. The docstring explains the callable-class design rather than the method's behavior. Code length: The implementation is compact, although imports and the expanded exception arguments introduce avoidable length. Action granularity: Statements generally perform one action per line, with error-message construction separated from raising the exception. Reading flow: The progression from configuration to validation to representation is natural, but cryptic names and import clutter interrupt readability.

Run 2

Code Structure: The validator is logically organized into attributes, validation behavior, and representation, but numerous unused imports add clutter. Nesting: Minimal nesting makes control flow easy to follow. Clarity of intent: Class and attribute names communicate regex validation clearly, while parameter names a, b, c and temporary variable d obscure their roles. The docstring explains the callable-class design rather than the method's validation behavior. Code length: The implementation is concise, though unused imports and the expanded exception arguments add unnecessary length. Action granularity: Each statement performs a single clear action. Reading flow: The sequence from state to validation to representation is natural, but cryptic local names and unexplained multi-argument ValueError construction interrupt comprehension.

Run 3

Code Structure: The validator class logically groups attributes, validation behavior, and representation, but numerous unused imports add clutter. Nesting: A single conditional keeps control flow shallow and easy to follow. Clarity of intent: The class name, regex check, and error message communicate the purpose clearly; however, parameters a, b, c and temporary variable d are cryptic, and the call method's docstring explains the class design rather than its validation behavior. Code length: The implementation is compact, though unused imports and the expanded exception argument list introduce avoidable length. Action granularity: Each statement performs one clear action, separating error-message construction from raising the exception. Reading flow: Attributes followed by validation and representation create a natural progression, slightly weakened by vague variable names and distracting imports.