jenkins-bot submitted this change.

View Change

Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
[IMPR] replace requests.utils.urlparse with urllib.parse.urlparse

requests.utils.urlparse is not part of the official API and it is used
within requests for Python 3 support,

Bug: T367649
Change-Id: If29b1fd6e3cceb64163ae0662e69ac31fc685b19
---
M pywikibot/comms/http.py
1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index 65f1333..ef4cc61 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -26,7 +26,7 @@
Cookies are lazy loaded when logging to site.
"""
#
-# (C) Pywikibot team, 2007-2023
+# (C) Pywikibot team, 2007-2024
#
# Distributed under the terms of the MIT license.
#
@@ -286,26 +286,25 @@


def get_authentication(uri: str) -> tuple[str, str] | None:
- """
- Retrieve authentication token.
+ """Retrieve authentication token.

:param uri: the URI to access
:return: authentication token
"""
- parsed_uri = requests.utils.urlparse(uri)
+ parsed_uri = urlparse(uri)
netloc_parts = parsed_uri.netloc.split('.')
netlocs = [parsed_uri.netloc] + ['.'.join(['*'] + netloc_parts[i + 1:])
for i in range(len(netloc_parts))]
for path in netlocs:
if path in config.authenticate:
- if len(config.authenticate[path]) in [2, 4]:
+ length = len(config.authenticate[path])
+ if length in (2, 4):
return config.authenticate[path]
- warn('config.authenticate["{path}"] has invalid value.\n'
- 'It should contain 2 or 4 items, not {length}.\n'
- 'See {url}/OAuth for more info.'
- .format(path=path,
- length=len(config.authenticate[path]),
- url=pywikibot.__url__))
+
+ warn(f'config.authenticate[{path!r}] has invalid value.\n'
+ f'It should contain 2 or 4 items, not {length}.\n'
+ f'See {pywikibot.__url__}/OAuth for more info.')
+
return None



To view, visit change 1045496. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: If29b1fd6e3cceb64163ae0662e69ac31fc685b19
Gerrit-Change-Number: 1045496
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot