Skip to content

Commit e6bcfbe

Browse files
[PR #9171/0462ae6b backport][3.10] Switch to using yarl.URL.absolute over yarl.URL.is_absolute() (#9291)
Co-authored-by: J. Nick Koston <[email protected]>
1 parent 0b82655 commit e6bcfbe

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

CHANGES/9171.misc.rst

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Improved performance of determining if a URL is absolute -- by :user:`bdraco`.
2+
3+
The property :attr:`~yarl.URL.absolute` is more performant than the method ``URL.is_absolute()`` and preferred when newer versions of yarl are used.

aiohttp/client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ def _build_url(self, str_or_url: StrOrURL) -> URL:
444444
if self._base_url is None:
445445
return url
446446
else:
447-
assert not url.is_absolute() and url.path.startswith("/")
447+
assert not url.absolute and url.path.startswith("/")
448448
return self._base_url.join(url)
449449

450450
async def _request(

aiohttp/test_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def make_url(self, path: StrOrURL) -> URL:
148148
assert self._root is not None
149149
url = URL(path)
150150
if not self.skip_url_asserts:
151-
assert not url.is_absolute()
151+
assert not url.absolute
152152
return self._root.join(url)
153153
else:
154154
return URL(str(self._root) + str(path))

aiohttp/web_request.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def __init__(
174174
self._version = message.version
175175
self._cache: Dict[str, Any] = {}
176176
url = message.url
177-
if url.is_absolute():
177+
if url.absolute:
178178
if scheme is not None:
179179
url = url.with_scheme(scheme)
180180
if host is not None:

0 commit comments

Comments
 (0)