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