jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/735987 )
Change subject: [cleanup] Deprecate boolean watch parameter in Page.save() ......................................................................
[cleanup] Deprecate boolean watch parameter in Page.save()
Change-Id: I3d00cbcdf8410ff90768238df50222eeb2f7fb3c --- M pywikibot/page/__init__.py 1 file changed, 16 insertions(+), 13 deletions(-)
Approvals: JJMC89: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py index 59d5781..f70199f 100644 --- a/pywikibot/page/__init__.py +++ b/pywikibot/page/__init__.py @@ -1132,16 +1132,21 @@
def save(self, summary: Optional[str] = None, - watch: Union[str, bool, None] = None, + watch: Optional[str] = None, minor: bool = True, botflag: Optional[bool] = None, force: bool = False, asynchronous: bool = False, - callback=None, apply_cosmetic_changes=None, - quiet: bool = False, **kwargs): + callback=None, + apply_cosmetic_changes: Optional[bool] = None, + quiet: bool = False, + **kwargs): """ Save the current contents of page's text to the wiki.
+ .. versionchanged:: 7.0 + boolean watch parameter is deprecated + :param summary: The edit summary for the modification (optional, but most wikis strongly encourage its use) :param watch: Specify how the watchlist is affected by this edit, set @@ -1151,11 +1156,6 @@ * preferences: use the preference settings (Default) * nochange: don't change the watchlist If None (default), follow bot account's default settings - - For backward compatibility watch parameter may also be boolean: - if True, add or if False, remove this Page to/from bot - user's watchlist. - :type watch: str, bool (deprecated) or None :param minor: if True, mark this edit as minor :param botflag: if True, mark this edit as made by a bot (default: True if user has bot status, False if not) @@ -1170,7 +1170,6 @@ successful. :param apply_cosmetic_changes: Overwrites the cosmetic_changes configuration value to this value unless it's None. - :type apply_cosmetic_changes: bool or None :param quiet: enable/disable successful save operation message; defaults to False. In asynchronous mode, if True, it is up to the calling bot to @@ -1178,10 +1177,14 @@ """ if not summary: summary = config.default_edit_summary - if watch is True: - watch = 'watch' - elif watch is False: - watch = 'unwatch' + + if isinstance(watch, bool): + issue_deprecation_warning( + 'boolean watch parameter', + '"watch", "unwatch", "preferences" or "nochange" value', + since='7.0.0') + watch = ('unwatch', 'watch')[watch] + if not force and not self.botMayEdit(): raise OtherPageSaveError( self, 'Editing restricted by {{bots}}, {{nobots}} '
pywikibot-commits@lists.wikimedia.org