jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693505 )
Change subject: [cleanup] Disallow non-map translation parameters
......................................................................
[cleanup] Disallow non-map translation parameters
Translation with a string or integer parameter argument were deprecated about
six years ago. Enforcing it.
Change-Id: Ic9869f12d729d8ec99fb2e96dbef12a5efd7f410
---
M pywikibot/i18n.py
1 file changed, 6 insertions(+), 11 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index aba2f29..5399c85 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -529,7 +529,7 @@
def translate(code,
xdict: Union[dict, str],
- parameters: Union[dict, str, int, None] = None,
+ parameters: Optional[Mapping] = None,
fallback=False) -> str:
"""Return the most appropriate localization from a localization dict.
@@ -610,15 +610,11 @@
return trans
if not isinstance(parameters, Mapping):
- issue_deprecation_warning('parameters not being a mapping',
- warning_class=FutureWarning,
- since='20151008')
- plural_parameters = _PluralMappingAlias(parameters)
- else:
- plural_parameters = parameters
+ raise ValueError('parameters should be a mapping, not {}'
+ .format(type(parameters).__name__))
# else we check for PLURAL variants
- trans = _extract_plural(code, trans, plural_parameters)
+ trans = _extract_plural(code, trans, parameters)
if parameters:
# On error: parameter is for PLURAL variants only,
# don't change the string
@@ -769,9 +765,8 @@
parameters = None
if parameters is not None and not isinstance(parameters, Mapping):
- issue_deprecation_warning('parameters not being a Mapping',
- warning_class=FutureWarning,
- since='20151008')
+ raise ValueError('parameters should be a mapping, not {}'
+ .format(type(parameters).__name__))
if not only_plural and parameters:
return trans % parameters
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693505
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ic9869f12d729d8ec99fb2e96dbef12a5efd7f410
Gerrit-Change-Number: 693505
Gerrit-PatchSet: 1
Gerrit-Owner: Damian <atagar1(a)gmail.com>
Gerrit-Reviewer: Isaacandy <isaac(a)iznd.xyz>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693498 )
Change subject: [cleanup] Remove deprecated LogEntry title method
......................................................................
[cleanup] Remove deprecated LogEntry title method
This method was deprecated almost six years ago. Cleaning it up.
Change-Id: Ie5d35b09b9838258494285bc21f2e7feed4f1c2c
---
M pywikibot/logentries.py
M tests/logentries_tests.py
2 files changed, 1 insertion(+), 32 deletions(-)
Approvals:
JJMC89: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py
index 106448d..4bade5d 100644
--- a/pywikibot/logentries.py
+++ b/pywikibot/logentries.py
@@ -11,7 +11,6 @@
import pywikibot
from pywikibot.backports import List
from pywikibot.exceptions import Error, HiddenKeyError
-from pywikibot.tools import deprecated
_logger = 'wiki'
@@ -102,16 +101,6 @@
return self[self._expected_type]
- @deprecated('page()', since='20150617', future_warning=True)
- def title(self):
- """
- DEPRECATED: Alias for page().
-
- This is going to be replaced by just returning the title as a string
- instead of a Page instance.
- """
- return self.page()
-
def page(self):
"""
Page on which action was performed.
diff --git a/tests/logentries_tests.py b/tests/logentries_tests.py
index f4d5653..990acf2 100644
--- a/tests/logentries_tests.py
+++ b/tests/logentries_tests.py
@@ -17,7 +17,7 @@
UserTargetLogEntry,
)
from tests import unittest_print
-from tests.aspects import DeprecationTestCase, MetaTestCaseClass, TestCase
+from tests.aspects import MetaTestCaseClass, TestCase
class TestLogentriesBase(TestCase):
@@ -284,26 +284,6 @@
self.assertEqual(type(le4), type(le5))
-class TestDeprecatedMethods(TestLogentriesBase, DeprecationTestCase):
-
- """Test cases for deprecated logentry methods."""
-
- def test_logentry_title(self, key):
- """Test title and page return the same instance."""
- # Request multiple log entries in the hope that one might have no
- # title entry
- self._do_test_warning_filename = False # T271044
- for logentry in self.site.logevents(total=5):
- if 'title' in logentry.data: # title may be missing
- self.assertIsInstance(logentry.title(), pywikibot.Page)
- self.assertIs(logentry.title(), logentry.page())
- else:
- with self.assertRaises(KeyError):
- logentry.title()
- self.assertDeprecation() # T271044
- self._reset_messages() # T271044
-
-
if __name__ == '__main__': # pragma: no cover
with suppress(SystemExit):
unittest.main()
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693498
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ie5d35b09b9838258494285bc21f2e7feed4f1c2c
Gerrit-Change-Number: 693498
Gerrit-PatchSet: 2
Gerrit-Owner: Damian <atagar1(a)gmail.com>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693504 )
Change subject: [cleanup] Disallow site to be None when required for regex
......................................................................
[cleanup] Disallow site to be None when required for regex
Our _get_regexes() issued a deprecation warning when a site is required but not
provided. It's time we enforce it.
Change-Id: I56c9c1cff7e8a192d525dd66533c44209e0fc5dc
---
M pywikibot/textlib.py
1 file changed, 2 insertions(+), 6 deletions(-)
Approvals:
JJMC89: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index ae7060d..2b14c97 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -296,12 +296,8 @@
if isinstance(_regex_cache[exc], tuple):
if not site and exc in ('interwiki', 'property', 'invoke',
'category', 'file'):
- issue_deprecation_warning(
- 'site=None',
- "a valid site for '{}' regex".format(exc),
- warning_class=FutureWarning,
- since='20151006')
- site = pywikibot.Site()
+ raise ValueError("Site cannot be None for the '{}' regex"
+ .format(exc))
if (exc, site) not in _regex_cache:
re_text, re_var = _regex_cache[exc]
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693504
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I56c9c1cff7e8a192d525dd66533c44209e0fc5dc
Gerrit-Change-Number: 693504
Gerrit-PatchSet: 1
Gerrit-Owner: Damian <atagar1(a)gmail.com>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged