jenkins-bot submitted this change.
[IMPR] Replaced basestring by str
Bug: T265128
Change-Id: I84def45808d3e3c036871c8a6ad472947129b9e8
---
M scripts/cosmetic_changes.py
M scripts/create_categories.py
M scripts/data_ingestion.py
M scripts/delete.py
M scripts/djvutext.py
M scripts/download_dump.py
M scripts/editarticle.py
7 files changed, 22 insertions(+), 26 deletions(-)
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
index a826608..42b5b60 100644
--- a/scripts/cosmetic_changes.py
+++ b/scripts/cosmetic_changes.py
@@ -32,6 +32,8 @@
#
# Distributed under the terms of the MIT license.
#
+from typing import Tuple
+
import pywikibot
from pywikibot import config, cosmetic_changes, i18n, pagegenerators
@@ -76,14 +78,13 @@
asynchronous=self.getOption('async'))
-def main(*args) -> None:
+def main(*args: Tuple[str, ...]) -> None:
"""
Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: str
"""
options = {}
diff --git a/scripts/create_categories.py b/scripts/create_categories.py
index d5bd477..144494c 100755
--- a/scripts/create_categories.py
+++ b/scripts/create_categories.py
@@ -35,6 +35,8 @@
#
# Distributed under the terms of the MIT license.
#
+from typing import Tuple
+
import pywikibot
from pywikibot.bot import AutomaticTWSummaryBot, SingleSiteBot
from pywikibot import pagegenerators
@@ -92,14 +94,13 @@
return super().skip_page(page)
-def main(*args):
+def main(*args: Tuple[str, ...]):
"""
Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: str
"""
options = {}
diff --git a/scripts/data_ingestion.py b/scripts/data_ingestion.py
index 20adb5e..52c2564 100755
--- a/scripts/data_ingestion.py
+++ b/scripts/data_ingestion.py
@@ -106,6 +106,7 @@
import os
import posixpath
+from typing import Tuple
from urllib.parse import urlparse
from warnings import warn
@@ -121,15 +122,13 @@
"""Represents a Photo (or other file), with metadata, to be uploaded."""
- def __init__(self, URL, metadata, site=None):
+ def __init__(self, URL: str, metadata: dict, site=None):
"""
Initializer.
@param URL: URL of photo
- @type URL: str
@param metadata: metadata about the photo that can be referred to
from the title & template
- @type metadata: dict
@param site: target site
@type site: pywikibot.site.APISite
@@ -177,7 +176,7 @@
self.site.allimages(
sha1=base64.b16encode(hashObject.digest()))]
- def getTitle(self, fmt):
+ def getTitle(self, fmt: str) -> str:
"""
Populate format string with %(name)s entries using metadata.
@@ -185,9 +184,7 @@
a MediaWiki page title, and cause an API exception when used.
@param fmt: format string
- @type fmt: str
@return: formatted string
- @rtype: str
"""
# FIXME: normalise the title so it is usable as a MediaWiki title.
return fmt % self.metadata
@@ -223,7 +220,7 @@
"""Data ingestion bot."""
- def __init__(self, reader, titlefmt, pagefmt,
+ def __init__(self, reader, titlefmt: str, pagefmt: str,
site='deprecated_default_commons'):
"""
Initializer.
@@ -231,9 +228,7 @@
@param reader: Generator of Photos to process.
@type reader: Photo page generator
@param titlefmt: Title format
- @type titlefmt: basestring
@param pagefmt: Page format
- @type pagefmt: basestring
@param site: Target site for image upload.
Use None to determine the site from the pages treated.
Defaults to 'deprecated_default_commons' to use Wikimedia Commons
@@ -326,14 +321,13 @@
return configuration
-def main(*args):
+def main(*args: Tuple[str, ...]):
"""
Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: str
"""
# Process global args and prepare generator args parser
local_args = pywikibot.handle_args(args)
diff --git a/scripts/delete.py b/scripts/delete.py
index ac63729..8ef9a94 100755
--- a/scripts/delete.py
+++ b/scripts/delete.py
@@ -58,7 +58,7 @@
#
import collections
-from typing import Set
+from typing import Tuple, Set
import pywikibot
@@ -135,14 +135,13 @@
"""This robot allows deletion of pages en masse."""
- def __init__(self, generator, summary, **kwargs) -> None:
+ def __init__(self, generator, summary: str, **kwargs) -> None:
"""
Initializer.
@param generator: the pages to work on
@type generator: iterable
@param summary: the reason for the (un)deletion
- @type summary: str
"""
self.availableOptions.update({
'undelete': False,
@@ -227,14 +226,13 @@
quit=True)
-def main(*args) -> None:
+def main(*args: Tuple[str, ...]) -> None:
"""
Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: str
"""
page_name = ''
summary = None
diff --git a/scripts/djvutext.py b/scripts/djvutext.py
index 1b30c64..dc879ae 100644
--- a/scripts/djvutext.py
+++ b/scripts/djvutext.py
@@ -34,6 +34,8 @@
#
import os.path
+from typing import Tuple
+
import pywikibot
from pywikibot import i18n
@@ -121,14 +123,13 @@
self.userPut(page, old_text, new_text, summary=summary)
-def main(*args):
+def main(*args: Tuple[str, ...]):
"""
Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: str
"""
index = None
djvu_path = '.' # default djvu file directory
diff --git a/scripts/download_dump.py b/scripts/download_dump.py
index a5f920a..f3e0bbd 100644
--- a/scripts/download_dump.py
+++ b/scripts/download_dump.py
@@ -22,6 +22,7 @@
import os.path
from os import remove, replace, symlink, urandom
+from typing import Tuple
import pywikibot
from pywikibot import Bot
@@ -171,14 +172,13 @@
pywikibot.output('Done! File stored as ' + file_final_storepath)
-def main(*args):
+def main(*args: Tuple[str, ...]):
"""
Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: str
"""
opts = {}
unknown_args = []
diff --git a/scripts/editarticle.py b/scripts/editarticle.py
index c8b768e..5d3064f 100755
--- a/scripts/editarticle.py
+++ b/scripts/editarticle.py
@@ -35,6 +35,8 @@
import sys
import tempfile
+from typing import Tuple
+
import pywikibot
from pywikibot import i18n
@@ -111,14 +113,13 @@
pywikibot.output('Nothing changed')
-def main(*args):
+def main(*args: Tuple[str, ...]):
"""
Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
@param args: command line arguments
- @type args: str
"""
app = ArticleEditor(*args)
app.run()
To view, visit change 634351. To unsubscribe, or for help writing mail filters, visit settings.