jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1100139?usp=email )
Change subject: IMPR: use self-documenting expressions with f-strings
......................................................................
IMPR: use self-documenting expressions with f-strings
Bug: T379062
Change-Id: I5f13757c6ed22892047d1f4a3fce36ad3bd3b563
---
M pywikibot/comms/http.py
M pywikibot/family.py
M pywikibot/proofreadpage.py
M pywikibot/site/_generators.py
M scripts/pyproject.toml
M scripts/reflinks.py
6 files changed, 11 insertions(+), 11 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index 71345d6..67a89d3 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -400,7 +400,7 @@
if use_fake_user_agent and isinstance(use_fake_user_agent, str):
return use_fake_user_agent # Custom UA.
raise ValueError('Invalid parameter: '
- f'use_fake_user_agent={use_fake_user_agent}')
+ f'{use_fake_user_agent=!s}')
def assign_user_agent(user_agent_format_string):
if not user_agent_format_string or '{' in user_agent_format_string:
diff --git a/pywikibot/family.py b/pywikibot/family.py
index b96bf14..43d569d 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -574,7 +574,7 @@
def get_address(self, code, title) -> str:
"""Return the path to title using index.php with redirects disabled."""
- return f'{self.path(code)}?title={title}&redirect=no'
+ return f'{self.path(code)}?{title=!s}&redirect=no'
def interface(self, code: str) -> str:
"""Return interface to use for code."""
diff --git a/pywikibot/proofreadpage.py b/pywikibot/proofreadpage.py
index a452603..502d9e4 100644
--- a/pywikibot/proofreadpage.py
+++ b/pywikibot/proofreadpage.py
@@ -133,14 +133,14 @@
def _convert(self, value):
"""Handle conversion from str to int and quotes."""
if not isinstance(value, (str, int)):
- raise TypeError(f'value={value} must be str or int.')
+ raise TypeError(f'{value=!s} must be str or int.')
self._orig_value = value
if isinstance(value, str):
if (value.startswith('"') != value.endswith('"')
or value.startswith("'") != value.endswith("'")):
- raise ValueError(f'value={value} has wrong quotes.')
+ raise ValueError(f'{value=!s} has wrong quotes.')
value = value.strip('"\'')
value = int(value) if value.isdigit() else value
@@ -288,7 +288,7 @@
"""Initializer."""
m = self.pat_tag.search(text)
if m is None:
- raise ValueError(f'Invalid text={text}')
+ raise ValueError(f'Invalid {text=!s}')
tag = m['attrs']
matches = list(self.pat_attr.finditer(tag))
@@ -1270,7 +1270,7 @@
end = self.num_pages
if not 1 <= start <= end <= self.num_pages:
- raise ValueError(f'start={start}, end={end} are not in valid '
+ raise ValueError(f'{start=!s}, {end=!s} are not in valid '
f'range (1, {self.num_pages})')
# All but 'Without Text'
diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py
index 8f5c7f7..145430f 100644
--- a/pywikibot/site/_generators.py
+++ b/pywikibot/site/_generators.py
@@ -221,7 +221,7 @@
except KeyError:
pywikibot.debug(f"No 'title' in {pagedata}")
- pywikibot.debug(f'pageids={pageids}')
+ pywikibot.debug(f'{pageids=!s}')
pywikibot.debug(f'titles={list(cache.keys())}')
continue
diff --git a/scripts/pyproject.toml b/scripts/pyproject.toml
index 9dccc93..cfe050b 100644
--- a/scripts/pyproject.toml
+++ b/scripts/pyproject.toml
@@ -17,7 +17,7 @@
]
description = "Pywikibot Scripts Collection"
readme = "scripts/README.rst"
-requires-python = ">=3.7.0"
+requires-python = ">=3.8.0"
dependencies = [
"pywikibot >= 9.4.0",
"isbnlib",
diff --git a/scripts/reflinks.py b/scripts/reflinks.py
index 2f7f10e..5d14b93 100755
--- a/scripts/reflinks.py
+++ b/scripts/reflinks.py
@@ -391,7 +391,7 @@
elif v[IX.quoted]:
name = f'"{name}"'
- named = f'<ref {group}name={name}>{ref}</ref>'
+ named = f'<ref {group}{name=!s}>{ref}</ref>'
text = text.replace(v[IX.reflist][0], named, 1)
# make sure that the first (named ref) is not removed later
@@ -400,7 +400,7 @@
end = text[pos:]
# replace multiple identical references with repeated ref
- repeated_ref = f'<ref {group}name={name} />'
+ repeated_ref = f'<ref {group}{name=!s} />'
for ref in v[IX.reflist][1:]:
# Don't replace inside templates (T266411)
end = replaceExcept(end, re.escape(ref), repeated_ref,
@@ -415,7 +415,7 @@
name = f'"{name}"'
text = re.sub(rf'<ref name\s*=\s*(?P<quote>["\']?)\s*{ref}\s*'
- r'(?P=quote)\s*/>', f'<ref name={name} />', text)
+ r'(?P=quote)\s*/>', f'<ref {name=!s} />', text)
return text
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1100139?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I5f13757c6ed22892047d1f4a3fce36ad3bd3b563
Gerrit-Change-Number: 1100139
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]