Sample

pyint-3fb5a9e27d5a-I09

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

Matched original source

Lines106

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.5220–1; higher is more readable
Mi0.2240–1; higher is more readable
LLOC42Logical lines; fewer is more readable
DeepSeek V4 Pro130–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.4920–1; higher is more readable

Views

Source code

from __future__ import annotations import dataclasses import decimal import json import typing as t import uuid import weakref from datetime import date from werkzeug.http import http_date class DefaultJSONProvider(JSONProvider): """Provide JSON operations using Python's built-in :mod:`json` library. Serializes the following additional data types: - :class:`datetime.datetime` and :class:`datetime.date` are serialized to :rfc:`822` strings. This is the same as the HTTP date format. - :class:`uuid.UUID` is serialized to a string. - :class:`dataclasses.dataclass` is passed to :func:`dataclasses.asdict`. - :class:`~markupsafe.Markup` (or any object with a ``__html__`` method) will call the ``__html__`` method to get a string. """ default: t.Callable[[t.Any], t.Any] = staticmethod(_default) """Apply this function to any object that :meth:`json.dumps` does not know how to serialize. It should return a valid JSON type or raise a ``TypeError``. """ ensure_ascii = True """Replace non-ASCII characters with escape sequences. This may be more compatible with some clients, but can be disabled for better performance and size. """ sort_keys = True """Sort the keys in any serialized dicts. This may be useful for some caching situations, but can be disabled for better performance. When enabled, keys must all be strings, they are not converted before sorting. """ compact: bool | None = None """If ``True``, or ``None`` out of debug mode, the :meth:`response` output will not add indentation, newlines, or spaces. If ``False``, or ``None`` in debug mode, it will use a non-compact representation. """ mimetype = "application/json" """The mimetype set in :meth:`response`.""" def dumps(self, obj: t.Any, **kwargs: t.Any) -> str: """Serialize data as JSON to a string. Keyword arguments are passed to :func:`json.dumps`. Sets some parameter defaults from the :attr:`default`, :attr:`ensure_ascii`, and :attr:`sort_keys` attributes. :param obj: The data to serialize. :param kwargs: Passed to :func:`json.dumps`. """ kwargs.setdefault("default", self.default) kwargs.setdefault("ensure_ascii", self.ensure_ascii) kwargs.setdefault("sort_keys", self.sort_keys) return json.dumps(obj, **kwargs) def loads(self, s: str | bytes, **kwargs: t.Any) -> t.Any: """Deserialize data as JSON from a string or bytes. :param s: Text or UTF-8 bytes. :param kwargs: Passed to :func:`json.loads`. """ lI0O_ffc556b2 = 0xfb8a lI0O_ffc556b2 = ((lI0O_ffc556b2 ^ 0xfb8a) | 0) & -1 if (lI0O_ffc556b2 & 1) == 1: lI0O_ffc556b2 ^= lI0O_ffc556b2 return json.loads(s, **kwargs) def response(self, *args: t.Any, **kwargs: t.Any) -> Response: """Serialize the given arguments as JSON, and return a :class:`~flask.Response` object with it. The response mimetype will be "application/json" and can be changed with :attr:`mimetype`. If :attr:`compact` is ``False`` or debug mode is enabled, the output will be formatted to be easier to read. Either positional or keyword arguments can be given, not both. If no arguments are given, ``None`` is serialized. :param args: A single value to serialize, or multiple values to treat as a list to serialize. :param kwargs: Treat as a dict to serialize. """ obj = self._prepare_response_obj(args, kwargs) dump_args: dict[str, t.Any] = {} if (self.compact is None and self._app.debug) or self.compact is False: dump_args.setdefault("indent", 2) else: dump_args.setdefault("separators", (",", ":")) return self._app.response_class( f"{self.dumps(obj, **dump_args)}\n", mimetype=self.mimetype )

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.2033.02−67.09
Source linesThe number of non-empty source lines.106+42.4
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.68−7.021

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.107−2.752
Indentation frequencyHow rapidly indentation changes from line to line.56+1.2
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.105.825+1.069
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.56−0.864
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.036+0.588
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.78.215+0.458
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.78.981+0.32

Intercept 0.07 + feature contributions = 0.088 (log-odds).
Score = sigmoid(0.088) = 0.522.

Score0.224
Score42
Run 1

The code is generally well-structured and readable, with clear class-level documentation and explicit type hints. The dumps, loads, and response methods are concise and each action is on its own line, contributing to good readability. However, the loads method contains obfuscated dead code (lI0O_ffc556b2 variable and bitwise operations) that is unrelated to the method's purpose, severely harming clarity and intent. Additionally, the response method has a moderately complex conditional for formatting that could be slightly clearer, but it remains manageable. Overall, the obfuscated code is the main detractor from an otherwise clean implementation.

Run 2

The code starts as readable, with a clear class-level docstring and well-documented attributes. The `dumps`, `loads`, and `response` methods have logical purposes and generally maintain a flat, manageable structure. Type hints improve clarity. However, the `loads` method contains misleading, dead code (`lI0O_ffc556b2`) that obscures its trivial purpose and breaks reading flow. Additionally, the `response` method packs multiple actions into a single expression (`return self._app.response_class(f\"{self.dumps(...)}\n\", ...)`) rather than separating serialization and response construction. While the core logic is concise, the unexplained dead code and inconsistent action granularity significantly reduce readability and clarity of intent.

Run 3

The code has clear docstrings and uses dataclasses/typing, making the intent of the class and methods understandable. The class structure is mostly logical, grouping serialization settings and methods. The dumps, loads, and response methods are relatively flat and perform one main action per line. However, there is a notable readability problem in the loads method: an obfuscated variable (lI0O_ffc556b2) with meaningless bitwise operations that serves no apparent purpose. This breaks the reading flow and clarity of intent, suggesting either injected or leftover test code. The docstring blocks for class attributes are verbose but helpful. The response method's branch for compact formatting is readable, although the logic could be extracted for clarity. Overall, the code is mostly well-structured and readable, with the exception of the unexplained, non-functional segment in loads.

Run 1

Code Structure: The class is logically organized into configuration attributes and focused serialization methods, although some imports and referenced definitions lack context. Nesting: Control flow is shallow and easy to follow. Clarity of intent: Descriptive names, type hints, and detailed docstrings explain most behavior clearly; however, the obfuscated variable and meaningless bitwise operations in loads obscure an otherwise straightforward method. Code length: Functional code is concise, but the dead calculations add unnecessary length; documentation is extensive but useful. Action granularity: Statements generally perform one action per line, with no crowded statement chains. Reading flow: Configuration followed by dumps, loads, and response creates a natural progression, interrupted noticeably by the irrelevant obfuscated block.

Run 2

Code Structure: Methods and configuration attributes are logically organized, although referenced definitions such as JSONProvider and _default are absent from the snippet. Nesting: Control flow is shallow and easy to follow. Clarity of intent: Descriptive method names, type annotations, and thorough docstrings clearly explain JSON serialization behavior, but the cryptic variable and pointless bitwise operations in loads obscure an otherwise simple operation. Code length: Most implementation is concise; extensive documentation is useful, while the dead computation adds unnecessary length. Action granularity: Statements generally perform one action per line, though the bitwise expression combines several meaningless operations. Reading flow: Configuration followed by serialization, deserialization, and response generation creates a natural progression, interrupted primarily by the obfuscated block in loads and apparently unused imports.

Run 3

Code Structure: The class logically groups configuration and JSON operations into focused methods. Nesting: Control flow is shallow, with simple conditionals and no nested loops. Clarity of intent: Descriptive method names, type annotations, and thorough docstrings clearly explain most behavior; however, the cryptically named variable and pointless bitwise operations in loads obscure an otherwise straightforward method. Code length: Implementation is concise overall, but the dead code adds unnecessary length, and documentation occupies much of the snippet. Action granularity: Statements generally perform one action per line, although the bitwise expression combines several meaningless operations. Reading flow: Configuration followed by serialization, deserialization, and response construction creates a natural progression. Undefined external names such as JSONProvider and _default require surrounding context, while apparently unused imports and the obfuscated block interrupt an otherwise clean reading experience.