Sample

pyint-35f82b21c5be-I01

Remove comments and docstrings

Matched original source

Lines137

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.870–1; higher is more readable
Mi0.7290–1; higher is more readable
LLOC58Logical lines; fewer is more readable
DeepSeek V4 Pro160–20; mean of three runs
GPT-6.1 Sol160–20; mean of three runs
BTTF0.4750–1; higher is more readable

Views

Source code

from __future__ import annotations import datetime import encodings.idna 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 Request(RequestHooksMixin): hooks: dict[str, list[_t.HookType]] method: str | None url: _t.UriType | None headers: Mapping[str, str | bytes] files: _t.FilesType data: _t.DataType json: _t.JsonType params: _t.ParamsType auth: _t.AuthType cookies: RequestsCookieJar | CookieJar | dict[str, str] | None def __init__( self, method: str | None = None, url: _t.UriType | None = None, headers: _t.HeadersType = None, files: _t.FilesType = None, data: _t.DataType = None, params: _t.ParamsType = None, auth: _t.AuthType = None, cookies: RequestsCookieJar | CookieJar | dict[str, str] | None = None, hooks: _t.HooksInputType | None = None, json: _t.JsonType = None, ) -> None: data = [] if data is None else data files = [] if files is None else files headers = {} if headers is None else headers params = {} if params is None else params hooks = {} if hooks is None else hooks self.hooks = default_hooks() for k, v in list(hooks.items()): self.register_hook(event=k, hook=v) self.method = method self.url = url self.headers = headers self.files = files self.data = data self.json = json self.params = params self.auth = auth self.cookies = cookies def __repr__(self) -> str: return f"<Request [{self.method}]>" def prepare(self) -> PreparedRequest: p = PreparedRequest() p.prepare( method=self.method, url=self.url, headers=self.headers, files=self.files, data=self.data, json=self.json, params=self.params, auth=self.auth, cookies=self.cookies, hooks=self.hooks, ) return p

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.4410.481−145.546
Source linesThe number of non-empty source lines.137+54.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.535−6.802

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

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.137+4.002
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.138−3.85
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.136.886+1.504
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398
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.77.928+0.365
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.075+0.213

Intercept 0.07 + feature contributions = 1.897 (log-odds).
Score = sigmoid(1.897) = 0.87.

Score0.729
Score58
Run 1

The code is moderately readable. The import section is long but well-organized using parentheses for grouping, though it could be split or reordered for clarity. The class structure is clear with type hints and a straightforward __init__ method. The normalization of None values at the top of __init__ is a good pattern, but the assignment section that follows is repetitive and could be streamlined. The __repr__ and prepare methods are simple and concise. Overall, the code is maintainable but has minor issues with verbosity and repetition, preventing a higher score.

Run 2

The code demonstrates several good practices: logical import organization (standard library, third-party, local), clear class structure with explicit type hints, and a clean __init__ method that normalizes inputs before assignment. The prepare method is concise and delegates appropriately, maintaining single responsibility. Action granularity is consistent, with one action per line throughout. However, the score is reduced by the massive import block spanning 60+ lines, which creates reading friction at the top. The class annotations reference types (RequestHooksMixin, PreparedRequest, RequestsCookieJar, CookieJar) that aren't imported in the shown code, creating ambiguity for readers. The normalization pattern (repeated ternary expressions) is clear but slightly repetitive. Some imports include unused module references (encodings.idna, datetime) that add noise. The docstrings are missing entirely despite complex logic, and the final blank line before the class is unnecessary. Overall, the code is readable but would benefit from import consolidation and documentation.

Run 3

The code is highly readable. It has a clear, logical structure with well-organized imports and a straightforward class definition. It is mostly flat with minimal nesting. The intent is clear: define a Request class with initialization and preparation methods. Code length is concise, and action granularity is appropriate, generally one action per line. Reading flow is natural and easy to follow. Minor points deducted for some redundancy (e.g., defaulting parameters to None then reassigning) and slight verbosity in imports, but overall it is excellent.

Run 1

Code Structure: The class is logically organized into attributes, initialization, representation, and preparation, although the extensive import block distracts from the small implementation. Nesting: Control flow is shallow, with only one simple loop. Clarity of intent: Descriptive method names, type annotations, and explicit keyword arguments make the request-building purpose clear; missing docstrings and dependencies not defined or imported in the snippet reduce self-contained understanding. Code length: The implementation is reasonably concise, but many imports appear unused in the provided code, and attribute declarations repeat information from initialization. Action granularity: Statements generally perform one action per line, making assignments and defaults easy to scan. Reading flow: Initialization proceeds naturally from default normalization through hook registration to attribute assignment, followed by preparation. Excess whitespace and the long import preamble slightly interrupt that flow.

Run 2

Code Structure: The class is logically organized into annotations, initialization, representation, and preparation, though the large import block includes many names unused in this excerpt. Nesting: Control flow is shallow, with only a simple loop. Clarity of intent: Descriptive attributes, method names, and type hints make request construction clear; missing docstrings and externally defined types and classes limit standalone understanding. Code length: The implementation is reasonably concise, but extensive imports, repeated field declarations and assignments, and extra blank lines add visual bulk. Action granularity: Each statement performs one clear action, and multiline calls are easy to scan. Reading flow: Initialization proceeds naturally from default normalization to hook registration and attribute assignment, followed by preparation; excessive whitespace and import overhead slightly interrupt the flow.

Run 3

Code Structure: Imports, attribute declarations, initialization, representation, and preparation are logically grouped, although the large import section includes many names unused in this excerpt. Nesting: Minimal nesting makes control flow easy to follow. Clarity of intent: Descriptive names and type annotations clearly convey request configuration and preparation; however, absent docstrings and undefined dependencies in the excerpt reduce self-contained understanding. Code length: The class is reasonably concise, but extensive imports and repeated attribute forwarding add visual bulk. Action granularity: Statements generally perform one action per line, improving scanability. Reading flow: Methods follow a natural lifecycle from initialization to preparation, with consistent formatting overall; excessive blank space and stray whitespace slightly disrupt the presentation.