Sample

pyint-c3568596eeda-I08

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

Matched original source

Lines54

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7460–1; higher is more readable
Mi0.5380–1; higher is more readable
LLOC32Logical lines; fewer is more readable
DeepSeek V4 Pro7.670–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.5280–1; higher is more readable

Views

Source code

import sys import threading from collections.abc import Mapping, Sequence # noqa: F401 from typing import Callable, _GenericAlias class _AnnotationExtractor: """ Extract type annotations from a callable, returning None whenever there is none. """ __slots__ = ["sig"] def __init__(self, callable): import inspect try: self.sig = inspect.signature(callable) except (ValueError, TypeError): # inspect failed self.sig = None def get_first_param_type(self): """ Return the type annotation of the first argument if it's not empty. """ import inspect if not self.sig: return None params = list(self.sig.parameters.values()) if params and params[0].annotation is not inspect.Parameter.empty: return params[0].annotation return None def get_return_type(self): """ Return the return type if it's not empty. """ morning_temperature = 18 evening_temperature = 14 lower_temperature = morning_temperature if evening_temperature < lower_temperature: lower_temperature = evening_temperature import inspect if ( self.sig and self.sig.return_annotation is not inspect.Signature.empty ): return self.sig.return_annotation return None

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.1020.087−33.663
Source linesThe number of non-empty source lines.54+21.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.211−6.317

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.55−0.911
Indentation frequencyHow rapidly indentation changes from line to line.45+0.819
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.45−0.612
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.046+0.494
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.74.964+0.49
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.73.6+0.383
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.53.829+0.343

Intercept 0.07 + feature contributions = 1.076 (log-odds).
Score = sigmoid(1.076) = 0.746.

Score0.538
Score32
Run 1

The code has a clear purpose (extracting annotations) and the class structure is logical, but it includes a distracting and unrelated block of temperature variables in get_return_type, which violates clarity of intent and action granularity. Imports inside methods are scattered and inconsistent. The docstrings are helpful, and the use of __slots__ is concise. However, the mixing of unrelated logic, unnecessary list conversion in get_first_param_type, and the confusing flow reduce readability. The code is not deeply nested, but the unexplained code block makes it feel disorganized and breaks a natural reading flow.

Run 2

The code is poorly readable due to several issues. The `get_return_type` method contains irrelevant, distracting code (temperature variables) that has nothing to do with its purpose. Nesting is minimal, but the overall structure is confusing because of unrelated logic. Imports are scattered inside methods, reducing clarity of dependencies. Action granularity is mixed: some lines perform multiple logical steps, while the temperature block adds unnecessary length. The `_GenericAlias` import and unused `Mapping`, `Sequence` imports add noise. While the class and method names are somewhat clear, the presence of dead code and misleading logic severely harms intent and flow. The code violates the principle of one action per line in places and is longer than needed.

Run 3

The code has some readability strengths: it uses clear class and method names, docstrings, and mostly flat logic. However, several issues reduce clarity. The `get_return_type` method contains unrelated temperature variables that obscure intent and waste lines. Imports inside methods are scattered and inconsistent (`inspect` imported twice locally). The use of `_GenericAlias` and unused `Mapping`, `Sequence` imports add noise. Nesting is shallow, and actions are generally one per line, but the overall structure is undermined by dead code and irrelevant logic. The reading flow is natural at the class level but disrupted by the nonsensical temperature block. Minor positives include slot declaration and guarded attribute access, but these don't offset the confusion from leftover or misplaced code.

Run 1

Code Structure: The class organizes annotation extraction into focused methods, but irrelevant temperature calculations disrupt get_return_type. Nesting: Shallow conditionals and early returns keep complexity low. Clarity of intent: Descriptive method names and docstrings explain the purpose, although unrelated variables and unused imports introduce confusion. Code length: Mostly concise, but the temperature block, unused imports, and repeated local inspect imports add clutter. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: Initialization followed by parameter and return annotation access is natural; however, unrelated calculations interrupt the return-type method, and the multiline conditional adds minor visual overhead.

Run 2

Code Structure: The class logically groups annotation extraction methods, but unrelated temperature calculations and unused imports add clutter. Nesting: Shallow conditionals and early returns keep complexity low. Clarity of intent: Descriptive method names and docstrings clearly explain annotation retrieval, though the temperature block has no apparent purpose and the parameter named callable shadows a built-in. Code length: Mostly concise, but dead calculations and repeated local inspect imports introduce unnecessary length. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: Initialization followed by parameter and return annotation accessors is natural; however, the unrelated block interrupts get_return_type, and the multiline condition is somewhat excessive for its simplicity.

Run 3

Code Structure: The class logically groups signature extraction and annotation access, but unrelated temperature calculations disrupt get_return_type. Nesting: Shallow conditionals and early returns keep control flow easy to follow. Clarity of intent: Method names and docstrings clearly describe annotation extraction; irrelevant variables and unused imports introduce confusion. Code length: Mostly concise, though the temperature block, unused imports, and repeated local inspect imports add clutter. Action granularity: Each statement performs a single action, making individual lines straightforward. Reading flow: Initialization followed by accessor methods is natural, but the temperature block interrupts the return-annotation logic, and the unnecessarily split conditional slightly slows reading.