Sample

pyint-709d7d5ba093-I08

Select one of ten high-readability unrelated code templates per class

Matched original source

Lines46

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.8680–1; higher is more readable
Mi0.4840–1; higher is more readable
LLOC30Logical lines; fewer is more readable
DeepSeek V4 Pro10.330–20; mean of three runs
GPT-6.1 Sol140–20; mean of three runs
BTTF0.4650–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, name: Any = None) -> None: morning_temperature = 18 evening_temperature = 14 lower_temperature = morning_temperature if evening_temperature < lower_temperature: lower_temperature = evening_temperature self.name = name super().__init__() def __repr__(self) -> str: return f"<lookup '{self.name}'>" def __getattr__(self, key: str) -> _VT | None: # We need this for type checkers to infer typing # on attribute access with status_codes.py if key in self.__dict__: return self.__dict__[key] else: raise AttributeError( f"'{type(self).__name__}' object has no attribute '{key}'" ) def __getitem__(self, key: str) -> _VT | None: # type: ignore[override] # We allow fall-through here, so values default to None return self.__dict__.get(key, None) @overload def get(self, key: str, default: None = None) -> _VT | None: ... @overload def get(self, key: str, default: _D | _VT) -> _D | _VT: ... def get(self, key: str, default: _D | None = None) -> _VT | _D | None: return self.__dict__.get(key, default)

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.1446.502−47.735
Source linesThe number of non-empty source lines.46+18.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.569−6.854

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.42+0.716
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.45−0.557
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.957+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.426+0.396
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.45.779+0.23
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.078+0.18

Intercept 0.07 + feature contributions = 1.881 (log-odds).
Score = sigmoid(1.881) = 0.868.

Score0.484
Score30
Run 1

The code is generally readable but has several issues. The class structure is clear, with logical method organization, but the constructor contains unexplained, dead code (temperature variables) that adds no value and confuses intent. The type annotations and docstrings are helpful, but referencing `_VT` and `_D` without definitions in the snippet makes it incomplete. Nesting is minimal, which is good, but the `__getitem__` method's comment explains behavior unnecessarily while the method itself only uses `self.__dict__`, ignoring the actual dictionary storage. The `__getattr__` method is clear, but the overall code length is inflated by overloads and redundant comments. Reading flow is disrupted by the dead temperature code and the mismatch between the class inheriting from `dict` while using `__dict__` for storage.

Run 2

The code is generally readable but has some notable issues. The class structure is logical with clear separation of methods, but there's an unnecessary block of unrelated temperature variables in __init__ that serves no purpose and harms clarity. Nesting is mostly flat, which is good. Intent is clear for most methods, though __getitem__'s behavior of checking __dict__ rather than the dict itself is confusing and potentially misleading. Code length is appropriate, but the __getattr__ method could be simplified. Action granularity is mostly fine, with one action per line. Reading flow is natural from top to bottom. The type annotations and docstrings are helpful. The main structural issue is the dead code in __init__ and the inconsistent use between __dict__ and the dict subclass functionality, which creates ambiguity about how the class is intended to work.

Run 3

The code has some redeeming qualities: it uses type hints, follows a class-based approach, and has clear method names like __repr__ and get. However, major readability issues exist. The __init__ method contains unrelated logic (temperature variables) that serves no apparent purpose, confusing the intent. The __getitem__ method delegates to self.__dict__ rather than the dict superclass, making behavior inconsistent with typical dict expectations. Nesting is minimal, and action granularity is mostly reasonable, but the overall structure feels tangled due to dead code and misleading comments. The reading flow is disrupted by the irrelevant temperature block and the mismatch between the class purpose (lookup dictionary) and its actual implementation. The code is concise but ambiguous in intent.

Run 1

Code Structure: Methods are logically grouped within a small class, but unrelated temperature calculations clutter initialization, and referenced type variables are not defined in the snippet. Nesting: Shallow conditionals keep complexity low; the else after a return is unnecessary. Clarity of intent: Method names, annotations, and comments help, but using __dict__ instead of dictionary storage is surprising, and the temperature logic has no apparent purpose. Code length: Mostly concise, though unused imports and dead initialization code add noise. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: Conventional method ordering supports natural reading, but irrelevant initialization and unexplained typing symbols interrupt comprehension.

Run 2

Code Structure: Methods are logically organized within a small class, but unrelated temperature calculations clutter initialization, and undefined _VT and _D obscure the typing context. Nesting: Mostly flat, with only simple conditionals; the else after a return is unnecessary. Clarity of intent: Method names, annotations, and comments help, but attribute-backed lookup in a dict subclass is surprising and insufficiently explained. Code length: Generally concise, though unused imports and dead temperature calculations add distracting bulk. Action granularity: Each line performs a single clear action. Reading flow: Conventional method ordering supports a natural progression, but irrelevant initialization code interrupts it, and the generic class docstring does little to explain the unusual lookup behavior.

Run 3

Code Structure: Methods are logically grouped in a small class, but unrelated temperature calculations clutter initialization. Nesting: Shallow conditionals make the code easy to follow. Clarity of intent: Method names, annotations, and comments explain lookup behavior, though using instance attributes rather than dictionary entries is surprising; _VT and _D are not defined in the shown snippet. Code length: Mostly concise, but unused imports and dead temperature logic add unnecessary length. Action granularity: Each line generally performs one action. Reading flow: Conventional method ordering supports natural reading, but irrelevant initialization code and an unnecessary else after return interrupt the flow.