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 <i...@gno.de> Gerrit-Reviewer: Xqt <i...@gno.de> Gerrit-Reviewer: jenkins-bot
_______________________________________________ Pywikibot-commits mailing list -- pywikibot-commits@lists.wikimedia.org To unsubscribe send an email to pywikibot-commits-le...@lists.wikimedia.org