Skip to content

Commit

Permalink
[PR #9171/0462ae6b backport][3.10] Switch to using `yarl.URL.absolute…
Browse files Browse the repository at this point in the history
…` over `yarl.URL.is_absolute()` (#9291)

Co-authored-by: J. Nick Koston <[email protected]>
  • Loading branch information
patchback[bot] and bdraco authored Sep 24, 2024
1 parent 0b82655 commit e6bcfbe
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES/9171.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Improved performance of determining if a URL is absolute -- by :user:`bdraco`.

The property :attr:`~yarl.URL.absolute` is more performant than the method ``URL.is_absolute()`` and preferred when newer versions of yarl are used.
2 changes: 1 addition & 1 deletion aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def _build_url(self, str_or_url: StrOrURL) -> URL:
if self._base_url is None:
return url
else:
assert not url.is_absolute() and url.path.startswith("/")
assert not url.absolute and url.path.startswith("/")
return self._base_url.join(url)

async def _request(
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def make_url(self, path: StrOrURL) -> URL:
assert self._root is not None
url = URL(path)
if not self.skip_url_asserts:
assert not url.is_absolute()
assert not url.absolute
return self._root.join(url)
else:
return URL(str(self._root) + str(path))
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def __init__(
self._version = message.version
self._cache: Dict[str, Any] = {}
url = message.url
if url.is_absolute():
if url.absolute:
if scheme is not None:
url = url.with_scheme(scheme)
if host is not None:
Expand Down

0 comments on commit e6bcfbe

Please sign in to comment.