Skip to content

Commit 101425e

Browse files
committed
Enhance documentation for clarity.
1 parent f4ec3d2 commit 101425e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

requests/cookies.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
165165
session.cookies to support dict operations.
166166
167167
Requests does not use the dict interface internally; it's just for
168-
compatibility with external client code. All `requests` code should work
168+
compatibility with external client code. All requests code should work
169169
out of the box with externally provided instances of ``CookieJar``, e.g.
170170
``LWPCookieJar`` and ``FileCookieJar``.
171171
@@ -275,8 +275,9 @@ def get_dict(self, domain=None, path=None):
275275
def __getitem__(self, name):
276276
"""Dict-like __getitem__() for compatibility with client code. Throws
277277
exception if there are more than one cookie with name. In that case,
278-
use the more explicit get() method instead. Caution: operation is O(n),
279-
not O(1)."""
278+
use the more explicit get() method instead.
279+
280+
.. warning:: operation is O(n), not O(1)."""
280281

281282
return self._find_no_duplicates(name)
282283

@@ -320,11 +321,11 @@ def _find(self, name, domain=None, path=None):
320321
raise KeyError('name=%r, domain=%r, path=%r' % (name, domain, path))
321322

322323
def _find_no_duplicates(self, name, domain=None, path=None):
323-
"""__get_item__ and get call _find_no_duplicates -- never used in
324-
Requests internally. Takes as args name and optional domain and path.
325-
Returns a cookie.value. Throws KeyError if cookie is not found and
326-
CookieConflictError if there are multiple cookies that match name and
327-
optionally domain and path."""
324+
"""Both ``__get_item__`` and ``get`` call this function: it's never
325+
used elsewhere in Requests. Takes as args name and optional domain and
326+
path. Returns a cookie.value. Throws KeyError if cookie is not found
327+
and CookieConflictError if there are multiple cookies that match name
328+
and optionally domain and path."""
328329
toReturn = None
329330
for cookie in iter(self):
330331
if cookie.name == name:

0 commit comments

Comments
 (0)