Sample

pyint-f07c5c591d9c-I04

Replace names with deterministic minifier-style shortest identifiers

Matched original source

Lines298

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.7220–1; higher is more readable
Mi0.6080–1; higher is more readable
LLOC145Logical lines; fewer is more readable
DeepSeek V4 Pro2.670–20; mean of three runs
GPT-6.1 Sol100–20; mean of three runs
BTTF0.1420–1; higher is more readable

Views

Source code

from __future__ import annotations import calendar import copy import time from collections.abc import Iterator, MutableMapping from http.cookiejar import Cookie, CookieJar, CookiePolicy from typing import TYPE_CHECKING, Any, TypeVar, overload from ._internal_utils import to_native_string from ._types import is_prepared as _is_prepared from .compat import Morsel, cookielib, urlparse, urlunparse import threading class RequestsCookieJar(CookieJar, MutableMapping[str, str | None]): # type: ignore[misc] """Compatibility class; is a http.cookiejar.CookieJar, but exposes a dict interface. This is the CookieJar we create by default for requests and sessions that don't specify one, since some clients may expect response.cookies and session.cookies to support dict operations. Requests does not use the dict interface internally; it's just for compatibility with external client code. All requests code should work out of the box with externally provided instances of ``CookieJar``, e.g. ``LWPCookieJar`` and ``FileCookieJar``. Unlike a regular CookieJar, this class is pickleable. .. warning:: dictionary operations that are normally O(1) may be O(n). """ _policy: CookiePolicy def a( # type: ignore[override] self, t: str, u: str | None = None, v: str | None = None, w: str | None = None, ) -> str | None: """Dict-like get() that also supports optional domain and path args in order to resolve naming collisions from using one cookie jar over multiple domains. .. warning:: operation is O(n), not O(1). """ try: return self.q(t, v, w) except KeyError: return u def b( self, x: str, y: str | Morsel[dict[str, str]] | None, **z: Any ) -> Cookie | None: """Dict-like set() that also supports optional domain and path args in order to resolve naming collisions from using one cookie jar over multiple domains. """ # support client code that unsets cookies by assignment of a None value: if y is None: remove_cookie_by_name( self, x, domain=z.get("domain"), path=z.get("path") ) return if isinstance(y, Morsel): A = morsel_to_cookie(y) else: A = create_cookie(x, y, **z) self.n(A) return A def d(self) -> Iterator[str]: """Dict-like iterkeys() that returns an iterator of names of cookies from the jar. .. seealso:: itervalues() and iteritems(). """ for B in iter(self): yield B.name def e(self) -> list[str]: # type: ignore[override] """Dict-like keys() that returns a list of names of cookies from the jar. .. seealso:: values() and items(). """ return list(self.d()) def f(self) -> Iterator[str | None]: """Dict-like itervalues() that returns an iterator of values of cookies from the jar. .. seealso:: iterkeys() and iteritems(). """ for C in iter(self): yield C.value def g(self) -> list[str | None]: # type: ignore[override] """Dict-like values() that returns a list of values of cookies from the jar. .. seealso:: keys() and items(). """ return list(self.f()) def h(self) -> Iterator[tuple[str, str | None]]: """Dict-like iteritems() that returns an iterator of name-value tuples from the jar. .. seealso:: iterkeys() and itervalues(). """ for D in iter(self): yield D.name, D.value def i(self) -> list[tuple[str, str | None]]: # type: ignore[override] """Dict-like items() that returns a list of name-value tuples from the jar. Allows client-code to call ``dict(RequestsCookieJar)`` and get a vanilla python dict of key value pairs. .. seealso:: keys() and values(). """ return list(self.h()) def j(self) -> list[str]: """Utility method to list all the domains in the jar.""" E: list[str] = [] for F in iter(self): if F.domain not in E: E.append(F.domain) return E def k(self) -> list[str]: """Utility method to list all the paths in the jar.""" G: list[str] = [] for H in iter(self): if H.path not in G: G.append(H.path) return G def l(self) -> bool: """Returns True if there are multiple domains in the jar. Returns False otherwise. :rtype: bool """ I: list[str] = [] for J in iter(self): if J.domain is not None and J.domain in I: # type: ignore[reportUnnecessaryComparison] # defensive check return True I.append(J.domain) return False # there is only one domain in jar def m( self, K: str | None = None, L: str | None = None ) -> dict[str, str | None]: """Takes as an argument an optional domain and path and returns a plain old Python dict of name-value pairs of cookies that meet the requirements. :rtype: dict """ M: dict[str, str | None] = {} for N in iter(self): if (K is None or N.domain == K) and ( L is None or N.path == L ): M[N.name] = N.value return M def __iter__(self) -> Iterator[Cookie]: # type: ignore[override] """RequestCookieJar's __iter__ comes from CookieJar not MutableMapping.""" return super().__iter__() def __contains__(self, O: object) -> bool: try: return super().__contains__(O) except CookieConflictError: return True def __getitem__(self, P: str) -> str | None: """Dict-like __getitem__() for compatibility with client code. Throws exception if there are more than one cookie with name. In that case, use the more explicit get() method instead. .. warning:: operation is O(n), not O(1). """ return self.q(P) def __setitem__( self, Q: str, R: str | Morsel[dict[str, str]] | None ) -> None: """Dict-like __setitem__ for compatibility with client code. Throws exception if there is already a cookie of that name in the jar. In that case, use the more explicit set() method instead. """ self.b(Q, R) def __delitem__(self, S: str) -> None: """Deletes a cookie given a name. Wraps ``http.cookiejar.CookieJar``'s ``remove_cookie_by_name()``. """ remove_cookie_by_name(self, S) def n(self, T: Cookie, *U: Any, **V: Any) -> None: if ( (W := T.value) is not None and W.startswith('"') and W.endswith('"') ): T.value = W.replace('\\"', "") return super().set_cookie(T, *U, **V) def o( # type: ignore[override] self, X: CookieJar | SupportsKeysAndGetItem[str, str] ) -> None: """Updates this jar with cookies from another CookieJar or dict-like""" if isinstance(X, cookielib.CookieJar): for Y in X: self.n(copy.copy(Y)) else: super().update(X) def p( self, Z: str, aa: str | None = None, ab: str | None = None ) -> str | None: """Requests uses this method internally to get cookie values. If there are conflicting cookies, _find arbitrarily chooses one. See _find_no_duplicates if you want an exception thrown if there are conflicting cookies. :param name: a string containing name of cookie :param domain: (optional) string containing domain of cookie :param path: (optional) string containing path of cookie :return: cookie.value """ for ac in iter(self): if ac.name == Z: if aa is None or ac.domain == aa: if ab is None or ac.path == ab: return ac.value raise KeyError(f"name={Z!r}, domain={aa!r}, path={ab!r}") def q( self, ad: str, ae: str | None = None, af: str | None = None ) -> str: """Both ``__get_item__`` and ``get`` call this function: it's never used elsewhere in Requests. :param name: a string containing name of cookie :param domain: (optional) string containing domain of cookie :param path: (optional) string containing path of cookie :raises KeyError: if cookie is not found :raises CookieConflictError: if there are multiple cookies that match name and optionally domain and path :return: cookie.value """ ag = None for ah in iter(self): if ah.name == ad: if ae is None or ah.domain == ae: if af is None or ah.path == af: if ag is not None: # if there are multiple cookies that meet passed in criteria raise CookieConflictError( f"There are multiple cookies with name, {ad!r}" ) # we will eventually return this as long as no cookie conflict ag = ah.value if ag is not None: return ag raise KeyError(f"name={ad!r}, domain={ae!r}, path={af!r}") def __getstate__(self) -> dict[str, Any]: """Unlike a normal CookieJar, this class is pickleable.""" ai = self.__dict__.copy() # remove the unpickleable RLock object ai.pop("_cookies_lock") return ai def __setstate__(self, aj: dict[str, Any]) -> None: """Unlike a normal CookieJar, this class is pickleable.""" self.__dict__.update(aj) if "_cookies_lock" not in self.__dict__: self._cookies_lock = threading.RLock() def r(self) -> RequestsCookieJar: """Return a copy of this RequestsCookieJar.""" ak = RequestsCookieJar() ak.set_policy(self.s()) ak.update(self) return ak def s(self) -> CookiePolicy: """Return the CookiePolicy instance used.""" return self._policy

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.9090.297−299.98
Source linesThe number of non-empty source lines.298+119.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.385−6.577

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

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.299−9.55
Indentation frequencyHow rapidly indentation changes from line to line.198+6.111
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.297.941+3.755
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.117.97−1.332
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.117.973+1.099
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.055+0.404
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.1+0.398

Intercept 0.07 + feature contributions = 0.956 (log-odds).
Score = sigmoid(0.956) = 0.722.

Score0.608
Score145
Run 1

The code is extremely difficult to read due to pervasive obfuscation. Method names are single letters (a, b, q) replacing descriptive names like get, set, or get_dict. Parameter names are arbitrary (t, u, v, w, K, L, aa) rather than meaningful (name, domain, path, value). Local variables are also single letters (A, B, C, ag, ah). This destroys clarity of intent and reading flow. The structure and nesting are not inherently tangled, and methods generally do one action per line, but the cryptographic naming makes every line require reverse-engineering. Even docstrings, while present, cannot compensate because the code itself is unreadable without constant mental mapping. The use of comments like 'we will eventually return this as long as no cookie conflict' adds minor clarity, but the overall effect is overwhelmingly negative for maintainability and collaboration.

Run 2

The code is severely unreadable due to deliberate obfuscation. Method names are reduced to meaningless single letters (a, b, q, n, etc.), and all local variables follow the same pattern (A-Z, aa-aj). This destroys clarity of intent, making it impossible to understand what each method does without reading its docstring. While the underlying structure is similar to the original RequestsCookieJar, the renaming removes semantic meaning. Nesting and structure are moderate, inherited from the original code, but action granularity and reading flow are undermined by opaque identifiers. Code length is reasonable, but the obfuscation renders it unreadable.

Run 3

The code is severely unreadable due to deliberate obfuscation. All method and parameter names are meaningless single letters (a, b, t, u, v, z, A, B), obliterating clarity of intent. Action granularity and reading flow are destroyed because readers must constantly map cryptic symbols to their documented purposes. While the original structure—imports, class docstring, grouped methods—exists, the renaming makes it feel tangled. Nesting is moderate but harder to follow when conditions use opaque variables. Code length is concise line-wise, but each line demands heavy cognitive lookup. The informative docstrings are the only saving grace, providing a partial decoding key, but code comprehension still requires constant cross-referencing. This is effectively unreadable in practice despite a reasonable underlying layout.

Run 1

Code Structure: Methods are logically separated within a cohesive cookie-jar class, with useful docstrings and type annotations. Nesting: Most methods are shallow, but p and q contain three to four nested conditions that complicate lookup logic. Clarity of intent: Single-letter method names and arbitrary variable names severely obscure purpose; docstrings help, but reference original names that no longer match the code. Code length: Individual methods are generally concise, although repetitive wrappers and lengthy documentation increase the reading burden. Action granularity: Statements mostly perform one action per line; the assignment expression in n slightly combines operations. Reading flow: Consistent formatting and method grouping help, but opaque cross-method calls, mismatched documentation, and irregular import ordering interrupt natural comprehension.

Run 2

Code Structure: Methods are logically separated within a cohesive cookie-jar class, although import organization is inconsistent. Nesting: Most methods are shallow, but cookie lookup methods use three to four nested conditions that could be flattened. Clarity of intent: Type hints and detailed docstrings explain behavior, but opaque method and variable names severely obscure intent; documentation references meaningful names that no longer match the implementation. Code length: Individual methods are mostly concise, although repetitive wrappers and lengthy docstrings increase scanning effort. Action granularity: Statements generally perform one action per line, with few compressed expressions. Reading flow: Consistent formatting and grouping of related operations help, but tracing calls such as self.q(), self.n(), and self.s() requires repeatedly consulting definitions. Overall, sound structural organization is substantially undermined by pervasive non-descriptive naming.

Run 3

Code Structure: Methods are logically grouped within a single class, with clear separation of mapping operations, lookup, and serialization. Nesting: Most methods are shallow, but lookup methods p and q contain several nested conditions that impede scanning. Clarity of intent: Docstrings and type annotations explain functionality, but opaque method and variable names severely obscure intent; documentation also references names absent from the implementation. Code length: Individual methods are generally concise, although repetitive wrappers and lengthy docstrings increase overall reading effort. Action granularity: Most lines perform one action; the assignment expression in n slightly increases cognitive load. Reading flow: Consistent formatting and familiar special methods help, but deciphering letter-based identifiers and translating cross-references repeatedly interrupts comprehension.