jenkins-bot submitted this change.

View Change

Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
IMPR: use f-string instead of old format type

Change-Id: I1d367e53b50fb1daf5914d8d2bae6034af8623ad
---
M pywikibot/data/api/_generators.py
M pywikibot/logentries.py
M pywikibot/site/_generators.py
3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/pywikibot/data/api/_generators.py b/pywikibot/data/api/_generators.py
index ac1c981..b27abb1 100644
--- a/pywikibot/data/api/_generators.py
+++ b/pywikibot/data/api/_generators.py
@@ -634,8 +634,8 @@
previous_result_had_data = True
else:
if 'query' not in self.data:
- pywikibot.log("%s: 'query' not found in api response." %
- self.__class__.__name__)
+ pywikibot.log(f"{type(self).__name__}: 'query' not found"
+ ' in api response.')
pywikibot.log(str(self.data))

# if (query-)continue is present, self.resultkey might not have
diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py
index 9b25276..92a34cf 100644
--- a/pywikibot/logentries.py
+++ b/pywikibot/logentries.py
@@ -61,9 +61,10 @@
for hidden_key, hidden_types in hidden.items():
if hidden_key in self and key in hidden_types:
raise HiddenKeyError(
- "Log entry ({}) has a hidden '{}' key and you don't have "
- "permission to view it due to '{}'"
- .format(self['type'], key, hidden_key))
+ f'Log entry ({self["type"]}) has a hidden {key!r} key and'
+ " you don't have permission to view it due to "
+ f'{hidden_key!r}'
+ )

raise KeyError(f"Log entry ({self['type']}) has no {key!r} key")

diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py
index ecbd871..7e0bae6 100644
--- a/pywikibot/site/_generators.py
+++ b/pywikibot/site/_generators.py
@@ -197,7 +197,7 @@
for pagedata in rvgen:
pywikibot.debug(f'Preloading {pagedata}')
try:
- if pagedata['title'] not in cache:
+ if (pd_title := pagedata['title']) not in cache:
# API always returns a "normalized" title which is
# usually the same as the canonical form returned by
# page.title(), but sometimes not (e.g.,
@@ -206,19 +206,18 @@
# the response that corresponds to the canonical form
# used in the query.
for key, value in cache.items():
- if self.sametitle(key, pagedata['title']):
- cache[pagedata['title']] = value
+ if self.sametitle(key, pd_title):
+ cache[pd_title] = value
break
else:
- pywikibot.warning(
- 'preloadpages: Query returned unexpected '
- "title '{}'".format(pagedata['title']))
+ pywikibot.warning('preloadpages: Query returned '
+ f'unexpected title {pd_title!r}')
continue

except KeyError:
- pywikibot.debug(f"No 'title' in {pagedata}")
- pywikibot.debug(f'{pageids=!s}')
- pywikibot.debug(f'titles={list(cache.keys())}')
+ pywikibot.debug(f"No 'title' in {pagedata}\n"
+ f'{pageids=!s}\n'
+ f'titles={list(cache.keys())}')
continue

priority, page = cache[pagedata['title']]

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

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