Sample

pyint-cf48c3dfc94e-I06

Invert eligible conditions and exchange their branches

Matched original source

Lines53

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7260–1; higher is more readable
Mi0.5720–1; higher is more readable
LLOC29Logical lines; fewer is more readable
DeepSeek V4 Pro4.330–20; mean of three runs
GPT-6.1 Sol130–20; mean of three runs
BTTF0.5430–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 (not self.sig): pass else: return None params = list(self.sig.parameters.values()) if not (params and params[0].annotation is not inspect.Parameter.empty): pass else: return params[0].annotation return None def get_return_type(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.974.093−32.145
Source linesThe number of non-empty source lines.53+21.2
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.151−6.227

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.52−0.805
Indentation frequencyHow rapidly indentation changes from line to line.44+0.785
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.44−0.589
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.78.537+0.463
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.051+0.442
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.52.901+0.33
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.79.963+0.278

Intercept 0.07 + feature contributions = 0.974 (log-odds).
Score = sigmoid(0.974) = 0.726.

Score0.572
Score29
Run 1

The code has several readability problems. The `get_first_param_type` method uses convoluted double-negative logic (`if not (not self.sig)`) and redundant pass/else branches that invert natural reading flow — the condition should be `if not self.sig: return None`. Unnecessary re-imports of `inspect` inside methods reduce clarity. Some imports at module level are unused or oddly placed (`Mapping`, `Sequence`, `_GenericAlias`). The class name and docstrings are somewhat helpful, but the mixed structure, redundant `pass` statements, and inverted conditionals make the code needlessly verbose and confusing. While the overall intent is decipherable, the poor control-flow clarity, disorganized imports, and bloated logic lower readability significantly.

Run 2

The code has severe readability issues. The use of inverted conditional logic with empty pass branches and else branches for actual work (e.g., 'if not (not self.sig): pass else: return None') is highly confusing and obscures intent. Nesting is shallow, but the flow is unnatural and forces readers to mentally invert conditions. The extraction logic is split awkwardly across methods with redundant imports and unnecessary double negatives. Action granularity is acceptable, but clarity of intent is undermined by convoluted boolean expressions. The class structure is logical but implementation details are tangled. Overall, the code is difficult to follow due to inverted logic and unnatural control flow.

Run 3

The code has severe readability issues. The get_first_param_type method uses inverted, confusing logic: `if not (not self.sig)` with an empty pass block and an else clause that returns a value, obscuring the actual intent. This creates unnecessary nesting and pushes the main logic into an else branch, disrupting natural reading flow. There are redundant None checks after conditional returns. The class structure itself is reasonable, but the method implementations are convoluted. Imports are scattered (inspect imported inside methods rather than at module level), and there are unused imports. The method names are clear, but the implementation undermines clarity. The code mixes action granularity badly—multiple logical checks are crammed into awkward conditionals. Overall, the code is hard to follow and requires mental backtracking to understand simple conditional logic, making it significantly unreadable.

Run 1

Code Structure: The class logically groups annotation extraction and accessor methods, though unused imports add clutter. Nesting: Overall nesting is shallow, but unnecessary if/else branches with pass complicate the first-parameter accessor. Clarity of intent: Method names and docstrings clearly explain the purpose; double negation and inverted conditions obscure otherwise simple checks. Code length: Mostly concise, but redundant branches, repeated local imports, and converting all parameters to a list introduce avoidable verbosity. Action granularity: Statements generally perform one action per line, making individual operations easy to follow. Reading flow: Initialization and accessors follow a natural order, and get_return_type reads cleanly. However, get_first_param_type interrupts that flow with awkward conditional logic instead of straightforward early returns.

Run 2

Code Structure: The class logically groups signature extraction and annotation access, though unused imports add clutter. Nesting: Nesting is shallow, but unnecessary if/pass/else branches complicate otherwise simple checks. Clarity of intent: Method names and docstrings clearly describe the purpose; double negation in get_first_param_type obscures its logic. Code length: Generally compact, but redundant branches and repeated local imports make it longer than necessary. Action granularity: Each statement performs a single action, making individual steps easy to identify. Reading flow: Initialization followed by accessor methods is natural, and get_return_type reads cleanly. However, get_first_param_type interrupts that flow with inverted conditions and no-op branches instead of straightforward early returns.

Run 3

Code Structure: The class logically groups signature extraction and annotation access, though unused imports add clutter. Nesting: Control flow is shallow, but redundant if/pass/else branches make the first-parameter method harder to follow. Clarity of intent: Method names and docstrings clearly explain the purpose; double negation and inverted conditions obscure otherwise simple checks. Code length: Relatively short, but repeated local imports and unnecessary branches could be simplified. Action granularity: Statements generally perform one action per line, making individual operations easy to identify. Reading flow: Initialization and return-type extraction read naturally, while get_first_param_type interrupts the flow with awkward conditional logic.