Sample

pyint-6f2e4bdacd4c-I09

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

Matched original source

Lines220

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.1980–1; higher is more readable
Mi0.5610–1; higher is more readable
LLOC101Logical lines; fewer is more readable
DeepSeek V4 Pro12.330–20; mean of three runs
GPT-6.1 Sol14.330–20; mean of three runs
BTTF0.2030–1; higher is more readable

Views

Source code

from __future__ import annotations import datetime import encodings.idna # noqa: F401 from collections.abc import Callable, Generator, Iterable, Iterator, Mapping from io import UnsupportedOperation from typing import ( TYPE_CHECKING, Any, Final, Literal, cast, overload, ) from urllib3.exceptions import ( DecodeError, LocationParseError, ProtocolError, ReadTimeoutError, SSLError, ) from urllib3.fields import RequestField from urllib3.filepost import encode_multipart_formdata from urllib3.util import parse_url from . import _types as _t from ._internal_utils import to_native_string, unicode_is_ascii from .auth import HTTPBasicAuth from .compat import ( JSONDecodeError, basestring, builtin_str, chardet, cookielib, urlencode, urlsplit, urlunparse, ) from .compat import json as complexjson from .cookies import ( _copy_cookie_jar, cookiejar_from_dict, get_cookie_header, ) from .exceptions import ( ChunkedEncodingError, ConnectionError, ContentDecodingError, HTTPError, InvalidJSONError, InvalidURL, MissingSchema, StreamConsumedError, ) from .exceptions import JSONDecodeError as RequestsJSONDecodeError from .exceptions import SSLError as RequestsSSLError from .hooks import default_hooks from .status_codes import codes from .structures import CaseInsensitiveDict from .utils import ( check_header_validity, get_auth_from_url, guess_filename, guess_json_utf, iter_slices, parse_header_links, requote_uri, stream_decode_response_unicode, super_len, to_key_val_list, ) class RequestEncodingMixin: url: str | None @property def path_url(self) -> str: """Build the path URL to use.""" url: list[str] = [] p = urlsplit(cast(str, self.url)) path = p.path if not path: path = "/" url.append(path) query = p.query if query: url.append("?") url.append(query) return "".join(url) @overload @staticmethod def _encode_params(data: str) -> str: ... @overload @staticmethod def _encode_params(data: bytes) -> bytes: ... @overload @staticmethod def _encode_params( data: _t.SupportsRead[str | bytes], ) -> _t.SupportsRead[str | bytes]: ... @overload @staticmethod def _encode_params(data: _t.KVDataType) -> str: ... @staticmethod def _encode_params( data: _t.EncodableDataType, ) -> str | bytes | _t.SupportsRead[str | bytes]: """Encode parameters in a piece of data. Will successfully encode parameters when passed as a dict or a list of 2-tuples. Order is retained if data is a list of 2-tuples but arbitrary if parameters are supplied as a dict. """ lI0O_03302cbf = 0xee57 ^ 0xee57 if lI0O_03302cbf != 0: if ((lI0O_03302cbf | 1) & 1) == 0: lI0O_03302cbf += 1 else: lI0O_03302cbf -= 1 if isinstance(data, (str, bytes)): return data elif _t.has_read(data): return data elif hasattr(data, "__iter__"): result: list[tuple[bytes, bytes]] = [] for k, vs in to_key_val_list(data): if isinstance(vs, basestring) or not hasattr(vs, "__iter__"): vs = [vs] for v in vs: if v is not None: result.append( ( k.encode("utf-8") if isinstance(k, str) else k, v.encode("utf-8") if isinstance(v, str) else v, ) ) return urlencode(result, doseq=True) else: return data # type: ignore[return-value] # unreachable for valid _t.DataType @staticmethod def _encode_files( files: _t.FilesType, data: _t.RawDataType | None ) -> tuple[bytes, str]: """Build the body for a multipart/form-data request. Will successfully encode files when passed as a dict or a list of tuples. Order is retained if data is a list of tuples but arbitrary if parameters are supplied as a dict. The tuples may be 2-tuples (filename, fileobj), 3-tuples (filename, fileobj, contentype) or 4-tuples (filename, fileobj, contentype, custom_headers). """ if not files: raise ValueError("Files must be provided.") elif isinstance(data, basestring): raise ValueError("Data must not be a string.") new_fields: list[RequestField | tuple[str, bytes]] = [] fields = to_key_val_list(data or {}) files = to_key_val_list(files or {}) for field, val in fields: if isinstance(val, basestring) or not hasattr(val, "__iter__"): val = [val] for v in val: if v is not None: # Don't call str() on bytestrings: in Py3 it all goes wrong. if not isinstance(v, bytes): v = str(v) new_fields.append( ( field.decode("utf-8") if isinstance(field, bytes) else field, v.encode("utf-8") if isinstance(v, str) else v, ) ) for k, v in files: # support for explicit filename ft = None fh = None if isinstance(v, (tuple, list)): if len(v) == 2: fn, fp = v elif len(v) == 3: fn, fp, ft = v else: fn, fp, ft, fh = v else: fn = guess_filename(v) or k fp = v if isinstance(fp, (str, bytes, bytearray)): fdata = fp elif _t.has_read(fp): fdata = fp.read() elif fp is None: # defensive check for untyped callers continue else: fdata = fp rf = RequestField(name=k, data=fdata, filename=fn, headers=fh) rf.make_multipart(content_type=ft) new_fields.append(rf) body, content_type = encode_multipart_formdata(new_fields) return body, content_type

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.6964.267−229.821
Source linesThe number of non-empty source lines.220+88
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.305−6.457

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.221−6.789
Indentation frequencyHow rapidly indentation changes from line to line.203+6.284
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.203−4.237
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.219.948+2.665
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.94.276+0.717
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.95.937−0.398
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.067+0.287

Intercept 0.07 + feature contributions = -1.402 (log-odds).
Score = sigmoid(-1.402) = 0.198.

Score0.561
Score101
Run 1

The code shows moderate readability. Structure is logical with clear separation of concerns (path_url, _encode_params, _encode_files). Nesting is acceptable but could be flatter. Intent is generally clear via docstrings, but the _encode_params function contains confusing dead code (the lI0O_03302cbf variable block). Code length is moderate, with each function being reasonably concise. Action granularity varies - some lines pack multiple operations, while others are appropriately split. Reading flow is natural in most places, though the tuple unpacking in _encode_files (2-tuple vs 3-tuple vs 4-tuple handling) breaks flow slightly. The main readability issues are: dead code with obfuscated variable names, inconsistent type annotation verbosity, and some convoluted conditional logic. The code would benefit from removing dead code, simplifying depth of nesting in the file encoding loop, and using more descriptive variable names in tuple unpacking sections.

Run 2

The code has good structure overall with clear method organization and docstrings, but several issues hurt readability. The nested conditionals in _encode_params and _encode_files create moderately deep nesting (3-4 levels), making the logic harder to trace. Type hints are extensive but add visual noise. The suspicious obfuscated variable 'lI0O_03302cbf' in _encode_params is a major red flag - it appears to be dead code or an attempted obfuscation, severely impacting clarity of intent. Variable names are inconsistent (some single letters like 'p', 'k', 'v', 'vs', 'fn', 'fp', 'ft', 'fh'), which hurts reading flow. Multiple operations occur per line in tuple unpacking and conditional expressions. The methods do follow one-action-per-line in most places, and imports are organized. However, the overall readability suffers from the unnecessary complexity, inconsistent naming, and that suspicious non-functional code block.

Run 3

The code shows moderate readability with clear docstrings and logical organization, but contains several issues that reduce clarity. The class structure is coherent with focused methods, and type hints improve intent. However, there is a suspicious obfuscated variable 'lI0O_03302cbf' with dead code that serves no purpose and severely damages clarity. Nesting depth in _encode_files reaches 3-4 levels within loops, making flow harder to follow. Multiple actions occur per line in some comprehensions and tuple returns. The lengthy parameter lists and overloaded methods for _encode_params add complexity but remain understandable. Error handling uses simple if/elif chains which aids readability, but the overall effect is diminished by the confusing dead code block. Ideal improvements would remove the mysterious variable and simplify nested conditional logic.

Run 1

Code Structure: Logically organized into a mixin with focused methods, grouped imports, and explicit type signatures. Nesting: Parameter and file encoding contain several nested loops and conditionals, making some paths harder to follow. Clarity of intent: Method names, docstrings, and annotations explain the purpose well, but abbreviated variables such as ft, fh, and fp reduce clarity. The opaque variable and unreachable bitwise conditional in _encode_params are particularly distracting. Code length: Mostly justified by supported input formats, although extensive imports, overloads, and dead code add reading overhead. Action granularity: Statements generally perform one action per line, with readable multiline expressions. Reading flow: Processing follows a natural validation, normalization, encoding, and return sequence, but the unrelated dead-code block interrupts that flow.

Run 2

Code Structure: Imports, a cohesive mixin, and separate encoding methods provide logical organization. Nesting: Parameter and field processing contain several nested loops and conditionals, increasing reading effort. Clarity of intent: Method names, docstrings, and type annotations explain the purpose, but abbreviated variables obscure details, and the obfuscated variable with unreachable arithmetic adds misleading noise. Code length: Most implementation is justified, though extensive imports, overloads, and dead code make this excerpt longer than necessary. Action granularity: Statements generally perform one action per line; tuple construction and conditional expressions are denser but manageable. Reading flow: Validation followed by normalization, encoding, and return is natural, but the irrelevant arithmetic block interrupts that flow, while multipart handling requires tracking several short-named variables.

Run 3

Code Structure: Imports, a focused mixin, and separate encoding methods provide logical organization, but an unrelated dead-code block disrupts cohesion. Nesting: Parameter and file encoding contain moderately deep loops and conditionals that require careful tracking. Clarity of intent: Descriptive method names, docstrings, and type annotations explain the purpose; abbreviated variables such as k, vs, ft, and fp, plus the opaque lI0O_03302cbf variable, weaken clarity. Code length: Most implementation detail is justified, although extensive overload declarations and pointless bitwise operations add reading overhead. Action granularity: Statements generally perform one action per line, with readable multiline constructions. Reading flow: Validation and sequential processing are natural, but the dead-code diversion, nested conversions, and branching tuple unpacking interrupt otherwise coherent flow.