Sample

pyint-064fb432e990-I02

Shorten method, parameter, and local names without collisions

Matched original source

Lines214

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.2120–1; higher is more readable
Mi0.5610–1; higher is more readable
LLOC96Logical lines; fewer is more readable
DeepSeek V4 Pro5.670–20; mean of three runs
GPT-6.1 Sol120–20; mean of three runs
BTTF0.3740–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 path2(self) -> str: """Build the path URL to use.""" url2: list[str] = [] p2 = urlsplit(cast(str, self.url)) pat = p2.path if not pat: pat = "/" url2.append(pat) que = p2.query if que: url2.append("?") url2.append(que) return "".join(url2) @overload @staticmethod def encode6(dat: str) -> str: ... @overload @staticmethod def encode6(dat2: bytes) -> bytes: ... @overload @staticmethod def encode6( dat3: _t.SupportsRead[str | bytes], ) -> _t.SupportsRead[str | bytes]: ... @overload @staticmethod def encode6(dat4: _t.KVDataType) -> str: ... @staticmethod def encode6( dat5: _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. """ if isinstance(dat5, (str, bytes)): return dat5 elif _t.has_read(dat5): return dat5 elif hasattr(dat5, "__iter__"): res: list[tuple[bytes, bytes]] = [] for k2, vs2 in to_key_val_list(dat5): if isinstance(vs2, basestring) or not hasattr(vs2, "__iter__"): vs2 = [vs2] for v2 in vs2: if v2 is not None: res.append( ( k2.encode("utf-8") if isinstance(k2, str) else k2, v2.encode("utf-8") if isinstance(v2, str) else v2, ) ) return urlencode(res, doseq=True) else: return dat5 # type: ignore[return-value] # unreachable for valid _t.DataType @staticmethod def encode7( fil: _t.FilesType, dat6: _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 fil: raise ValueError("Files must be provided.") elif isinstance(dat6, basestring): raise ValueError("Data must not be a string.") new: list[RequestField | tuple[str, bytes]] = [] fie = to_key_val_list(dat6 or {}) fil = to_key_val_list(fil or {}) for fie2, val2 in fie: if isinstance(val2, basestring) or not hasattr(val2, "__iter__"): val2 = [val2] for v3 in val2: if v3 is not None: # Don't call str() on bytestrings: in Py3 it all goes wrong. if not isinstance(v3, bytes): v3 = str(v3) new.append( ( fie2.decode("utf-8") if isinstance(fie2, bytes) else fie2, v3.encode("utf-8") if isinstance(v3, str) else v3, ) ) for k3, v3 in fil: # support for explicit filename ft2 = None fh2 = None if isinstance(v3, (tuple, list)): if len(v3) == 2: fn2, fp2 = v3 elif len(v3) == 3: fn2, fp2, ft2 = v3 else: fn2, fp2, ft2, fh2 = v3 else: fn2 = guess_filename(v3) or k3 fp2 = v3 if isinstance(fp2, (str, bytes, bytearray)): fda = fp2 elif _t.has_read(fp2): fda = fp2.read() elif fp2 is None: # defensive check for untyped callers continue else: fda = fp2 rf2 = RequestField(name=k3, data=fda, filename=fn2, headers=fh2) rf2.make_multipart(content_type=ft2) new.append(rf2) bod, content = encode_multipart_formdata(new) return bod, content

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.6756.323−222.959
Source linesThe number of non-empty source lines.214+85.6
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.319−6.478

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.215−6.576
Indentation frequencyHow rapidly indentation changes from line to line.197+6.077
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.197−4.1
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.213.969+2.581
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.95.94+0.743
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.958−0.399
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.067+0.289

Intercept 0.07 + feature contributions = -1.314 (log-odds).
Score = sigmoid(-1.314) = 0.212.

Score0.561
Score96
Run 1

The code has some good structure with type hints and docstrings, but readability suffers from poor naming conventions. Variables like 'p2', 'pat', 'que', 'dat5', 'k2', 'vs2', 'v2', 'fil', 'dat6', 'fie', 'fie2', 'val2', 'v3', 'k3', 'fn2', 'fp2', 'ft2', 'fh2', 'fda', 'rf2', 'bod' are cryptic and non-descriptive, making the logic hard to follow. The encode7 method is particularly long (50+ lines) with nested loops and multiple conditional branches (2-3 levels deep), violating single-responsibility and flat nesting principles. Overloads for encode6 add complexity. The encode6 method has reasonable flow but still uses unclear variable names. Multiple abbreviations obscure intent. While imports are organized and there is type annotation, the overall readability is significantly compromised by poor variable naming, excessive abbreviations, lengthy methods, and deep nesting.

Run 2

The code has some redeeming qualities - type hints, docstrings, and a clear import structure - but suffers from severely degraded readability due to poor naming conventions. Variables like 'dat5', 'dat6', 'k2', 'vs2', 'v2', 'v3', 'fn2', 'fp2', 'ft2', 'fh2', 'p2', 'pat', 'que', 'url2', and method names like 'encode6', 'encode7', 'path2' provide no semantic meaning. This obscures the intent of operations throughout the code. While the structure maintains reasonable nesting levels and the logic flows in a somewhat linear fashion, the cryptic naming forces readers to mentally track obscure variable references, essentially requiring a decoder ring. The functional organization is acceptable, but the deliberate obfuscation of names - appearing to be pattern-based renaming - makes this code practically unreadable for maintenance purposes. The docstrings help somewhat, but cannot compensate for semantically void identifiers in core logic. Action granularity is reasonable with one operation per line, and the reading flow is sequential, but the constant mental translation of meaningless names makes comprehension extremely difficult.

Run 3

The code is highly unreadable due to confusing variable naming (dat5, dat6, k2, vs2, v3, fie2, etc.), which obscures intent despite docstrings. Nesting is deep in loops and conditionals, making flow hard to follow. Multiple actions occur per line in several places, reducing clarity. The encode6 method relies on overloads and type ignores that complicate understanding. Structure is cluttered with many imports and mixed responsibilities. While some formatting is consistent, the overall reading flow is poor because identifiers are cryptic and data transformations span many lines without clear intermediate steps.

Run 1

1. Code Structure: Imports, a focused mixin, and separate URL, parameter, and multipart methods provide logical organization. 2. Nesting: Encoding methods contain multiple nested loops and conditionals, making some execution paths harder to follow. 3. Clarity of intent: Docstrings, comments, and type annotations explain the broad purpose, but names such as path2, encode6, dat5, fie2, and fp2 obscure meaning and relationships. 4. Code length: Mostly justified by input handling and typing overloads, although repetitive conversions and verbose formatting increase reading effort. 5. Action granularity: Generally one operation per line, with clear assignments and calls; embedded conditional expressions add some density. 6. Reading flow: Processing proceeds naturally from validation through normalization to encoding, but abbreviated numbered identifiers, reused variables, and nested branches interrupt comprehension.

Run 2

Code Structure: Imports and related encoding methods are logically grouped within a mixin, with distinct responsibilities. Nesting: Parameter and multipart encoding contain several nested loops and conditionals, making some paths harder to follow. Clarity of intent: Docstrings, type annotations, and library calls explain the overall purpose, but cryptic names such as encode6, encode7, dat5, fie2, and ft2 obscure individual operations. Code length: Mostly justified by supported input formats, though extensive imports and overload declarations add visual overhead relative to the shown implementation. Action granularity: Statements generally perform one action per line; tuple unpacking and inline conditional conversions remain reasonably compact. Reading flow: Validation, normalization, encoding, and return steps follow a natural sequence, but reused variables and numbered identifiers require frequent backtracking to track their meanings.

Run 3

Code Structure: Methods logically separate URL construction, parameter encoding, and multipart encoding, with organized imports and useful type annotations. Nesting: Encoding methods contain several nested loops and conditionals, making some paths harder to follow. Clarity of intent: Docstrings explain overall purposes, but names such as path2, encode6, dat5, fie2, and ft2 obscure individual roles. Code length: Mostly justified by supported input formats, though overloads and verbose formatting add reading overhead. Action granularity: Statements generally perform one action per line; tuple unpacking and conditional expressions remain reasonably focused. Reading flow: Validation precedes processing and methods progress toward clear return values, but variable reuse, inconsistent abbreviations, and deeply nested conversions interrupt the flow. Overall, the organization is sound, but poor naming significantly reduces readability.