jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693497 )

Change subject: [cleanup] Remove deprecated MultipleSitesBot site attribute
......................................................................

[cleanup] Remove deprecated MultipleSitesBot site attribute

Our MultipleSitesBot's site attribute has been deprecated for almost six years.
Without it the class is no different from a BaseBot.

The bot module's class hierarchy could probably due with some rethought, but
for the moment simply cleaning up the deprecated code.

Bug: T283209
Change-Id: If241556cba23eb34e3a5835d5c285e4973bf8c2f
---
M pywikibot/bot.py
M tests/bot_tests.py
2 files changed, 4 insertions(+), 41 deletions(-)

Approvals:
  JJMC89: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 33b89d4..54918d4 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -1677,37 +1677,6 @@
     information on only one site.
     """

-    def __init__(self, **kwargs):
-        """Initializer."""
-        self._site = None
-        super().__init__(**kwargs)
-
-    @property
-    @deprecated("the page's site property", since='20150615',
-                future_warning=True)
-    def site(self):
-        """
-        Return the site if it's set and ValueError otherwise.
-
-        The site is only defined while in treat and it is preferred to use
-        the page's site instead.
-        """
-        if self._site is None:
-            raise ValueError('Requesting the site not while in treat is not '
-                             'allowed.')
-        return self._site
-
-    def run(self):
-        """Reset the bot's site after run."""
-        super().run()
-        self._site = None
-
-    def init_page(self, item):
-        """Define the site for this page."""
-        page = super().init_page(item)
-        self._site = page.site
-        return page
-

 class ConfigParserBot(BaseBot):

diff --git a/tests/bot_tests.py b/tests/bot_tests.py
index 53d9b96..df13919 100644
--- a/tests/bot_tests.py
+++ b/tests/bot_tests.py
@@ -10,7 +10,6 @@
 import pywikibot
 import pywikibot.bot
 from pywikibot import i18n
-from pywikibot.tools import suppress_warnings

 from tests.aspects import (
     DefaultSiteTestCase,
@@ -120,13 +119,16 @@

         Afterwards it calls post_treat so it's possible to do additional
         checks.
+
+        Site attributes are only present on Bot and SingleSitesBot, not
+        MultipleSitesBot.
         """
         def treat(page):
             self.assertEqual(page, next(self._page_iter))
             if self._treat_site is None:
                 self.assertFalse(hasattr(self.bot, 'site'))
                 self.assertFalse(hasattr(self.bot, '_site'))
-            else:
+            elif not isinstance(self.bot, pywikibot.bot.MultipleSitesBot):
                 self.assertIsNotNone(self.bot._site)
                 self.assertEqual(self.bot.site, self.bot._site)
                 if self._treat_site:
@@ -223,23 +225,15 @@
         self.bot.run()
         self.assertEqual(self.bot.site, self._treat_site)

-    @suppress_warnings('pywikibot.bot.MultipleSitesBot.site is deprecated')
     def test_MultipleSitesBot(self):
         """Test MultipleSitesBot class."""
         # Assert no specific site
         self._treat_site = False
         self.bot = pywikibot.bot.MultipleSitesBot(generator=self._generator())
-        with self.assertRaisesRegex(AttributeError,
-                                    self.CANT_SET_ATTRIBUTE_RE):
-            self.bot.site = self.de
-        with self.assertRaisesRegex(ValueError, self.NOT_IN_TREAT_RE):
-            self.bot.site

         self.bot.treat = self._treat(self._generator())
         self.bot.exit = self._exit(4)
         self.bot.run()
-        with self.assertRaisesRegex(ValueError, self.NOT_IN_TREAT_RE):
-            self.bot.site

     def test_Bot(self):
         """Test normal Bot class."""

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/693497
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: If241556cba23eb34e3a5835d5c285e4973bf8c2f
Gerrit-Change-Number: 693497
Gerrit-PatchSet: 4
Gerrit-Owner: Damian <[email protected]>
Gerrit-Reviewer: JJMC89 <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to