Skip to content

Commit

Permalink
Merge "cleanup: remove deprecated RedirectPageBot and NoRedirectPageBot"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Dec 3, 2024
2 parents 27e2c9a + 05a3624 commit e0df256
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 59 deletions.
4 changes: 2 additions & 2 deletions ROADMAP.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Current Release Changes

**Breaking changes and code cleanups**

* 7.2.0: RedirectPageBot and NoRedirectPageBot bot classes were removed in favour of
:attr:`use_redirects<bot.BaseBot.use_redirects>` attribute
* Python 3.7 support was dropped (:phab:`T378893`)


Expand Down Expand Up @@ -95,8 +97,6 @@ Pending removal in Pywikibot 10
* 7.2.0: ``tb`` parameter of :func:`exception()<pywikibot.logging.exception>` function was renamed to ``exc_info``
* 7.2.0: XMLDumpOldPageGenerator is deprecated in favour of a ``content`` parameter of
:func:`XMLDumpPageGenerator<pagegenerators.XMLDumpPageGenerator>` (:phab:`T306134`)
* 7.2.0: RedirectPageBot and NoRedirectPageBot bot classes are deprecated in favour of
:attr:`use_redirects<bot.BaseBot.use_redirects>` attribute
* 7.2.0: :func:`tools.formatter.color_format<tools.formatter.color_format>` is deprecated and will be removed
* 7.1.0: Unused ``get_redirect`` parameter of :meth:`Page.getOldVersion()<page.BasePage.getOldVersion>` will be removed
* 7.0.0: User.isBlocked() method is renamed to is_blocked for consistency
Expand Down
63 changes: 6 additions & 57 deletions pywikibot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ class is mainly used for bots which work with Wikibase or together
subclasses :class:`CurrentPageBot` and automatically defines the summary
when :meth:`put_current` is used.
.. deprecated:: 7.2
The bot classes :class:`RedirectPageBot` and
:class:`NoRedirectPageBot` are deprecated. Use
:attr:`use_redirects<BaseBot.use_redirects>` attribute instead.
.. deprecated:: 9.2
The functions
:func:`critical()<pywikibot.logging.critical>`
Expand All @@ -78,6 +73,11 @@ class is mainly used for bots which work with Wikibase or together
and ``WARNING`` imported from :mod:`logging` module are deprecated
within this module. Import them directly. These functions can also be
used as :mod:`pywikibot` members.
.. versionremoved:: 10.0
The bot classes :class:`RedirectPageBot` and
:class:`NoRedirectPageBot` are deprecated. Use
:attr:`use_redirects<BaseBot.use_redirects>` attribute instead.
"""
#
# (C) Pywikibot team, 2008-2024
Expand Down Expand Up @@ -105,7 +105,6 @@ class is mainly used for bots which work with Wikibase or together
'BaseBot', 'Bot', 'ConfigParserBot', 'SingleSiteBot', 'MultipleSitesBot',
'CurrentPageBot', 'AutomaticTWSummaryBot',
'ExistingPageBot', 'FollowRedirectPageBot', 'CreatingPageBot',
'RedirectPageBot', 'NoRedirectPageBot',
'WikidataBot',
)

Expand Down Expand Up @@ -189,7 +188,7 @@ class is mainly used for bots which work with Wikibase or together
from pywikibot.logging import stdout as _stdout
from pywikibot.logging import warning as _warning
from pywikibot.throttle import Throttle
from pywikibot.tools import issue_deprecation_warning, redirect_func, strtobool
from pywikibot.tools import redirect_func, strtobool
from pywikibot.tools._logging import LoggingFormatter


Expand Down Expand Up @@ -1937,56 +1936,6 @@ def skip_page(self, page: pywikibot.page.BasePage) -> bool:
return super().skip_page(page)


class RedirectPageBot(CurrentPageBot): # pragma: no cover

"""A RedirectPageBot class which only treats redirects.
.. deprecated:: 7.2
use BaseBot attribute
:attr:`use_redirects = True<BaseBot.use_redirects>` instead
"""

def __init__(self, *args, **kwargs):
"""Deprecate RedirectPageBot."""
issue_deprecation_warning('RedirectPageBot',
"BaseBot attribute 'use_redirects = True'",
since='7.2.0')
super().__init__(*args, **kwargs)

def skip_page(self, page: pywikibot.page.BasePage) -> bool:
"""Treat only redirect pages and handle IsNotRedirectPageError."""
if not page.isRedirectPage():
_warning(f'Page {page} on {page.site} is skipped because it is'
' not a redirect')
return True
return super().skip_page(page)


class NoRedirectPageBot(CurrentPageBot): # pragma: no cover

"""A NoRedirectPageBot class which only treats non-redirects.
.. deprecated:: 7.2
use BaseBot attribute
:attr:`use_redirects = False<BaseBot.use_redirects>` instead
"""

def __init__(self, *args, **kwargs):
"""Deprecate NoRedirectPageBot."""
issue_deprecation_warning('NoRedirectPageBot',
"BaseBot attribute 'use_redirects = False'",
since='7.2.0')
super().__init__(*args, **kwargs)

def skip_page(self, page: pywikibot.page.BasePage) -> bool:
"""Treat only non-redirect pages and handle IsRedirectPageError."""
if page.isRedirectPage():
_warning(f'Page {page} on {page.site} is skipped because it is'
' a redirect')
return True
return super().skip_page(page)


class WikidataBot(Bot, ExistingPageBot):

"""Generic Wikidata Bot to be subclassed.
Expand Down

0 comments on commit e0df256

Please sign in to comment.