jenkins-bot submitted this change.

View Change

Approvals: JJMC89: Looks good to me, approved jenkins-bot: Verified
add parameter types of int/float/str based on the default values

Change-Id: I456ea45d94bc5c6c28c7b725a34205c0fe468f68
---
M pywikibot/data/api.py
M pywikibot/data/sparql.py
M pywikibot/data/wikistats.py
M pywikibot/family.py
M pywikibot/page/__init__.py
M pywikibot/site/_apisite.py
M pywikibot/site/_datasite.py
M pywikibot/site/_extensions.py
M pywikibot/site/_generators.py
M pywikibot/site/_namespace.py
M pywikibot/site/_obsoletesites.py
M pywikibot/throttle.py
M pywikibot/tools/__init__.py
M pywikibot/tools/_deprecate.py
M pywikibot/tools/djvu.py
M pywikibot/userinterfaces/terminal_interface_base.py
M pywikibot/userinterfaces/win32_unicode.py
M pywikibot/version.py
M scripts/category.py
M scripts/checkimages.py
M scripts/claimit.py
M scripts/commonscat.py
M scripts/delete.py
M scripts/illustrate_wikidata.py
M scripts/interwiki.py
M scripts/listpages.py
M scripts/noreferences.py
M scripts/patrol.py
M scripts/redirect.py
M scripts/solve_disambiguation.py
M scripts/weblinkchecker.py
31 files changed, 175 insertions(+), 99 deletions(-)

diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index e24f816..f362a0c 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1561,7 +1561,7 @@
self.wait()
return None

- def _relogin(self, message='') -> None:
+ def _relogin(self, message: str = '') -> None:
"""Force re-login and inform user."""
pywikibot.error('{}{}Forcing re-login.'.format(message,
' ' if message else ''))
diff --git a/pywikibot/data/sparql.py b/pywikibot/data/sparql.py
index 7277461..c3a44ca 100644
--- a/pywikibot/data/sparql.py
+++ b/pywikibot/data/sparql.py
@@ -180,7 +180,7 @@
data = self.query(query, headers=headers)
return data['boolean']

- def get_items(self, query, item_name='item', result_type=set):
+ def get_items(self, query, item_name: str = 'item', result_type=set):
"""
Retrieve items which satisfy given query.

diff --git a/pywikibot/data/wikistats.py b/pywikibot/data/wikistats.py
index f6db4b4..c56f207 100644
--- a/pywikibot/data/wikistats.py
+++ b/pywikibot/data/wikistats.py
@@ -71,7 +71,7 @@

ALL_KEYS = set(FAMILY_MAPPING.keys()) | ALL_TABLES

- def __init__(self, url='https://wikistats.wmcloud.org/') -> None:
+ def __init__(self, url: str = 'https://wikistats.wmcloud.org/') -> None:
"""Initializer."""
self.url = url
self._data = {}
diff --git a/pywikibot/family.py b/pywikibot/family.py
index b563673..b49f88d 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -620,7 +620,7 @@
Family._families[fam] = cls
return cls

- def linktrail(self, code, fallback='_default'):
+ def linktrail(self, code, fallback: str = '_default'):
"""Return regex for trailing chars displayed as part of a link.

Returns a string, not a compiled regular expression object.
@@ -635,7 +635,7 @@
'ERROR: linktrail in language {language_code} unknown'
.format(language_code=code))

- def category_redirects(self, code, fallback='_default'):
+ def category_redirects(self, code, fallback: str = '_default'):
"""Return list of category redirect templates."""
if not hasattr(self, '_catredirtemplates') \
or code not in self._catredirtemplates:
@@ -681,7 +681,7 @@
"""
return self.archived_page_templates.get(code, ())

- def disambig(self, code, fallback='_default'):
+ def disambig(self, code, fallback: str = '_default'):
"""Return list of disambiguation templates."""
if code in self.disambiguationTemplates:
return self.disambiguationTemplates[code]
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index 2c87afd..15ea6ff 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -135,7 +135,7 @@
'_pageimage', '_item', '_lintinfo',
)

- def __init__(self, source, title='', ns=0) -> None:
+ def __init__(self, source, title: str = '', ns=0) -> None:
"""
Instantiate a Page object.

@@ -2841,7 +2841,7 @@
This class also represents the Wiki page User:<username>
"""

- def __init__(self, source, title='') -> None:
+ def __init__(self, source, title: str = '') -> None:
"""
Initializer for a User object.

@@ -3006,7 +3006,7 @@
"""
return self.getprops(force).get('rights', [])

- def getUserPage(self, subpage=''):
+ def getUserPage(self, subpage: str = ''):
"""
Return a Page object relative to this user's main page.

@@ -3025,7 +3025,7 @@
subpage = '/' + subpage
return Page(Link(self.title() + subpage, self.site))

- def getUserTalkPage(self, subpage=''):
+ def getUserTalkPage(self, subpage: str = ''):
"""
Return a Page object relative to this user's main talk page.

@@ -3574,7 +3574,7 @@

_cache_attrs = BasePage._cache_attrs + ('_content', )

- def __init__(self, site, title='', **kwargs) -> None:
+ def __init__(self, site, title: str = '', **kwargs) -> None:
"""
Initializer.

@@ -4471,7 +4471,7 @@
SNAK_TYPES = ('value', 'somevalue', 'novalue')

def __init__(self, site, pid, snak=None, hash=None, is_reference=False,
- is_qualifier=False, rank='normal', **kwargs) -> None:
+ is_qualifier=False, rank: str = 'normal', **kwargs) -> None:
"""
Initializer.

@@ -4738,14 +4738,19 @@
.format(value, value_class))
self.target = value

- def changeTarget(self, value=None, snaktype='value', **kwargs) -> None:
+ def changeTarget(
+ self,
+ value=None,
+ snaktype: str = 'value',
+ **kwargs
+ ) -> None:
"""
Set the target value in the data repository.

:param value: The new target value.
:type value: object
- :param snaktype: The new snak type.
- :type snaktype: str ('value', 'somevalue', or 'novalue')
+ :param snaktype: The new snak type ('value', 'somevalue', or
+ 'novalue').
"""
if value:
self.setTarget(value)
diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index 5385883..8ca21bd 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -1230,7 +1230,7 @@
self.loadpageinfo(page)
return page._protection

- def page_can_be_edited(self, page, action='edit') -> bool:
+ def page_can_be_edited(self, page, action: str = 'edit') -> bool:
"""Determine if the page can be modified.

Return True if the bot has the permission of needed restriction level
@@ -1485,7 +1485,7 @@

@need_right('deleterevision')
def deleterevs(self, targettype: str, ids, *,
- hide=None, show=None, reason='', target=None):
+ hide=None, show=None, reason: str = '', target=None):
"""Delete or undelete specified page revisions, file versions or logs.

:see: https://www.mediawiki.org/wiki/API:Revisiondelete
diff --git a/pywikibot/site/_datasite.py b/pywikibot/site/_datasite.py
index cd21300..5c2c62f 100644
--- a/pywikibot/site/_datasite.py
+++ b/pywikibot/site/_datasite.py
@@ -177,7 +177,7 @@
raise APIError(data['errors'], '')
return data['entities']

- def preload_entities(self, pagelist, groupsize=50):
+ def preload_entities(self, pagelist, groupsize: int = 50):
"""
Yield subclasses of WikibaseEntity's with content prefilled.

@@ -187,7 +187,6 @@
:param pagelist: an iterable that yields either WikibaseEntity objects,
or Page objects linked to an ItemPage.
:param groupsize: how many pages to query at a time
- :type groupsize: int
"""
if not hasattr(self, '_entity_namespaces'):
self._cache_entity_namespaces()
@@ -329,15 +328,15 @@
entity.latest_revision_id = data['pageinfo']['lastrevid']

@need_right('edit')
- def changeClaimTarget(self, claim, snaktype='value',
+ def changeClaimTarget(self, claim, snaktype: str = 'value',
bot=True, summary=None):
"""
Set the claim target to the value of the provided claim target.

:param claim: The source of the claim target value
:type claim: pywikibot.Claim
- :param snaktype: An optional snaktype. Default: 'value'
- :type snaktype: str ('value', 'novalue' or 'somevalue')
+ :param snaktype: An optional snaktype ('value', 'novalue' or
+ 'somevalue'). Default: 'value'
:param bot: Whether to mark the edit as a bot edit
:type bot: bool
:param summary: Edit summary
diff --git a/pywikibot/site/_extensions.py b/pywikibot/site/_extensions.py
index 0e5e229..63b8df3 100644
--- a/pywikibot/site/_extensions.py
+++ b/pywikibot/site/_extensions.py
@@ -369,9 +369,18 @@
return data['flow']['view-topiclist']['result']['topiclist']

@need_extension('Flow')
- def load_topiclist(self, page, content_format: str = 'wikitext', limit=100,
- sortby='newest', toconly=False, offset=None,
- offset_id=None, reverse=False, include_offset=False):
+ def load_topiclist(
+ self,
+ page,
+ content_format: str = 'wikitext',
+ limit: int = 100,
+ sortby: str = 'newest',
+ toconly=False,
+ offset=None,
+ offset_id=None,
+ reverse=False,
+ include_offset=False
+ ):
"""
Retrieve the topiclist of a Flow board.

@@ -380,9 +389,7 @@
:param content_format: The content format to request the data in.
must be either 'wikitext', 'html', or 'fixed-html'
:param limit: The number of topics to fetch in each request.
- :type limit: int
- :param sortby: Algorithm to sort topics by.
- :type sortby: str (either 'newest' or 'updated')
+ :param sortby: Algorithm to sort topics by ('newest' or 'updated').
:param toconly: Whether to only include information for the TOC.
:type toconly: bool
:param offset: The timestamp to start at (when sortby is 'updated').
diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py
index f3aaa0f..5605f22 100644
--- a/pywikibot/site/_generators.py
+++ b/pywikibot/site/_generators.py
@@ -94,7 +94,7 @@
priority, page = heapq.heappop(prio_queue)
yield page

- def preloadpages(self, pagelist, *, groupsize=50, templates=False,
+ def preloadpages(self, pagelist, *, groupsize: int = 50, templates=False,
langlinks=False, pageprops=False):
"""Return a generator to a list of preloaded pages.

@@ -791,10 +791,21 @@
for linkdata in pageitem['extlinks']:
yield linkdata['*']

- def allpages(self, start='!', prefix='', namespace=0, filterredir=None,
- filterlanglinks=None, minsize=None, maxsize=None,
- protect_type=None, protect_level=None, reverse=False,
- total=None, content=False):
+ def allpages(
+ self,
+ start: str = '!',
+ prefix: str = '',
+ namespace=0,
+ filterredir=None,
+ filterlanglinks=None,
+ minsize=None,
+ maxsize=None,
+ protect_type=None,
+ protect_level=None,
+ reverse=False,
+ total=None,
+ content=False
+ ):
"""Iterate pages in a single namespace.

:see: https://www.mediawiki.org/wiki/API:Allpages
@@ -863,8 +874,15 @@
apgen.request['gapdir'] = 'descending'
return apgen

- def alllinks(self, start='!', prefix='', namespace=0, unique=False,
- fromids=False, total=None):
+ def alllinks(
+ self,
+ start: str = '!',
+ prefix: str = '',
+ namespace=0,
+ unique=False,
+ fromids=False,
+ total=None
+ ):
"""Iterate all links to pages (which need not exist) in one namespace.

Note that, in practice, links that were found on pages that have
@@ -901,7 +919,7 @@
p._fromid = link['fromid']
yield p

- def allcategories(self, start='!', prefix='', total=None,
+ def allcategories(self, start: str = '!', prefix: str = '', total=None,
reverse=False, content=False):
"""Iterate categories used (which need not have a Category page).

@@ -945,7 +963,13 @@

yield from self._bots.values()

- def allusers(self, start='!', prefix='', group=None, total=None):
+ def allusers(
+ self,
+ start: str = '!',
+ prefix: str = '',
+ group=None,
+ total=None
+ ):
"""Iterate registered users, ordered by username.

Iterated values are dicts containing 'name', 'editcount',
@@ -970,9 +994,18 @@
augen.request['augroup'] = group
return augen

- def allimages(self, start='!', prefix='', minsize=None, maxsize=None,
- reverse=False, sha1=None, sha1base36=None,
- total=None, content=False):
+ def allimages(
+ self,
+ start: str = '!',
+ prefix: str = '',
+ minsize=None,
+ maxsize=None,
+ reverse=False,
+ sha1=None,
+ sha1base36=None,
+ total=None,
+ content=False
+ ):
"""Iterate all images, ordered by image title.

Yields FilePages, but these pages need not exist on the wiki.
@@ -2013,7 +2046,7 @@
"""
return self.querypage('Listredirects', total)

- def protectedpages(self, namespace=0, type='edit', level=False,
+ def protectedpages(self, namespace=0, type: str = 'edit', level=False,
total=None):
"""
Return protected pages depending on protection level and type.
diff --git a/pywikibot/site/_namespace.py b/pywikibot/site/_namespace.py
index 120b06b..9a52e73 100644
--- a/pywikibot/site/_namespace.py
+++ b/pywikibot/site/_namespace.py
@@ -278,7 +278,7 @@
return default_case

@classmethod
- def builtin_namespaces(cls, case='first-letter'):
+ def builtin_namespaces(cls, case: str = 'first-letter'):
"""Return a dict of the builtin namespaces."""
return {i: cls(i, case=cls.default_case(i, case))
for i in range(-2, 16)}
diff --git a/pywikibot/site/_obsoletesites.py b/pywikibot/site/_obsoletesites.py
index 40643d4..c5f0a50 100644
--- a/pywikibot/site/_obsoletesites.py
+++ b/pywikibot/site/_obsoletesites.py
@@ -22,7 +22,7 @@
"""Initializer."""
super().__init__(code, fam, user)

- def _closed_error(self, notice='') -> None:
+ def _closed_error(self, notice: str = '') -> None:
"""An error instead of pointless API call."""
pywikibot.error('Site {} has been closed. {}'.format(self.sitename,
notice))
diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py
index 8c1b764..a77ec52 100644
--- a/pywikibot/throttle.py
+++ b/pywikibot/throttle.py
@@ -277,7 +277,7 @@

time.sleep(seconds)

- def __call__(self, requestsize=1, write=False) -> None:
+ def __call__(self, requestsize: int = 1, write=False) -> None:
"""Block the calling program if the throttle time has not expired.

Parameter requestsize is the number of Pages to be read/written;
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index 685daa5..a5367f8 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -151,7 +151,12 @@
.. versionadded:: 3.0
"""

- def __init__(self, message='', category=Warning, filename='') -> None:
+ def __init__(
+ self,
+ message: str = '',
+ category=Warning,
+ filename: str = ''
+ ) -> None:
"""Initialize the object.

The parameter semantics are similar to those of
@@ -159,14 +164,12 @@

:param message: A string containing a regular expression that the start
of the warning message must match. (case-insensitive)
- :type message: str
:param category: A class (a subclass of Warning) of which the warning
category must be a subclass in order to match.
:type category: type
:param filename: A string containing a regular expression that the
start of the path to the warning module must match.
(case-sensitive)
- :type filename: str
"""
self.message_match = re.compile(message, re.I).match
self.category = category
@@ -614,8 +617,8 @@
..versionadded:: 3.0
"""

- def __init__(self, group=None, target=None, name='GeneratorThread',
- args=(), kwargs=None, qsize=65536) -> None:
+ def __init__(self, group=None, target=None, name: str = 'GeneratorThread',
+ args=(), kwargs=None, qsize: int = 65536) -> None:
"""Initializer. Takes same keyword arguments as threading.Thread.

target must be a generator function (or other callable that returns
@@ -624,7 +627,6 @@
:param qsize: The size of the lookahead queue. The larger the qsize,
the more values will be computed in advance of use (which can eat
up memory and processor time).
- :type qsize: int
"""
if kwargs is None:
kwargs = {}
@@ -705,7 +707,7 @@
yield group


-def islice_with_ellipsis(iterable, *args, marker='…'):
+def islice_with_ellipsis(iterable, *args, marker: str = '…'):
"""
Generator which yields the first n elements of the iterable.

@@ -722,7 +724,6 @@
- ``itertools.islice(iterable, start, stop[, step])``
:param marker: element to yield if iterable still contains elements
after showing the required number. Default value: '…'
- :type marker: str
"""
s = slice(*args)
_iterable = iter(iterable)
@@ -754,13 +755,11 @@

_logger = 'threadlist'

- def __init__(self, limit=128, wait_time=2, *args) -> None:
+ def __init__(self, limit: int = 128, wait_time: float = 2, *args) -> None:
"""Initializer.

:param limit: the number of simultaneous threads
- :type limit: int
:param wait_time: how long to wait if active threads exceeds limit
- :type wait_time: int or float
"""
self.limit = limit
self.wait_time = wait_time
@@ -1109,7 +1108,7 @@
return result


-def open_archive(filename, mode='rb', use_extension=True):
+def open_archive(filename, mode: str = 'rb', use_extension=True):
"""
Open a file and uncompress it if needed.

@@ -1132,7 +1131,6 @@
:param mode: The mode in which the file should be opened. It may either be
'r', 'rb', 'a', 'ab', 'w' or 'wb'. All modes open the file in binary
mode. It defaults to 'rb'.
- :type mode: str
:raises ValueError: When 7za is not available or the opening mode is
unknown or it tries to write a 7z archive.
:raises FileNotFoundError: When the filename doesn't exist and it tries
@@ -1240,14 +1238,18 @@
return result


-def file_mode_checker(filename: str, mode=0o600, quiet=False, create=False):
+def file_mode_checker(
+ filename: str,
+ mode: int = 0o600,
+ quiet=False,
+ create=False
+):
"""Check file mode and update it, if needed.

.. versionadded: 3.0

:param filename: filename path
:param mode: requested file mode
- :type mode: int
:param quiet: warn about file mode change if False.
:type quiet: bool
:param create: create the file if it does not exist already
@@ -1270,7 +1272,7 @@
warn(warn_str.format(filename, st_mode - stat.S_IFREG, mode))


-def compute_file_hash(filename: str, sha='sha1', bytes_to_read=None):
+def compute_file_hash(filename: str, sha: str = 'sha1', bytes_to_read=None):
"""Compute file hash.

Result is expressed as hexdigest().
@@ -1281,7 +1283,6 @@
:param sha: hashing function among the following in hashlib:
md5(), sha1(), sha224(), sha256(), sha384(), and sha512()
function name shall be passed as string, e.g. 'sha1'.
- :type sha: str
:param bytes_to_read: only the first bytes_to_read will be considered;
if file size is smaller, the whole file will be considered.
:type bytes_to_read: None or int
diff --git a/pywikibot/tools/_deprecate.py b/pywikibot/tools/_deprecate.py
index 87d2135..bff6759 100644
--- a/pywikibot/tools/_deprecate.py
+++ b/pywikibot/tools/_deprecate.py
@@ -43,7 +43,7 @@
"""


-def add_decorated_full_name(obj, stacklevel=1) -> None:
+def add_decorated_full_name(obj, stacklevel: int = 1) -> None:
"""Extract full object name, including class, and store in __full_name__.

This must be done on all decorators that are chained together, otherwise
@@ -52,7 +52,6 @@
:param obj: An object being decorated
:type obj: object
:param stacklevel: level to use
- :type stacklevel: int
"""
if hasattr(obj, '__full_name__'):
return
diff --git a/pywikibot/tools/djvu.py b/pywikibot/tools/djvu.py
index d60b6f7..debb78e 100644
--- a/pywikibot/tools/djvu.py
+++ b/pywikibot/tools/djvu.py
@@ -12,16 +12,13 @@
import pywikibot


-def _call_cmd(args, lib='djvulibre') -> tuple:
+def _call_cmd(args, lib: str = 'djvulibre') -> tuple:
"""
Tiny wrapper around subprocess.Popen().

:param args: same as Popen()
:type args: str or typing.Sequence[string]
-
:param lib: library to be logged in logging messages
- :type lib: str
-
:return: returns a tuple (res, stdoutdata), where
res is True if dp.returncode != 0 else False
"""
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py
index b72fdf8..4111d08 100755
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -81,7 +81,11 @@
self.cache = []
self.lock = RLock()

- def init_handlers(self, root_logger, default_stream='stderr') -> None:
+ def init_handlers(
+ self,
+ root_logger,
+ default_stream: str = 'stderr'
+ ) -> None:
"""Initialize the handlers for user output.

This method initializes handler(s) for output levels VERBOSE (if
diff --git a/pywikibot/userinterfaces/win32_unicode.py b/pywikibot/userinterfaces/win32_unicode.py
index 6242832..4c67edf 100755
--- a/pywikibot/userinterfaces/win32_unicode.py
+++ b/pywikibot/userinterfaces/win32_unicode.py
@@ -67,7 +67,7 @@

"""Unicode terminal input class."""

- def __init__(self, hConsole, name, bufsize=1024) -> None:
+ def __init__(self, hConsole, name, bufsize: int = 1024) -> None:
"""Initialize the input stream."""
self._hConsole = hConsole
self.bufsize = bufsize
diff --git a/pywikibot/version.py b/pywikibot/version.py
index 5e606dd..a84a536 100644
--- a/pywikibot/version.py
+++ b/pywikibot/version.py
@@ -325,7 +325,7 @@
return (tag, rev, date, hsh)


-def getversion_onlinerepo(path='branches/master'):
+def getversion_onlinerepo(path: str = 'branches/master'):
"""Retrieve current framework git hash from Gerrit."""
from pywikibot.comms import http

diff --git a/scripts/category.py b/scripts/category.py
index ef138cd..eb69f9b 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -303,7 +303,11 @@
This prevents loading the category pages over and over again.
"""

- def __init__(self, rebuild=False, filename='category.dump.bz2') -> None:
+ def __init__(
+ self,
+ rebuild=False,
+ filename: str = 'category.dump.bz2'
+ ) -> None:
"""Initializer."""
if not os.path.isabs(filename):
filename = config.datafilepath(filename)
@@ -1260,7 +1264,13 @@
the tree to stdout.
"""

- def __init__(self, cat_title, cat_db, filename=None, max_depth=10) -> None:
+ def __init__(
+ self,
+ cat_title,
+ cat_db,
+ filename=None,
+ max_depth: int = 10
+ ) -> None:
"""Initializer."""
self.cat_title = cat_title or \
pywikibot.input(
@@ -1277,7 +1287,7 @@
self.max_depth = max_depth
self.site = pywikibot.Site()

- def treeview(self, cat, current_depth=0, parent=None) -> str:
+ def treeview(self, cat, current_depth: int = 0, parent=None) -> str:
"""Return a tree view of all subcategories of cat.

The multi-line string contains a tree view of all subcategories of cat,
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index fb911dd..d097449 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -506,9 +506,15 @@
ignore_save_related_errors = True
ignore_server_errors = False

- def __init__(self, site, log_full_number=25000, sendemail_active=False,
- duplicates_report=False, log_full_error=True,
- max_user_notify=None) -> None:
+ def __init__(
+ self,
+ site,
+ log_full_number: int = 25000,
+ sendemail_active=False,
+ duplicates_report=False,
+ log_full_error=True,
+ max_user_notify=None
+ ) -> None:
"""Initializer, define some instance variables."""
self.site = site
self.log_full_error = log_full_error
diff --git a/scripts/claimit.py b/scripts/claimit.py
index 8ca70de..1e80032 100755
--- a/scripts/claimit.py
+++ b/scripts/claimit.py
@@ -65,13 +65,12 @@

use_from_page = None

- def __init__(self, claims, exists_arg='', **kwargs) -> None:
+ def __init__(self, claims, exists_arg: str = '', **kwargs) -> None:
"""Initializer.

:param claims: A list of wikidata claims
:type claims: list
:param exists_arg: String specifying how to handle duplicate claims
- :type exists_arg: str
"""
self.available_options['always'] = True
super().__init__(**kwargs)
diff --git a/scripts/commonscat.py b/scripts/commonscat.py
index c0430bd..45bd4e2 100755
--- a/scripts/commonscat.py
+++ b/scripts/commonscat.py
@@ -332,8 +332,14 @@
summary=summary)

def changeCommonscat(
- self, page=None, oldtemplate='', oldcat='',
- newtemplate='', newcat='', linktitle='') -> None:
+ self,
+ page=None,
+ oldtemplate: str = '',
+ oldcat: str = '',
+ newtemplate: str = '',
+ newcat: str = '',
+ linktitle: str = ''
+ ) -> None:
"""Change the current commonscat template and target."""
if '3=S' in (oldcat, linktitle):
return # TODO: handle additional param on de-wiki
@@ -448,7 +454,7 @@
commonscatLinktext, commonscatNote)
return None

- def checkCommonscatLink(self, name=''):
+ def checkCommonscatLink(self, name: str = ''):
"""Return the name of a valid commons category.

If the page is a redirect this function tries to follow it.
diff --git a/scripts/delete.py b/scripts/delete.py
index 9e278e9..c08f5fb 100755
--- a/scripts/delete.py
+++ b/scripts/delete.py
@@ -81,7 +81,7 @@
Supports the same interface as Page, with some added methods.
"""

- def __init__(self, source, title='', ns=0) -> None:
+ def __init__(self, source, title: str = '', ns=0) -> None:
"""Initializer."""
super().__init__(source, title, ns)
_cache_attrs = list(super()._cache_attrs)
diff --git a/scripts/illustrate_wikidata.py b/scripts/illustrate_wikidata.py
index 1a19d41..818c5a5 100755
--- a/scripts/illustrate_wikidata.py
+++ b/scripts/illustrate_wikidata.py
@@ -28,11 +28,10 @@

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

- def __init__(self, wdproperty='P18', **kwargs) -> None:
+ def __init__(self, wdproperty: str = 'P18', **kwargs) -> None:
"""Initializer.

:param wdproperty: The property to add. Should be of type commonsMedia
- :type wdproperty: str
"""
super().__init__(**kwargs)
self.wdproperty = wdproperty
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index 9e2742e..98a4250 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -1303,7 +1303,7 @@
if createneed:
self.problemfound = True

- def whereReport(self, page, indent=4) -> None:
+ def whereReport(self, page, indent: int = 4) -> None:
"""Report found interlanguage links with conflicts."""
for page2 in sorted(self.found_in[page]):
if page2 is None:
@@ -2067,11 +2067,11 @@
"""Check whether there is still more work to do."""
return not self and self.pageGenerator is None

- def plus(self, site, count=1) -> None:
+ def plus(self, site, count: int = 1) -> None:
"""Helper routine that the Subject class expects in a counter."""
self.counts[site] += count

- def minus(self, site, count=1) -> None:
+ def minus(self, site, count: int = 1) -> None:
"""Helper routine that the Subject class expects in a counter."""
self.counts[site] -= count
self.counts = +self.counts # remove zero and negative counts
diff --git a/scripts/listpages.py b/scripts/listpages.py
index 6d2aa0e..df8c1f6 100755
--- a/scripts/listpages.py
+++ b/scripts/listpages.py
@@ -120,7 +120,7 @@
# Identify which formats need outputlang
fmt_need_lang = [k for k, v in fmt_options.items() if 'trs_title' in v]

- def __init__(self, page, outputlang=None, default='******') -> None:
+ def __init__(self, page, outputlang=None, default: str = '******') -> None:
"""
Initializer.

@@ -152,7 +152,7 @@
except Error:
self.trs_title = '{}:{}'.format(default, page._link.title)

- def output(self, num=None, fmt='1') -> str:
+ def output(self, num=None, fmt: str = '1') -> str:
"""Output formatted string."""
fmt = self.fmt_options.get(fmt, fmt)
# If selected format requires trs_title, outputlang must be set.
diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index 036f1d2..f44e1ab 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -684,7 +684,7 @@
index = len(tmpText)
return self.createReferenceSection(oldText, index)

- def createReferenceSection(self, oldText, index, ident='==') -> str:
+ def createReferenceSection(self, oldText, index, ident: str = '==') -> str:
"""Create a reference section and insert it into the given text.

:param oldText: page text that is going to be be amended
@@ -694,7 +694,6 @@
:type index: int
:param ident: symbols to be inserted before and after reference section
title
- :type ident: str
:return: the amended page text with reference section added
"""
if self.site.code in noTitleRequired:
diff --git a/scripts/patrol.py b/scripts/patrol.py
index c087486..921df43 100755
--- a/scripts/patrol.py
+++ b/scripts/patrol.py
@@ -370,7 +370,7 @@
return False


-def api_feed_repeater(gen, delay=0, repeat=False, namespaces=None,
+def api_feed_repeater(gen, delay: float = 0, repeat=False, namespaces=None,
user=None, recent_new_gen=True):
"""Generator which loads pages details to be processed."""
while True:
diff --git a/scripts/redirect.py b/scripts/redirect.py
index c928e08..7ed9702 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -229,8 +229,10 @@
if chunk:
yield chunk

- def get_redirects_via_api(self, maxlen=8) -> Generator[Tuple[
- str, Optional[int], str, Optional[str]], None, None]:
+ def get_redirects_via_api(
+ self,
+ maxlen: int = 8
+ ) -> Generator[Tuple[str, Optional[int], str, Optional[str]], None, None]:
r"""
Return a generator that yields tuples of data about redirect Pages.

diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py
index 7d2bcd8..83d4bb0 100755
--- a/scripts/solve_disambiguation.py
+++ b/scripts/solve_disambiguation.py
@@ -394,8 +394,13 @@

"""Referring Page generator, with an ignore manager."""

- def __init__(self, page, primary=False, minimum=0, main_only=False
- ) -> None:
+ def __init__(
+ self,
+ page,
+ primary=False,
+ minimum: int = 0,
+ main_only=False
+ ) -> None:
"""Initializer.

:type page: pywikibot.Page
@@ -1189,8 +1194,13 @@
self.opt.pos += links
return True

- def setSummaryMessage(self, page, new_targets=None, unlink_counter=0,
- dn=False) -> None:
+ def setSummaryMessage(
+ self,
+ page,
+ new_targets=None,
+ unlink_counter: int = 0,
+ dn=False
+ ) -> None:
"""Setup i18n summary message."""
new_targets = new_targets or []
# make list of new targets
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py
index 2a2a2d1..1daa12b 100755
--- a/scripts/weblinkchecker.py
+++ b/scripts/weblinkchecker.py
@@ -567,7 +567,7 @@
It uses several LinkCheckThreads at once to process pages from generator.
"""

- def __init__(self, http_ignores=None, day=7, **kwargs) -> None:
+ def __init__(self, http_ignores=None, day: int = 7, **kwargs) -> None:
"""Initializer."""
super().__init__(**kwargs)


To view, visit change 767441. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I456ea45d94bc5c6c28c7b725a34205c0fe468f68
Gerrit-Change-Number: 767441
Gerrit-PatchSet: 3
Gerrit-Owner: JJMC89 <JJMC89.Wikimedia@gmail.com>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia@gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged