Sample

pyint-c4b5ddebba33-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines49

Scores

MethodScoreScale
Posnett0.0010–1; higher is more readable
Dorn0.7520–1; higher is more readable
Mi0.6290–1; higher is more readable
LLOC27Logical lines; fewer is more readable
DeepSeek V4 Pro11.670–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.5930–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, cal): import inspect try: self.sig = inspect.signature(cal) except (ValueError, TypeError): # inspect failed self.sig = None def get(self): """ Return the type annotation of the first argument if it's not empty. """ import inspect if not self.sig: return None par = list(self.sig.parameters.values()) if par and par[0].annotation is not inspect.Parameter.empty: return par[0].annotation return None def get2(self): """ Return the return type if it's not empty. """ 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.896.111−29.572
Source linesThe number of non-empty source lines.49+19.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.177−6.266

Intercept 8.87 + feature contributions = -7.367 (log-odds).
Score = sigmoid(-7.367) = 0.001.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.49−0.699
Indentation frequencyHow rapidly indentation changes from line to line.40+0.646
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.40−0.497
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.94+0.491
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.052+0.44
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.73.48+0.381
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.48.882+0.273

Intercept 0.07 + feature contributions = 1.107 (log-odds).
Score = sigmoid(1.107) = 0.752.

Score0.629
Score27
Run 1

The code is moderately readable but has several issues. The class has a clear single responsibility, but method names like get() and get2() are ambiguous and poorly communicate their intent. The conditional logic in get2() is unnecessarily broken across multiple lines, creating awkward nesting that hurts reading flow. Imports are inconsistent: some at module level, others inside methods without explanation. The unused imports (Mapping, Sequence, _GenericAlias) are distracting. The action granularity is mostly good, with one operation per line, but the variable name 'cal' instead of 'callable' reduces clarity, and 'par' instead of 'parameter' or 'first_parameter' is too abbreviated. The docstrings help but don't compensate for unclear naming. Overall, the code structure is logical but execution lacks polish and clarity.

Run 2

The code demonstrates moderate readability with clear class and method naming, helpful docstrings, and a logical structure. It uses `__slots__`, handles exceptions, and imports only what's needed locally. However, issues reduce clarity: inconsistent method names (`get` vs `get2`) lack descriptive intent; some lines are vertically verbose (e.g., the condition in `get2`); the class-level imports are not consistently placed; and the presence of unused imports (`sys`, `threading`, `Mapping`, `Sequence`, `Callable`, `_GenericAlias`) creates noise. Nesting is minimal, and action granularity is acceptable, but the overall reading flow is disrupted by these inconsistencies. The code could be more concise and self-explanatory with better naming and removal of dead imports.

Run 3

The code is generally readable with clear class and method names, logical separation of concerns, and straightforward logic. Each method performs a single purpose, and nesting is minimal. However, some aspects reduce readability: the use of `cal` instead of a more descriptive name like `callable_obj`, the `__slots__` declaration is understandable but not immediately obvious, and the conditional in `get2` is split across multiple lines unnecessarily, which slightly disrupts flow. The imports inside methods are a bit unconventional; moving `import inspect` to the top would improve consistency. Docstrings are helpful, though brief. Overall, the code is clear and maintainable but could be improved with minor naming and import adjustments.

Run 1

1. Code Structure: The class cleanly separates signature extraction from argument and return annotation retrieval, though several imports are unused. 2. Nesting: Shallow conditionals and early returns keep control flow easy to follow. 3. Clarity of intent: Docstrings explain the purpose, but names such as cal, par, get, and especially get2 are vague; descriptive method names would improve readability. 4. Code length: Compact overall, although repeated local inspect imports and converting parameters to a list add minor verbosity. 5. Action granularity: Each statement performs a single clear action, with no compressed multi-action lines. 6. Reading flow: Initialization followed by retrieval methods creates a natural progression, but repeated imports and the awkwardly wrapped return-annotation condition slightly interrupt the flow.

Run 2

Code Structure: The class logically groups signature extraction and annotation access, though unused module imports and repeated local imports add clutter. Nesting: Control flow is shallow, with simple conditionals and early returns. Clarity of intent: Docstrings explain the methods, but names such as cal, par, get, and especially get2 are vague; descriptive names would improve readability. Code length: The implementation is compact without being excessively terse, although repeated imports and converting parameters to a list introduce minor overhead in presentation. Action granularity: Statements generally perform one action per line, making execution easy to follow. Reading flow: Initialization followed by argument and return annotation retrieval creates a natural progression; the multiline return-annotation condition slightly interrupts an otherwise straightforward flow.

Run 3

Code Structure: The class logically groups signature extraction and annotation access, although repeated local imports and unused module imports add clutter. Nesting: Shallow conditionals and early returns keep control flow easy to follow. Clarity of intent: Docstrings explain the methods, but names such as cal, par, get, and especially get2 are vague; descriptive parameter and method names would improve readability. Code length: The implementation is compact, though repeated imports and converting parameters to a list introduce minor overhead in reading. Action granularity: Each statement performs a single clear action, with no compressed multi-action lines. Reading flow: Initialization followed by argument and return annotation retrieval forms a natural sequence; the multiline condition is readable but slightly verbose. Overall, the code is well organized and approachable, with naming and import cleanup as its main readability opportunities.