Sample

pyint-37e475c5a71a-I12

Inline all eligible single-use intermediate local variables

Matched original source

Lines80

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.2970–1; higher is more readable
Mi0.4720–1; higher is more readable
LLOC35Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol17.670–20; mean of three runs
BTTF0.5030–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 CaseInsensitiveDict(MutableMapping[str, _VT], Generic[_VT]): """A case-insensitive ``dict``-like object. Implements all methods and operations of ``MutableMapping`` as well as dict's ``copy``. Also provides ``lower_items``. All keys are expected to be strings. The structure remembers the case of the last key to be set, and ``iter(instance)``, ``keys()``, ``items()``, ``iterkeys()``, and ``iteritems()`` will contain case-sensitive keys. However, querying and contains testing is case insensitive:: cid = CaseInsensitiveDict() cid['Accept'] = 'application/json' cid['aCCEPT'] == 'application/json' # True list(cid) == ['Accept'] # True For example, ``headers['content-encoding']`` will return the value of a ``'Content-Encoding'`` response header, regardless of how the header name was originally stored. If the constructor, ``.update``, or equality comparison operations are given keys that have equal ``.lower()``s, the behavior is undefined. """ _store: OrderedDict[str, tuple[str, _VT]] def __init__( self, data: Mapping[str, _VT] | Iterable[tuple[str, _VT]] | None = None, **kwargs: _VT, ) -> None: self._store = OrderedDict() if data is None: data = {} self.update(data, **kwargs) def __setitem__(self, key: str, value: _VT) -> None: # Use the lowercased key for lookups, but store the actual # key alongside the value. self._store[key.lower()] = (key, value) def __getitem__(self, key: str) -> _VT: return self._store[key.lower()][1] def __delitem__(self, key: str) -> None: del self._store[key.lower()] def __iter__(self) -> Iterator[str]: return (casedkey for casedkey, _ in self._store.values()) def __len__(self) -> int: return len(self._store) def lower_items(self) -> Iterator[tuple[str, _VT]]: """Like iteritems(), but with all lowercase keys.""" return ((lowerkey, keyval[1]) for (lowerkey, keyval) in self._store.items()) def __eq__(self, other: object) -> bool: if isinstance(other, Mapping): other_dict: CaseInsensitiveDict[Any] = CaseInsensitiveDict(other) # type: ignore[reportUnknownArgumentType] else: return NotImplemented # Compare insensitively return dict(self.lower_items()) == dict(other_dict.lower_items()) # Copy is required def copy(self) -> CaseInsensitiveDict[_VT]: return CaseInsensitiveDict(self._store.values()) def __repr__(self) -> str: return str(dict(self.items()))

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.2440.842−80.548
Source linesThe number of non-empty source lines.80+32
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.718−7.077

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.81−1.832
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.119.975−1.416
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.119.988+1.131
Indentation frequencyHow rapidly indentation changes from line to line.50+0.992
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.51−0.749
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.79.802+0.706
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.072+0.238

Intercept 0.07 + feature contributions = -0.86 (log-odds).
Score = sigmoid(-0.86) = 0.297.

Score0.472
Score35
Run 1

The code is highly readable with a clear, logical class structure. It uses type hints, a docstring with examples, and consistent method definitions. Nesting is minimal—only one conditional in __eq__—and actions are generally one per line. The intent of each method is obvious from its name and implementation. The code is concise but not overly terse, and the reading flow follows a natural order (init, item methods, iteration, length, comparison, copy, repr). Minor deductions could be made for the slightly long __eq__ method and the reliance on type: ignore, but they do not harm overall clarity.

Run 2

The code is well-structured with clear class and method organization. It has a helpful docstring with examples, and each method has a single responsibility. Nesting is minimal (one generator expression and one isinstance check). Type hints improve clarity. However, minor readability issues include the dense `__init__` parameter annotation and the `other_dict` assignment with a type-ignore comment, which feels slightly clunky. Generator expressions on one line are acceptable but could be more readable if split. Overall, intent is clear and the flow is natural, but a few lines are long and combine multiple actions.

Run 3

The code is highly readable with clear structure, low nesting, and strong type hints. The class docstring is excellent, providing usage examples and explaining case-insensitive behavior. Methods are concise and focused, using flat, one-action-per-line logic. The use of an OrderedDict to preserve original key casing while enabling case-insensitive lookups is well-commented. Small improvements could include renaming `_store` for clarity or adding brief comments to methods like `__eq__`, but overall the code is clean, idiomatic, and easy to follow.

Run 1

Code Structure: Methods are logically organized around the mapping interface, with storage encapsulated consistently. Nesting: Almost entirely flat, with only simple conditionals. Clarity of intent: The class docstring, type annotations, and storage comment clearly explain case-insensitive lookup while preserving original casing. However, _VT is not defined in the provided snippet, and unused TypeVar and overload imports introduce minor confusion. Code length: Implementations are concise; the extensive docstring is useful but includes legacy method references. Action granularity: Each statement generally performs one clear action, although generator expressions combine iteration and tuple extraction. Reading flow: Initialization, core mapping operations, comparison, copying, and representation follow a natural progression. The long annotated assignment and inline type-ignore comment in __eq__ slightly interrupt readability.

Run 2

Code Structure: Well-organized class with small, focused mapping methods and clear separation of responsibilities. Nesting: Very shallow; only simple conditionals appear. Clarity of intent: The detailed class docstring, type annotations, and storage comment clearly explain case-insensitive lookup and preservation of original key casing. However, _VT is not defined in the provided snippet, and tuple indexing and names such as keyval slightly obscure the internal representation. Code length: Implementation is concise, though the docstring is comparatively long and some imports are unused. Action granularity: Statements generally perform one action per line; generator expressions remain compact and understandable. Reading flow: Methods follow a natural progression from initialization through mapping operations, comparison, copying, and representation. The long type-ignore comment slightly interrupts an otherwise clean flow.

Run 3

Code Structure: Well-organized class with small, focused methods following the mapping interface. Nesting: Minimal, with only simple conditionals and no deeply nested control flow. Clarity of intent: The detailed docstring, type annotations, and storage comment clearly explain case-insensitive lookup while preserving original keys. However, _VT is never defined despite importing TypeVar, and tuple indexing and names such as keyval slightly obscure the storage representation. Code length: The implementation is concise; documentation is lengthy but useful, while the unused overload import adds minor clutter. Action granularity: Each statement generally performs one action, with compact generator expressions remaining understandable. Reading flow: Methods progress naturally from initialization through mapping operations to equality, copying, and representation. The long inline type-ignore comment slightly disrupts an otherwise clean flow.