jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1104960?usp=email )
Change subject: IMPR: use f-string instead of old format type
......................................................................
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(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
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 https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1104960?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: I1d367e53b50fb1daf5914d8d2bae6034af8623ad
Gerrit-Change-Number: 1104960
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1104388?usp=email )
Change subject: cleanup: Support for MediaWiki <= 1.30 was dropped
......................................................................
cleanup: Support for MediaWiki <= 1.30 was dropped
Bug: T378984
Change-Id: I90807d956798f5e199f1a1627b74758b56bc0c11
---
M pywikibot/login.py
1 file changed, 0 insertions(+), 3 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/login.py b/pywikibot/login.py
index 5760c3a..b73776f 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -445,10 +445,7 @@
del login_request['rememberMe']
continue
- # messagecode was introduced with 1.29.0-wmf.14
- # but older wikis are still supported
login_throttled = response.get('messagecode') == 'login-throttled'
-
if (status == 'Throttled' or status == self.keyword('fail')
and (login_throttled or 'wait' in fail_reason)):
wait = response.get('wait')
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1104388?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: I90807d956798f5e199f1a1627b74758b56bc0c11
Gerrit-Change-Number: 1104388
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1104387?usp=email )
Change subject: cleanup: Drop support for MediaWiki < 1.31
......................................................................
cleanup: Drop support for MediaWiki < 1.31
- remove WbQuantity._require_errors
- update dry_api_tests
- update edit_tests
- update documentation
Bug: T378984
Change-Id: Ic11901e060b58b958a437d1bb8adf61656a1c0f5
---
M pywikibot/_wbtypes.py
M tests/README.rst
M tests/aspects.py
M tests/dry_api_tests.py
M tests/edit_tests.py
M tests/siteinfo_tests.py
6 files changed, 9 insertions(+), 29 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/_wbtypes.py b/pywikibot/_wbtypes.py
index a0c0b5d..dae9afe 100644
--- a/pywikibot/_wbtypes.py
+++ b/pywikibot/_wbtypes.py
@@ -18,7 +18,6 @@
import pywikibot
from pywikibot import exceptions
from pywikibot.backports import Iterator
-from pywikibot.logging import warning
from pywikibot.time import Timestamp
from pywikibot.tools import issue_deprecation_warning, remove_last_args
@@ -808,21 +807,6 @@
_items = ('amount', 'upperBound', 'lowerBound', 'unit')
@staticmethod
- def _require_errors(site: DataSite | None) -> bool:
- """Check if Wikibase site is old and requires error bounds to be given.
-
- If no site item is supplied it raises a warning and returns True.
-
- :param site: The Wikibase site
- """
- if not site:
- warning(
- "WbQuantity now expects a 'site' parameter. This is needed to "
- 'ensure correct handling of error bounds.')
- return False
- return site.mw_version < '1.29.0-wmf.2'
-
- @staticmethod
def _todecimal(value: ToDecimalType) -> Decimal | None:
"""Convert a string to a Decimal for use in WbQuantity.
@@ -872,13 +856,10 @@
and not unit.startswith(('http://', 'https://')):
raise ValueError("'unit' must be an ItemPage or entity uri.")
- if error is None and not self._require_errors(site):
+ if error is None:
self.upperBound = self.lowerBound = None
else:
- if error is None:
- upper_error: Decimal | None = Decimal(0)
- lower_error: Decimal | None = Decimal(0)
- elif isinstance(error, tuple):
+ if isinstance(error, tuple):
upper_error = self._todecimal(error[0])
lower_error = self._todecimal(error[1])
else:
@@ -945,7 +926,7 @@
lower_bound = cls._todecimal(data.get('lowerBound'))
bounds_provided = (upper_bound is not None and lower_bound is not None)
error = None
- if bounds_provided or cls._require_errors(site):
+ if bounds_provided:
error = (upper_bound - amount, amount - lower_bound)
unit = None if data['unit'] == '1' else data['unit']
return cls(amount, unit, error, site)
diff --git a/tests/README.rst b/tests/README.rst
index 7c82899..297c4e7 100644
--- a/tests/README.rst
+++ b/tests/README.rst
@@ -207,7 +207,7 @@
from tests.aspects import require_version
[......]
- @require_version('>=1.27.0')
+ @require_version('>=1.31.0')
def test_require_version(self):
@unittest.mock.patch
diff --git a/tests/aspects.py b/tests/aspects.py
index 6fefe0c..084cd29 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -288,7 +288,7 @@
"""Require minimum MediaWiki version to be queried.
The version needed for the test; must be given with a preleading rich
- comparisons operator like ``<1.27wmf4`` or ``>=1.39``. If the
+ comparisons operator like ``<1.31wmf4`` or ``>=1.43``. If the
comparison does not match the test will be skipped.
This decorator can only be used for TestCase having a single site.
diff --git a/tests/dry_api_tests.py b/tests/dry_api_tests.py
index f7a512b..7752342 100755
--- a/tests/dry_api_tests.py
+++ b/tests/dry_api_tests.py
@@ -164,7 +164,7 @@
self._siteinfo = DummySiteinfo({'case': 'first-letter'})
def version(self):
- return '1.27' # lowest supported release
+ return '1.31' # lowest supported release
def protocol(self):
return 'http'
diff --git a/tests/edit_tests.py b/tests/edit_tests.py
index 9f3e351..6de9970 100755
--- a/tests/edit_tests.py
+++ b/tests/edit_tests.py
@@ -14,7 +14,7 @@
import pywikibot
from pywikibot import page_put_queue
from pywikibot.exceptions import Error
-from tests.aspects import TestCase, require_version
+from tests.aspects import TestCase
called_back = False
@@ -81,7 +81,6 @@
write = True
rights = 'mergehistory'
- @require_version('>=1.27.0wmf.13', 'support the history merge API')
def setup_test_pages(self):
"""Helper function to set up pages that we will use in these tests."""
site = self.get_site()
diff --git a/tests/siteinfo_tests.py b/tests/siteinfo_tests.py
index 9e3034b..9553173 100755
--- a/tests/siteinfo_tests.py
+++ b/tests/siteinfo_tests.py
@@ -57,12 +57,12 @@
def test_properties(self):
"""Test the siteinfo properties."""
- # 'fileextensions' introduced in v1.15:
+ # fileextensions
self.assertIn('fileextensions', self.site.siteinfo)
fileextensions = self.site.siteinfo.get('fileextensions')
self.assertIsInstance(fileextensions, list)
self.assertIn({'ext': 'png'}, fileextensions)
- # 'restrictions' introduced in v1.23:
+ # restrictions
self.assertIn('restrictions', self.site.siteinfo)
restrictions = self.site.siteinfo.get('restrictions')
self.assertIsInstance(restrictions, dict)
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1104387?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: Ic11901e060b58b958a437d1bb8adf61656a1c0f5
Gerrit-Change-Number: 1104387
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot