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

Change subject: Update harvest_template for py3
......................................................................

Update harvest_template for py3

Bug: T257399
Change-Id: If5948ecb6023d805a767c0daa8a7e64ffd5ea4d9
---
M scripts/harvest_template.py
1 file changed, 13 insertions(+), 11 deletions(-)

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



diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py
index e8606de..9f0d587 100755
--- a/scripts/harvest_template.py
+++ b/scripts/harvest_template.py
@@ -92,11 +92,12 @@
 #
 # Distributed under the terms of MIT License.
 #
-from __future__ import absolute_import, division, unicode_literals
-
 import signal

+from typing import Any, List, Optional
+
 import pywikibot
+
 from pywikibot import pagegenerators as pg, textlib
 from pywikibot.bot import WikidataBot, OptionHandler

@@ -104,7 +105,7 @@
 willstop = False


-def _signal_handler(signal, frame):
+def _signal_handler(signal, frame) -> None:
     global willstop
     if not willstop:
         willstop = True
@@ -134,7 +135,7 @@

     """A bot to add Wikidata claims."""

-    def __init__(self, generator, template_title, fields, **kwargs):
+    def __init__(self, generator, template_title, fields, **kwargs) -> None:
         """
         Initializer.

@@ -162,7 +163,7 @@
             'islink': False,
             'multi': False,
         })
-        super(HarvestRobot, self).__init__(**kwargs)
+        super().__init__(**kwargs)
         self.generator = generator
         # TODO: Make it a list including the redirects to the template
         self.fields = {}
@@ -177,7 +178,7 @@
         self.linkR = textlib.compileLinkR()
         self.create_missing_item = self.getOption('create')

-    def getTemplateSynonyms(self, title):
+    def getTemplateSynonyms(self, title) -> List[str]:
         """Fetch redirects of the title, so we can check against them."""
         temp = pywikibot.Page(pywikibot.Site(), title, ns=10)
         if not temp.exists():
@@ -196,7 +197,8 @@
         titles.append(temp.title(with_ns=False))
         return titles

-    def _template_link_target(self, item, link_text):
+    def _template_link_target(self, item, link_text
+                              ) -> Optional[pywikibot.ItemPage]:
         link = pywikibot.Link(link_text)
         linked_page = pywikibot.Page(link)
         try:
@@ -231,7 +233,7 @@

         return linked_item

-    def _get_option_with_fallback(self, handler, option):
+    def _get_option_with_fallback(self, handler, option) -> Any:
         """
         Compare bot's (global) and provided (local) options.

@@ -244,7 +246,7 @@
         else:
             return local or default

-    def treat_page_and_item(self, page, item):
+    def treat_page_and_item(self, page, item) -> None:
         """Process a single page/item."""
         if willstop:
             raise KeyboardInterrupt
@@ -349,7 +351,7 @@
                     item, claim, exists_arg, page.site, pywikibot.output)


-def main(*args):
+def main(*args) -> None:
     """
     Process command line arguments and invoke bot.

@@ -409,7 +411,7 @@
         fields[current_args[0]] = (current_args[1], handler)
     elif len(current_args) == 1:
         pywikibot.error('Incomplete command line param-property pair.')
-        return False
+        return

     if not template_title:
         pywikibot.error(

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/611810
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: If5948ecb6023d805a767c0daa8a7e64ffd5ea4d9
Gerrit-Change-Number: 611810
Gerrit-PatchSet: 1
Gerrit-Owner: JJMC89 <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to