Sample

pyint-299d6f54d0f4-I10

Deterministically remove some optional blank lines and bracketed line breaks

Matched original source

Lines72

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.3210–1; higher is more readable
Mi0.4270–1; higher is more readable
LLOC35Logical lines; fewer is more readable
DeepSeek V4 Pro14.670–20; mean of three runs
GPT-6.1 Sol16.670–20; mean of three runs
BTTF0.4990–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.72+28.8
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.716−7.074

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.73−1.548
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.986−1.417
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.119.973+1.131
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.46−0.635
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.71.793+0.594
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.748 (log-odds).
Score = sigmoid(-0.748) = 0.321.

Score0.427
Score35
Run 1

The class has a clear purpose and mostly logical organization, with a docstring that explains case-insensitive behavior and key storage. However, readability is undermined by inconsistent formatting: missing blank lines between methods, inconsistent indentation/alignment (e.g., in __init__ and __eq__), and trailing whitespace in function signatures. The code is not deeply nested and methods are mostly short, which helps, but occasional confusing constructs like 'type: ignore[reportUnknownArgumentType]' add noise without context. Action granularity is mostly fine, though generator expressions in lower_items are slightly dense. Overall, the code is understandable but the formatting inconsistencies disrupt reading flow and make it feel less polished than it should be.

Run 2

The code is generally well-structured with clear intent, especially in the docstring and method comments. However, several issues reduce readability: inconsistent spacing, a misplaced closing parenthesis in __init__, and multiple methods crammed together without blank lines (e.g., lower_items, __eq__, copy, __repr__). Some lines are too long and combine multiple actions. Nesting is low, which is good, but formatting inconsistencies and minor layout problems disrupt reading flow. Overall, the logic is understandable but the presentation could be cleaner.

Run 3

The code is generally well-structured with clear class and method separation. It uses type hints, docstrings, and comments effectively. However, readability is reduced by minor issues: the `__init__` signature has awkward spacing before `)`, multiple methods are packed together without blank lines (e.g., `lower_items`, `__eq__`, `copy`, `__repr__`), and the generator expressions in `__iter__` and `lower_items` are compact but dense. The `__eq__` method includes a type-ignore comment that adds noise. Overall, intent is clear and the logic is flat, but formatting inconsistencies and slight verbosity in some operations lower the score.

Run 1

Code Structure: The class is logically organized into small mapping methods, though missing blank lines between some methods and imports reduce visual separation. Nesting: Control flow is shallow and easy to follow. Clarity of intent: The detailed docstring, conventional method names, and comments explain case-insensitive lookup and preservation of original keys. However, _VT is never defined despite importing TypeVar, and names such as keyval are less descriptive. Code length: Implementation methods are concise; documentation is lengthy but useful. Action granularity: Statements generally perform one action per line, with straightforward generator expressions. Reading flow: Methods follow a natural progression from initialization through mapping operations to equality and representation. Awkward constructor formatting and a long type-ignore line interrupt otherwise smooth reading.

Run 2

Code Structure: Logically organized into small mapping methods, though missing blank lines between some methods and before the class weaken visual separation. Nesting: Very shallow, with only simple conditionals. Clarity of intent: The class docstring, type annotations, and storage comment clearly explain case-insensitive behavior; however, _VT is not defined in the snippet, and unused imports introduce distraction. Code length: Implementation is concise, although the docstring is relatively long and references legacy iteration methods. Action granularity: Statements generally perform one action per line; generator expressions are compact and understandable. Reading flow: Methods follow a natural progression from initialization through mapping operations, equality, copying, and representation. Awkward constructor formatting and the long annotated assignment in __eq__ slightly interrupt readability.

Run 3

Code Structure: Well organized into a focused mapping class with small, logically grouped methods, though missing blank lines weaken separation. Nesting: Very shallow, with only simple conditionals. Clarity of intent: The class docstring, descriptive method names, annotations, and storage comment clearly explain case-insensitive behavior. However, _VT is referenced without a visible definition, some imports are unused, and tuple indexing slightly obscures the internal representation. Code length: Implementation is concise; the lengthy docstring provides useful context but references legacy methods. Action granularity: Statements generally perform one action per line, with compact generator expressions remaining readable. Reading flow: Follows conventional mapping operations naturally, but the malformed-looking constructor spacing, long equality annotation line, and inconsistent method spacing interrupt the flow.