jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1033678?usp=email )
Change subject: [cleanup] remove arguments cleanup introduced with pwb 6.0.0
......................................................................
[cleanup] remove arguments cleanup introduced with pwb 6.0.0
Change-Id: I1ccc08b60e126397377707569cb31040bd9697cd
---
M scripts/solve_disambiguation.py
1 file changed, 4 insertions(+), 74 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py
index ac7f4ad..26c1dae 100755
--- a/scripts/solve_disambiguation.py
+++ b/scripts/solve_disambiguation.py
@@ -75,7 +75,7 @@
"""
#
-# (C) Pywikibot team, 2003-2023
+# (C) Pywikibot team, 2003-2024
#
# Distributed under the terms of the MIT license.
#
@@ -107,7 +107,7 @@
NoPageError,
PageSaveRelatedError,
)
-from pywikibot.tools import first_lower, first_upper, issue_deprecation_warning
+from pywikibot.tools import first_lower, first_upper
from pywikibot.tools.formatter import SequenceOutputter
@@ -610,7 +610,7 @@
}
# refer -help message for complete options documentation
- disambig_options = {
+ available_options = {
'always': None, # always perform the same action
'pos': [], # add possibilities as alternative disambig
'just': True, # just and only use the possibilities given with command
@@ -621,83 +621,13 @@
'min': 0, # minimum number of pages on a disambig
}
- # needed for argument cleanup
- available_options = disambig_options
-
def __init__(self, *args, **kwargs) -> None:
"""Initializer."""
- self._clean_args(args, kwargs)
- super().__init__(**kwargs)
+ super().__init__(*args, **kwargs)
self.ignores = set()
self.summary = None
self.dn_template_str = i18n.translate(self.site, dn_template)
- def _clean_args(self, args, kwargs) -> None:
- """Cleanup positional and keyword arguments.
-
- Replace positional arguments with keyword arguments.
- Replace old keywords with new keywords which are given by
- argument handling.
-
- This also fixes arguments which aren't currently used by
- BaseDisambigBot abstract class but was introduced for the old
- DisambiguationRobot to prevent multiple deprecation warnings.
- """
- # New keys of positional arguments
- keys = ('always', 'pos', 'just', 'dnskip', 'generator', 'primary',
- 'main', 'first', 'min')
-
- # Keys mapping from old argument name to new keywords.
- # The ordering of dics is not safe for Python < 3.7. Therefore
- # we need a dict in addition to key above.
- keymap = {
- 'alternatives': 'pos',
- 'getAlternatives': 'just',
- 'dnSkip': 'dnskip',
- 'main_only': 'main',
- 'first_only': 'first',
- 'minimum': 'min',
- }
-
- # Replace positional arguments with keyword arguments
- for i, arg in enumerate(args):
- key = keys[i]
- issue_deprecation_warning(
- f'Positional argument {i + 1} ({arg})',
- f'keyword argument "{key}={arg}"',
- since='6.0.0')
- if key in kwargs:
- pywikibot.warning('{!r} is given as keyword argument {!r} '
- 'already; ignoring {!r}'
- .format(key, arg, kwargs[key]))
- else:
- kwargs[key] = arg
-
- # replace old keywords to new
- for key in list(kwargs):
- if key in keymap:
- newkey = keymap[key]
- issue_deprecation_warning(
- f'{key!r} argument of {self.__class__.__name__}',
- repr(newkey), since='6.0.0')
- kwargs[newkey] = kwargs.pop(key)
-
- # Expand available_options
- # Currently scripts may have its own options set
- added_keys = []
- for key in keys:
- if key != 'generator' and key not in self.available_options:
- added_keys.append(key)
- self.available_options[key] = self.disambig_options[key]
- if added_keys:
- pywikibot.warning("""\
-The following keys were added to available_options:
-{options}.
-Either add them to available_options setting of {classname}
-bot class or use available_options.update() to use default settings from
-DisambiguationRobot""".format(options=added_keys,
- classname=self.__class__.__name__))
-
def checkContents(self, text: str) -> str | None: # noqa: N802
"""
Check if the text matches any of the ignore regexes.
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1033678?usp=email
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: I1ccc08b60e126397377707569cb31040bd9697cd
Gerrit-Change-Number: 1033678
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]