Home / Function/ _find_no_duplicates() — requests Function Reference

_find_no_duplicates() — requests Function Reference

Architecture documentation for the _find_no_duplicates() function in cookies.py from the requests codebase.

Entity Profile

Dependency Diagram

graph TD
  fd38c17e_2878_56aa_908e_1c7dd00e7a22["_find_no_duplicates()"]
  12ccbc5f_4c31_987c_5272_7babba58a1f2["RequestsCookieJar"]
  fd38c17e_2878_56aa_908e_1c7dd00e7a22 -->|defined in| 12ccbc5f_4c31_987c_5272_7babba58a1f2
  b59a42f3_d82f_81a3_c550_b1cea1222004["get()"]
  b59a42f3_d82f_81a3_c550_b1cea1222004 -->|calls| fd38c17e_2878_56aa_908e_1c7dd00e7a22
  0324ee83_119d_91ab_adf9_a43164f67d41["__getitem__()"]
  0324ee83_119d_91ab_adf9_a43164f67d41 -->|calls| fd38c17e_2878_56aa_908e_1c7dd00e7a22
  style fd38c17e_2878_56aa_908e_1c7dd00e7a22 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/requests/cookies.py lines 386–413

    def _find_no_duplicates(self, name, domain=None, path=None):
        """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
        """
        toReturn = None
        for cookie in iter(self):
            if cookie.name == name:
                if domain is None or cookie.domain == domain:
                    if path is None or cookie.path == path:
                        if toReturn is not None:
                            # if there are multiple cookies that meet passed in criteria
                            raise CookieConflictError(
                                f"There are multiple cookies with name, {name!r}"
                            )
                        # we will eventually return this as long as no cookie conflict
                        toReturn = cookie.value

        if toReturn:
            return toReturn
        raise KeyError(f"name={name!r}, domain={domain!r}, path={path!r}")

Domain

Subdomains

Called By

Frequently Asked Questions

What does _find_no_duplicates() do?
_find_no_duplicates() is a function in the requests codebase, defined in src/requests/cookies.py.
Where is _find_no_duplicates() defined?
_find_no_duplicates() is defined in src/requests/cookies.py at line 386.
What calls _find_no_duplicates()?
_find_no_duplicates() is called by 2 function(s): __getitem__, get.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free