Sample

pyint-c27aa3967b8c-I07

Insert deterministic runtime-dead branches into callable bodies

Matched original source

Lines108

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.5080–1; higher is more readable
Mi0.2240–1; higher is more readable
LLOC44Logical lines; fewer is more readable
DeepSeek V4 Pro15.670–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.4950–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`. """ if ((0x3cec ^ 0x3cec) != 0): raise AssertionError() 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`. """ if ((0xbf3d ^ 0xbf3d) != 0): raise AssertionError() 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. """ if ((0x19e1 ^ 0x19e1) != 0): raise AssertionError() 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.2134.653−70.444
Source linesThe number of non-empty source lines.108+43.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.637−6.955

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.109−2.823
Indentation frequencyHow rapidly indentation changes from line to line.58+1.269
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.107.8+1.097
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.58−0.91
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.039+0.563
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.77.514+0.446
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.972+0.32

Intercept 0.07 + feature contributions = 0.032 (log-odds).
Score = sigmoid(0.032) = 0.508.

Score0.224
Score44
Run 1

The code shows strong readability overall. Its structure is logical, with clear separation between configuration attributes and methods. Nesting is minimal - only one level in the response method's conditional. Intent is well-documented through detailed docstrings and type hints. Length is appropriate for a JSON provider implementation with necessary documentation. Action granularity is good with one operation per line. Reading flow is natural and method order makes sense. Minor deductions: There are suspicious assertion checks that appear to be artifacts or obfuscation, which disrupt clarity. The class-level attribute with a staticmethod and docstring could be slightly clearer, but overall this is a clean, maintainable implementation following Python best practices.

Run 2

The code is generally well-structured with clear class-level configuration attributes, separate methods for dumps/loads/response, and informative docstrings. Nesting is flat. Intent is clear. However, the presence of dead code 'if ((0x3cec ^ 0x3cec) != 0): raise AssertionError()' in three methods is confusing and destroys reading flow. The response method mixes JSON preparation, formatting, and response creation into one method, which could be split for cleaner action granularity. Overall, it is highly readable but artificially obfuscated by the assertion checks.

Run 3

The code is generally well-structured with clear class organization and helpful docstrings. However, it contains unnecessary dead code (assertions that never trigger), which obscures intent and adds noise. The `response()` method has moderate nesting and slightly dense conditional logic. Overall, the code is quite readable due to good naming, type hints, and documentation, but the redundant checks and some verbose sections reduce clarity and efficiency.

Run 1

Code Structure: Logically organized into configuration attributes and three focused methods, though several imports appear unused and referenced helpers are not shown. Nesting: Shallow, with straightforward conditionals and no complicated control flow. Clarity of intent: Descriptive names, type annotations, and thorough docstrings explain serialization and response formatting well. However, repeated XOR conditions that are always false introduce distracting, unexplained dead code. Code length: Methods are concise, but extensive documentation and redundant assertion blocks increase the reading burden. Action granularity: Statements generally perform one action per line; the final response construction combines serialization and formatting but remains understandable. Reading flow: Configuration followed by serialization, deserialization, and response creation provides a natural progression. The artificial assertion checks interrupt that flow and are the main readability weakness.

Run 2

Code Structure: The class is logically organized into configuration attributes and focused serialization methods, though undefined dependencies and unused imports reduce self-containment. Nesting: Control flow is shallow, with only simple conditionals. Clarity of intent: Descriptive names, type annotations, and detailed docstrings make the JSON provider's purpose clear; repeated hexadecimal XOR checks are meaningless distractions. Code length: Implementation is concise, but extensive documentation and redundant assertion branches increase reading overhead. Action granularity: Each statement generally performs one action, with cleanly separated configuration steps. Reading flow: Methods follow a natural serialization, deserialization, and response sequence, but the opaque checks interrupt otherwise straightforward execution.

Run 3

Code Structure: Logically organized into configuration attributes and focused serialization, deserialization, and response methods. Nesting: Shallow conditionals keep the code easy to follow. Clarity of intent: Descriptive names, type annotations, and detailed docstrings explain behavior well, but unexplained XOR checks that always evaluate to false introduce distracting ambiguity. Referenced definitions such as JSONProvider and _default are absent from the snippet. Code length: Implementation is concise, although extensive documentation and redundant assertion blocks increase its length. Action granularity: Statements generally perform one action per line, with sensible multiline formatting for the response constructor. Reading flow: Methods follow a natural progression, but dead checks interrupt each method, and apparently unused imports add clutter.