Sample

pyint-dd3eb2d95411-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines41

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8510–1; higher is more readable
Mi0.5050–1; higher is more readable
LLOC25Logical lines; fewer is more readable
DeepSeek V4 Pro90–20; mean of three runs
GPT-6.1 Sol13.670–20; mean of three runs
BTTF0.5530–1; higher is more readable

Views

Source code

from __future__ import annotations from collections import OrderedDict from collections.abc import Iterable, Iterator, Mapping from typing import Any, Generic, TypeVar, overload from .compat import MutableMapping class LookupDict(dict[str, _VT]): """Dictionary lookup object.""" name: Any def __init__(self, nam: Any = None) -> None: self.name = nam super().__init__() def __repr__(self) -> str: return f"<lookup '{self.name}'>" def __getattr__(self, key2: str) -> _VT | None: # We need this for type checkers to infer typing # on attribute access with status_codes.py if key2 in self.__dict__: return self.__dict__[key2] else: raise AttributeError( f"'{type(self).__name__}' object has no attribute '{key2}'" ) def __getitem__(self, key3: str) -> _VT | None: # type: ignore[override] # We allow fall-through here, so values default to None return self.__dict__.get(key3, None) @overload def get4(self, key4: str, def2: None = None) -> _VT | None: ... @overload def get4(self, key5: str, def3: _D | _VT) -> _D | _VT: ... def get4(self, key6: str, def4: _D | None = None) -> _VT | _D | None: return self.__dict__.get(key6, def4)

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.1355.033−44.716
Source linesThe number of non-empty source lines.41+16.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.672−7.008

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.37+0.543
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.75.262+0.41
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.76.881+0.409
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.39−0.345
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.40.859+0.161
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.087+0.098

Intercept 0.07 + feature contributions = 1.744 (log-odds).
Score = sigmoid(1.744) = 0.851.

Score0.505
Score25
Run 1

This code has significant readability issues. The naming is confusing and inconsistent: parameters like 'nam', 'key2', 'key3', 'key4', 'key5', 'key6' and 'def2', 'def3', 'def4' suggest artificial renaming that obscures intent rather than clarifying it. The class inherits from dict but overrides __getitem__ to ignore dictionary contents entirely, accessing only __dict__, which is deeply misleading. The __getattr__ method's comment about type checkers is helpful but the logic remains unclear. The overloaded 'get4' method has a problematic name and redundant overloads. The code lacks proper documentation for the unusual behavior, missing type variable definitions (_VT, _D are used but not defined in this snippet), and violates the principle of least surprise. While the structure is relatively flat and methods are short, the ambiguous naming, misleading inheritance pattern, and unclear purpose significantly reduce readability.

Run 2

The code is generally structured but has several readability issues. The class is logically organized, but unclear naming (nam, key2, key3, get4) obscures intent and makes the code ambiguous. The double-underscore dict access in __getitem__ is misleading because LookupDict inherits from dict but uses __dict__ for storage, creating a confusing mental model. The __getattr__ implementation is flat, but the logic is slightly tangled with type-checker comments. While it is concise, the overloads and type annotations add complexity, reducing clarity. Action granularity is acceptable, but the reading flow is disrupted by poorly named parameters and methods. Overall, it is readable but not highly so, falling around the middle of the scale.

Run 3

The code is structurally simple but has several readability issues. The class inherits from dict yet overrides __getitem__ to delegate to self.__dict__, breaking expected mapping semantics and creating confusing dual behavior. Variable names are poor: 'nam', 'key2' through 'key6', 'def2' through 'def4' obscure intent and suggest copy-pasted code. The get4 method with overloads adds complexity for marginal type hinting benefit. Docstring is minimal and doesn't explain the purpose or the unusual fall-through semantics. Comments are sparse and don't clarify the dual-dictionary design. While flat and concise, the mixed inheritance pattern and semantic mismatch between dict and __dict__ operations create cognitive overhead.

Run 1

Code Structure: Methods are logically grouped within a small class, although unused imports and undefined type variables in the snippet distract. Nesting: Very shallow, with only a simple conditional; the else after a return is unnecessary. Clarity of intent: Docstrings, annotations, and comments help, but names such as nam, key2, get4, and def4 obscure meaning. Looking up values in __dict__ rather than the inherited dictionary is surprising and insufficiently explained. Code length: Generally concise, though overloads and redundant default arguments add some visual overhead. Action granularity: Each line performs a single clear action. Reading flow: The constructor, representation, and lookup methods follow a natural sequence, but inconsistent parameter names across overloads and unexplained type variables interrupt comprehension.

Run 2

Code Structure: Methods are logically grouped within a small class, though unused imports and unexplained type variables add distraction. Nesting: Shallow control flow is easy to follow; the else after a return is unnecessary. Clarity of intent: Type annotations and comments help, but names such as nam, key2–key6, def2–def4, and get4 obscure meaning. Using __dict__ rather than dictionary entries for lookups is surprising and deserves clearer explanation. Code length: Mostly concise, although overloads and repetitive parameter naming introduce some visual overhead. Action granularity: Each statement performs a single action, making individual operations easy to understand. Reading flow: The progression from initialization to representation and lookup methods is natural, but inconsistent naming and undefined _VT and _D in the provided snippet interrupt comprehension.

Run 3

Code Structure: Methods are logically grouped within a small class, but unused imports and undefined type variables (_VT and _D) distract from its organization. Nesting: Very shallow, with only one simple conditional; the else after a return is unnecessary. Clarity of intent: The docstring and comments help, but names such as nam, key2–key6, def2–def4, and get4 obscure meaning. Using instance attributes rather than dictionary entries for lookup is surprising for a dict subclass and deserves clearer explanation. Code length: Compact overall, though imports and repetitive overload declarations add visual overhead. Action granularity: Each statement performs a single action, making individual lines easy to follow. Reading flow: Initialization, representation, and lookup methods form a natural sequence, but inconsistent naming, typing details, and an extra blank line interrupt smooth reading.