Sample

pyint-f1c6136d21dd-I03

Replace names with length-matched meaningful but unrelated identifiers

Matched original source

Lines41

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8540–1; higher is more readable
Mi0.4850–1; higher is more readable
LLOC25Logical lines; fewer is more readable
DeepSeek V4 Pro9.670–20; mean of three runs
GPT-6.1 Sol13.670–20; mean of three runs
BTTF0.5340–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, item: Any = None) -> None: self.name = item super().__init__() def __repr__(self) -> str: return f"<lookup '{self.name}'>" def __getattr__(self, map: str) -> _VT | None: # We need this for type checkers to infer typing # on attribute access with status_codes.py if map in self.__dict__: return self.__dict__[map] else: raise AttributeError( f"'{type(self).__name__}' object has no attribute '{map}'" ) def __getitem__(self, map: str) -> _VT | None: # type: ignore[override] # We allow fall-through here, so values default to None return self.__dict__.get(map, None) @overload def emit(self, age: str, context: None = None) -> _VT | None: ... @overload def emit(self, map: str, nextKey: _D | _VT) -> _D | _VT: ... def emit(self, map: str, invoice: _D | None = None) -> _VT | _D | None: return self.__dict__.get(map, invoice)

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.1339.694−44.21
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.613−6.919

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.37+0.543
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.75.952+0.448
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.74.286+0.394
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.805+0.161
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.087+0.101

Intercept 0.07 + feature contributions = 1.77 (log-odds).
Score = sigmoid(1.77) = 0.854.

Score0.485
Score25
Run 1

The code is generally readable with clear structure and type hints, but has several issues. It defines a simple dictionary wrapper with straightforward methods, but introduces generic type variables (_VT, _D) without definitions, which is confusing. Method parameter names are misleading ('map' for key, 'invoice'/'age' for value, 'nextKey' for value), reducing clarity. The overloads add complexity without obvious benefit. __getattr__ and __getitem__ have overlapping logic but different behaviors, which is ambiguous. The class name 'LookupDict' is clear, and the code is well-formatted with docstrings. Nesting is minimal and each action is on its own line. Overall, the code is understandable but could be improved with better naming and simplification.

Run 2

The code suffers from major readability issues. Variable names are misleading ('map' for a key, 'age', 'invoice', 'nextKey' are unrelated to dictionary operations), which obscures intent. The class inherits from dict but overrides __getitem__ to return None, creating confusing behavior that contradicts dict semantics. The overload variants for emit are inconsistent and lack clear purpose. The __getattr__ logic has a redundant branch: if the key is missing it raises AttributeError, but the initial 'if map in self.__dict__' check is the only path checked, making the else clause unreachable for normal attribute access. Type annotations include unused imports (Generic, TypeVar) and undefined _VT, _D. While the structure is flat and actions are mostly one per line, the unclear naming, misleading overrides, and ambiguous type usage severely hurt comprehension.

Run 3

The code has major readability issues despite simple structure. Variable naming is severely confusing: parameters like 'map', 'age', 'nextKey', and 'invoice' are semantically misleading and unrelated to their actual function (dictionary lookups). The dual use of __dict__ and MutableMapping inheritance creates ambiguity about data storage - __getitem__ reads from __dict__ while the class inherits from dict, which is confusing. The overloads on emit() add complexity without clear benefit. Missing type variable definitions (_VT, _D) at module level leaves the code incomplete. Documentation is sparse, with unclear comments. While nesting is minimal and line length is reasonable, the intent is obscured by poor naming and mixed data access patterns. The class name LookupDict suggests dictionary behavior, but __getitem__ returning None instead of raising KeyError breaks expected dict semantics, which is not immediately obvious.

Run 1

Code Structure: The class is organized into small, distinct methods, but unused imports and undefined type variables distract from its structure. Nesting: Minimal nesting makes the code easy to scan; the else after a return is unnecessary. Clarity of intent: Type annotations and comments help, but emit is an unclear name for a lookup operation, and inconsistent parameter names (age, context, map, nextKey, invoice) obscure the overloads' shared purpose. Using __dict__ rather than dictionary storage is surprising for a dict subclass and deserves explanation. Code length: Generally concise, though redundant defaults, comments, and imports add noise. Action granularity: Each line performs a single clear action. Reading flow: Method ordering is natural, but inconsistent naming and unexplained typing symbols interrupt comprehension.

Run 2

Code Structure: Methods are logically grouped in a small class, but unused imports and undefined type variables (_VT and _D) make the snippet harder to interpret. Nesting: Minimal nesting makes control flow easy to follow; the else after a return is unnecessary. Clarity of intent: Docstrings and comments explain attribute-based lookup, but misleading parameter names (map, age, nextKey, invoice) and inconsistent overload signatures obscure emit's purpose. Using __dict__ rather than dictionary entries is surprising for a dict subclass. Code length: Mostly concise, with some unnecessary imports and whitespace. Action granularity: Each line generally performs one clear action. Reading flow: Conventional method ordering and formatting help, but inconsistent naming and unexplained typing details interrupt an otherwise straightforward flow.

Run 3

Code Structure: The class is logically organized into initialization, representation, lookup, and overload methods, but unused imports and undefined type variables distract. Nesting: Minimal nesting makes control flow easy to follow; the else after raise could be omitted. Clarity of intent: Lookup behavior is understandable, but inconsistent parameter names (age, context, map, nextKey, invoice) obscure emit's purpose, and accessing __dict__ rather than dictionary entries is surprising. Code length: Mostly concise, with minor unnecessary whitespace and boilerplate. Action granularity: Each statement performs one action, supporting readability. Reading flow: Method ordering and formatting are natural, but inconsistent overload signatures, unexplained type variables, and misleading dictionary semantics interrupt comprehension.