jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/767278 )
Change subject: add return types for some scalars ......................................................................
add return types for some scalars
Change-Id: Idd9f428c1e2a621bead120d4c75ef342166399f9 --- M pywikibot/data/api.py M pywikibot/families/commons_family.py M pywikibot/families/i18n_family.py M pywikibot/families/lingualibre_family.py M pywikibot/families/omegawiki_family.py M pywikibot/families/osm_family.py M pywikibot/families/vikidia_family.py M pywikibot/families/wikidata_family.py M pywikibot/families/wikihow_family.py M pywikibot/families/wikispore_family.py M pywikibot/families/wikitech_family.py M pywikibot/family.py M pywikibot/page/__init__.py M pywikibot/scripts/generate_family_file.py M pywikibot/scripts/generate_user_files.py M pywikibot/site/_apisite.py M pywikibot/site/_siteinfo.py M pywikibot/specialbots/_upload.py M pywikibot/textlib.py M pywikibot/throttle.py M pywikibot/tools/__init__.py M pywikibot/tools/chars.py M pywikibot/tools/djvu.py M pywikibot/userinterfaces/gui.py M pywikibot/userinterfaces/terminal_interface_base.py M pywikibot/userinterfaces/terminal_interface_unix.py M scripts/commons_information.py M scripts/commonscat.py M scripts/imagetransfer.py M scripts/interwiki.py M scripts/patrol.py M scripts/reflinks.py M scripts/replace.py M scripts/replicate_wiki.py M scripts/weblinkchecker.py 35 files changed, 83 insertions(+), 83 deletions(-)
Approvals: JJMC89: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index 51db7e0..e24f816 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -1567,7 +1567,7 @@ ' ' if message else '')) self.site._relogin()
- def _userinfo_query(self, result): + def _userinfo_query(self, result) -> bool: """Handle userinfo query.""" if self.action == 'query' and 'userinfo' in result.get('query', ()): # if we get passed userinfo in the query result, we can confirm @@ -1604,7 +1604,7 @@ pywikibot.warning('API warning ({}): {}' .format(mod, single_warning))
- def _logged_in(self, code): + def _logged_in(self, code) -> bool: """Check whether user is logged in.
Older wikis returned an error instead of a warning when the request @@ -1631,7 +1631,7 @@ self._relogin(message) return False
- def _internal_api_error(self, code, error, result): + def _internal_api_error(self, code, error, result) -> bool: """Check for internal_api_error_ or readonly and retry.
:raises pywikibot.exceptions.APIMWError: internal_api_error or readonly @@ -2472,7 +2472,7 @@
return None
- def _query_continue(self): + def _query_continue(self) -> bool: if all(key not in self.data[self.continue_name] for key in self.continuekey): pywikibot.log( @@ -2484,7 +2484,7 @@ self._add_continues(query_continue_pair) return False # a new request with query-continue is needed
- def _continue(self): + def _continue(self) -> bool: self._add_continues(self.data['continue']) return False # a new request with continue is needed
diff --git a/pywikibot/families/commons_family.py b/pywikibot/families/commons_family.py index 7ac1656..8db20ad 100644 --- a/pywikibot/families/commons_family.py +++ b/pywikibot/families/commons_family.py @@ -39,7 +39,7 @@ '_default': (('/doc', ), ['commons']), }
- def interface(self, code): + def interface(self, code) -> str: """Return 'DataSite' to enable structured data.
.. versionadded 6.5 diff --git a/pywikibot/families/i18n_family.py b/pywikibot/families/i18n_family.py index 92e670d..584669b 100644 --- a/pywikibot/families/i18n_family.py +++ b/pywikibot/families/i18n_family.py @@ -15,6 +15,6 @@ name = 'i18n' domain = 'translatewiki.net'
- def protocol(self, code): + def protocol(self, code) -> str: """Return https as the protocol for this family.""" return 'https' diff --git a/pywikibot/families/lingualibre_family.py b/pywikibot/families/lingualibre_family.py index 73523ea..7febae9 100644 --- a/pywikibot/families/lingualibre_family.py +++ b/pywikibot/families/lingualibre_family.py @@ -25,10 +25,10 @@
interwiki_forward = 'wikipedia'
- def scriptpath(self, code): + def scriptpath(self, code) -> str: """Return the script path for this family.""" return ''
- def interface(self, code): + def interface(self, code) -> str: """Return 'DataSite'.""" return 'DataSite' diff --git a/pywikibot/families/omegawiki_family.py b/pywikibot/families/omegawiki_family.py index fb2926b..c13103b 100644 --- a/pywikibot/families/omegawiki_family.py +++ b/pywikibot/families/omegawiki_family.py @@ -15,6 +15,6 @@ name = 'omegawiki' domain = 'www.omegawiki.org'
- def scriptpath(self, code): + def scriptpath(self, code) -> str: """Return the script path for this family.""" return '' diff --git a/pywikibot/families/osm_family.py b/pywikibot/families/osm_family.py index 7d66abe..3ff502d 100644 --- a/pywikibot/families/osm_family.py +++ b/pywikibot/families/osm_family.py @@ -44,6 +44,6 @@ 'en': ('In Bearbeitung',), }
- def protocol(self, code): + def protocol(self, code) -> str: """Return https as the protocol for this family.""" return 'https' diff --git a/pywikibot/families/vikidia_family.py b/pywikibot/families/vikidia_family.py index aa765ae..6893c7c 100755 --- a/pywikibot/families/vikidia_family.py +++ b/pywikibot/families/vikidia_family.py @@ -22,6 +22,6 @@ # Sites we want to edit but not count as real languages test_codes = ['central', 'test']
- def protocol(self, code): + def protocol(self, code) -> str: """Return https as the protocol for this family.""" return 'https' diff --git a/pywikibot/families/wikidata_family.py b/pywikibot/families/wikidata_family.py index 06e1391..02ffcf7 100644 --- a/pywikibot/families/wikidata_family.py +++ b/pywikibot/families/wikidata_family.py @@ -41,15 +41,15 @@ 'wikidata': ('wikidata', 'test', 'beta') })
- def interface(self, code): + def interface(self, code) -> str: """Return 'DataSite'.""" return 'DataSite'
- def calendarmodel(self, code): + def calendarmodel(self, code) -> str: """Default calendar model for WbTime datatype.""" return 'http://www.wikidata.org/entity/Q1985727'
- def default_globe(self, code): + def default_globe(self, code) -> str: """Default globe for Coordinate datatype.""" return 'earth'
diff --git a/pywikibot/families/wikihow_family.py b/pywikibot/families/wikihow_family.py index 38d3ab4..7c98124 100644 --- a/pywikibot/families/wikihow_family.py +++ b/pywikibot/families/wikihow_family.py @@ -57,10 +57,10 @@ cls.langs[code] = 'www.' + domain return cls.langs
- def scriptpath(self, code): + def scriptpath(self, code) -> str: """Return the script path for this family.""" return ''
- def protocol(self, code): + def protocol(self, code) -> str: """Return 'https' as the protocol.""" return 'https' diff --git a/pywikibot/families/wikispore_family.py b/pywikibot/families/wikispore_family.py index 7178ea9..2f4681b 100644 --- a/pywikibot/families/wikispore_family.py +++ b/pywikibot/families/wikispore_family.py @@ -23,5 +23,5 @@ 'test': 'wikispore-test.wmflabs.org', }
- def protocol(self, code): + def protocol(self, code) -> str: return 'https' diff --git a/pywikibot/families/wikitech_family.py b/pywikibot/families/wikitech_family.py index 4535f0d..400a237 100644 --- a/pywikibot/families/wikitech_family.py +++ b/pywikibot/families/wikitech_family.py @@ -15,6 +15,6 @@ name = 'wikitech' code = 'en'
- def protocol(self, code): + def protocol(self, code) -> str: """Return the protocol for this family.""" return 'https' diff --git a/pywikibot/family.py b/pywikibot/family.py index 1221fa8..b563673 100644 --- a/pywikibot/family.py +++ b/pywikibot/family.py @@ -743,7 +743,7 @@ """ return '/w'
- def ssl_pathprefix(self, code): + def ssl_pathprefix(self, code) -> str: """The path prefix for secure HTTP access.""" # Override this ONLY if the wiki family requires a path prefix return '' @@ -773,15 +773,15 @@ uri = self.ssl_pathprefix(code) + uri return urlparse.urljoin('{}://{}'.format(protocol, host), uri)
- def path(self, code): + def path(self, code) -> str: """Return path to index.php.""" return '{}/index.php'.format(self.scriptpath(code))
- def querypath(self, code): + def querypath(self, code) -> str: """Return path to query.php.""" return '{}/query.php'.format(self.scriptpath(code))
- def apipath(self, code): + def apipath(self, code) -> str: """Return path to api.php.""" return '{}/api.php'.format(self.scriptpath(code))
@@ -799,7 +799,7 @@ """ raise NotImplementedError('This family does not support EventStreams')
- def get_address(self, code, title): + def get_address(self, code, title) -> str: """Return the path to title using index.php with redirects disabled.""" return '{}?title={}&redirect=no'.format(self.path(code), title)
@@ -889,11 +889,11 @@ """Return the maximum URL length for GET instead of POST.""" return config.maximum_GET_length
- def dbName(self, code): + def dbName(self, code) -> str: """Return the name of the MySQL database.""" return '{}{}'.format(code, self.name)
- def encoding(self, code): + def encoding(self, code) -> str: """Return the encoding for a specific language wiki.""" return 'utf-8'
@@ -930,7 +930,7 @@ """Return the shared image repository, if any.""" return (None, None)
- def isPublic(self, code): + def isPublic(self, code) -> bool: """Check the wiki require logging in before viewing it.""" return True
@@ -1084,7 +1084,7 @@
return {code: cls.domain for code in codes}
- def protocol(self, code): + def protocol(self, code) -> str: """Return 'https' as the protocol.""" return 'https'
@@ -1211,15 +1211,15 @@ """Return Wikimedia Commons as the shared image repository.""" return ('commons', 'commons')
- def protocol(self, code): + def protocol(self, code) -> str: """Return 'https' as the protocol.""" return 'https'
- def eventstreams_host(self, code): + def eventstreams_host(self, code) -> str: """Return 'https://stream.wikimedia.org' as the stream hostname.""" return 'https://stream.wikimedia.org'
- def eventstreams_path(self, code): + def eventstreams_path(self, code) -> str: """Return path for EventStreams.""" return '/v2/stream'
@@ -1229,7 +1229,7 @@ """Single site family for sites hosted at ``*.wikimedia.org``."""
@classproperty - def domain(cls): + def domain(cls) -> str: """Return the parents domain with a subdomain prefix.""" return '{}.wikimedia.org'.format(cls.name)
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py index 8fcbb94..2c87afd 100644 --- a/pywikibot/page/__init__.py +++ b/pywikibot/page/__init__.py @@ -3480,7 +3480,7 @@ del self._content self.latest_revision_id = updates['entity'].get('lastrevid')
- def concept_uri(self): + def concept_uri(self) -> str: """ Return the full concept URI.
@@ -4531,7 +4531,7 @@ return not self.__eq__(other)
@staticmethod - def _claim_mapping_same(this, other): + def _claim_mapping_same(this, other) -> bool: if len(this) != len(other): return False my_values = list(chain.from_iterable(this.values())) @@ -4547,7 +4547,7 @@ return True
def same_as(self, other, ignore_rank=True, ignore_quals=False, - ignore_refs=True): + ignore_refs=True) -> bool: """Check if two claims are same.""" if ignore_rank: attributes = ['id', 'snaktype', 'target'] @@ -5181,7 +5181,7 @@ return '{}:{}'.format(name, self.title) return self.title
- def astext(self, onsite=None): + def astext(self, onsite=None) -> str: """ Return a text representation of the link.
diff --git a/pywikibot/scripts/generate_family_file.py b/pywikibot/scripts/generate_family_file.py index 16753d7..e109e7a 100755 --- a/pywikibot/scripts/generate_family_file.py +++ b/pywikibot/scripts/generate_family_file.py @@ -88,7 +88,7 @@ self.wikis = {} # {'https://wiki/$1': Wiki('https://wiki/$1'), ...} self.langs = [] # [Wiki('https://wiki/$1'), ...]
- def get_params(self): # pragma: no cover + def get_params(self) -> bool: # pragma: no cover """Ask for parameters if necessary.""" if self.base_url is None: self.base_url = input('Please insert URL to wiki: ') diff --git a/pywikibot/scripts/generate_user_files.py b/pywikibot/scripts/generate_user_files.py index 064229a..b4c09c9 100755 --- a/pywikibot/scripts/generate_user_files.py +++ b/pywikibot/scripts/generate_user_files.py @@ -91,7 +91,7 @@ return False
-def file_exists(filename): +def file_exists(filename) -> bool: """Return whether the file exists and print a message if it exists.""" if os.path.exists(filename): pywikibot.output('{1} already exists in the target directory "{0}".' diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py index cd14ab2..5385883 100644 --- a/pywikibot/site/_apisite.py +++ b/pywikibot/site/_apisite.py @@ -279,7 +279,7 @@ return self._request_class({'parameters': kwargs}).create_simple( self, **kwargs)
- def logged_in(self): + def logged_in(self) -> bool: """Verify the bot is logged into the site as the expected user.
The expected usernames are those provided as the user parameter @@ -763,7 +763,7 @@ """ return self.has_all_mediawiki_messages([key], lang=lang)
- def has_all_mediawiki_messages(self, keys, lang=None): + def has_all_mediawiki_messages(self, keys, lang=None) -> bool: """Confirm that the site defines a set of MediaWiki messages.
:param keys: names of MediaWiki messages @@ -970,7 +970,7 @@
return _namespaces
- def has_extension(self, name): + def has_extension(self, name) -> bool: """Determine whether extension `name` is loaded.
:param name: The extension to check for, case sensitive @@ -1230,7 +1230,7 @@ self.loadpageinfo(page) return page._protection
- def page_can_be_edited(self, page, action='edit'): + def page_can_be_edited(self, page, action='edit') -> bool: """Determine if the page can be modified.
Return True if the bot has the permission of needed restriction level diff --git a/pywikibot/site/_siteinfo.py b/pywikibot/site/_siteinfo.py index 5999e1c..90bb9e9 100644 --- a/pywikibot/site/_siteinfo.py +++ b/pywikibot/site/_siteinfo.py @@ -132,7 +132,7 @@ is the default value. :see: https://www.mediawiki.org/wiki/API:Meta#siteinfo_.2F_si """ - def warn_handler(mod, message): + def warn_handler(mod, message) -> bool: """Return True if the warning is handled.""" matched = Siteinfo.WARNING_REGEX.match(message) if mod == 'siteinfo' and matched: diff --git a/pywikibot/specialbots/_upload.py b/pywikibot/specialbots/_upload.py index bb2cd34..4bfb79f 100644 --- a/pywikibot/specialbots/_upload.py +++ b/pywikibot/specialbots/_upload.py @@ -441,7 +441,7 @@
return None
- def skip_run(self): + def skip_run(self) -> bool: """Check whether processing is to be skipped.""" # early check that upload is enabled if self.target_site.is_uploaddisabled(): diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py index 1821fb2..8f4b566 100644 --- a/pywikibot/textlib.py +++ b/pywikibot/textlib.py @@ -1967,7 +1967,7 @@ return (txt, None)
@staticmethod - def _valid_date_dict_positions(dateDict): + def _valid_date_dict_positions(dateDict) -> bool: """Check consistency of reasonable positions for groups.""" time_pos = dateDict['time']['start'] tzinfo_pos = dateDict['tzinfo']['start'] diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py index c9627f1..8c1b764 100644 --- a/pywikibot/throttle.py +++ b/pywikibot/throttle.py @@ -90,7 +90,7 @@
@property @deprecated(since='6.2') - def multiplydelay(self): + def multiplydelay(self) -> bool: """DEPRECATED attribute.""" return True
diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py index c6e476b..685daa5 100644 --- a/pywikibot/tools/__init__.py +++ b/pywikibot/tools/__init__.py @@ -83,7 +83,7 @@ return False
-def has_module(module, version=None): +def has_module(module, version=None) -> bool: """Check if a module can be imported.
.. versionadded:: 3.0 diff --git a/pywikibot/tools/chars.py b/pywikibot/tools/chars.py index 8cc36dd..6ffe762 100644 --- a/pywikibot/tools/chars.py +++ b/pywikibot/tools/chars.py @@ -28,7 +28,7 @@
def replace_invisible(text): """Replace invisible characters by '<codepoint>'.""" - def replace(match): + def replace(match) -> str: match = match.group() if sys.maxunicode < 0x10ffff and len(match) == 2: mask = (1 << 10) - 1 diff --git a/pywikibot/tools/djvu.py b/pywikibot/tools/djvu.py index cfc1c80..d60b6f7 100644 --- a/pywikibot/tools/djvu.py +++ b/pywikibot/tools/djvu.py @@ -243,7 +243,7 @@ return self._remove_control_chars(stdoutdata)
@check_page_number - def whiten_page(self, n): + def whiten_page(self, n) -> bool: """Replace page 'n' of djvu file with a blank page.
:param n: page n of djvu file @@ -294,7 +294,7 @@ return True
@check_page_number - def delete_page(self, n): + def delete_page(self, n) -> bool: """Delete page 'n' of djvu file.
:param n: page n of djvu file diff --git a/pywikibot/userinterfaces/gui.py b/pywikibot/userinterfaces/gui.py index cae3559..c13e761 100644 --- a/pywikibot/userinterfaces/gui.py +++ b/pywikibot/userinterfaces/gui.py @@ -137,24 +137,24 @@ if keylist: self.event_add(event, *keylist)
- def cut(self, event): + def cut(self, event) -> str: """Perform cut operation.""" if self.tag_ranges('sel'): self.event_generate('<<Cut>>') return 'break'
- def copy(self, event): + def copy(self, event) -> str: """Perform copy operation.""" if self.tag_ranges('sel'): self.event_generate('<<Copy>>') return 'break'
- def paste(self, event): + def paste(self, event) -> str: """Perform paste operation.""" self.event_generate('<<Paste>>') return 'break'
- def select_all(self, event=None): + def select_all(self, event=None) -> str: """Perform select all operation.""" self.tag_add('sel', '1.0', 'end-1c') self.mark_set('insert', '1.0') @@ -166,17 +166,17 @@ self.tag_remove('sel', '1.0', 'end') self.see('insert')
- def del_word_left(self, event): + def del_word_left(self, event) -> str: """Perform delete word (left) operation.""" self.event_generate('<Meta-Delete>') return 'break'
- def del_word_right(self, event=None): + def del_word_right(self, event=None) -> str: """Perform delete word (right) operation.""" self.event_generate('<Meta-d>') return 'break'
- def find_event(self, event=None): + def find_event(self, event=None) -> str: """Perform find operation.""" if not self.tag_ranges('sel'): found = self.tag_ranges('found') @@ -187,17 +187,17 @@ SearchDialog.find(self) return 'break'
- def find_again_event(self, event=None): + def find_again_event(self, event=None) -> str: """Perform find again operation.""" SearchDialog.find_again(self) return 'break'
- def find_selection_event(self, event=None): + def find_selection_event(self, event=None) -> str: """Perform find selection operation.""" SearchDialog.find_selection(self) return 'break'
- def replace_event(self, event=None): + def replace_event(self, event=None) -> str: """Perform replace operation.""" ReplaceDialog.replace(self) return 'break' @@ -431,7 +431,7 @@ self.text = self.editbox.get('1.0', tkinter.END) self.parent.destroy()
- def debug(self, event=None): + def debug(self, event=None) -> str: """Call quit() and return 'break'.""" self.quit() return 'break' diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py index 8909aa7..b72fdf8 100755 --- a/pywikibot/userinterfaces/terminal_interface_base.py +++ b/pywikibot/userinterfaces/terminal_interface_base.py @@ -145,7 +145,7 @@ """Optionally encode and write the text to the target stream.""" target_stream.write(text)
- def support_color(self, target_stream): + def support_color(self, target_stream) -> bool: """Return whether the target stream does support colors.""" return False
diff --git a/pywikibot/userinterfaces/terminal_interface_unix.py b/pywikibot/userinterfaces/terminal_interface_unix.py index 2a56196..4174ea5 100755 --- a/pywikibot/userinterfaces/terminal_interface_unix.py +++ b/pywikibot/userinterfaces/terminal_interface_unix.py @@ -34,7 +34,7 @@
"""User interface for Unix terminals."""
- def support_color(self, target_stream): + def support_color(self, target_stream) -> bool: """Return that the target stream supports colors.""" return True
diff --git a/scripts/commons_information.py b/scripts/commons_information.py index baa2637..466ddfe 100755 --- a/scripts/commons_information.py +++ b/scripts/commons_information.py @@ -59,7 +59,7 @@ return langdetect.detect_langs(text) return None
- def process_desc_template(self, template): + def process_desc_template(self, template) -> bool: """Process description template.""" tmp_page = pywikibot.Page(self.site, template.name.strip(), ns=10) if tmp_page in self.lang_tmps and len(template.params) == 1 \ diff --git a/scripts/commonscat.py b/scripts/commonscat.py index b58b6ab..c0430bd 100755 --- a/scripts/commonscat.py +++ b/scripts/commonscat.py @@ -250,7 +250,7 @@ return super().skip_page(page)
@staticmethod - def skipPage(page): + def skipPage(page) -> bool: """Determine if the page should be skipped.""" try: templates_to_ignore = ignoreTemplates[page.site.code] diff --git a/scripts/imagetransfer.py b/scripts/imagetransfer.py index 3f60988..d43edda 100755 --- a/scripts/imagetransfer.py +++ b/scripts/imagetransfer.py @@ -326,7 +326,7 @@ pywikibot.output( color_format('{yellow}No such image number.{default}'))
- def transfer_allowed(self, image): + def transfer_allowed(self, image) -> bool: """Check whether transfer is allowed.""" target_repo = self.opt.target.image_repository()
diff --git a/scripts/interwiki.py b/scripts/interwiki.py index 6e9d5a5..9e2742e 100755 --- a/scripts/interwiki.py +++ b/scripts/interwiki.py @@ -468,7 +468,7 @@ if not self.quiet: pywikibot.output('NOTE: ' + text)
- def readOptions(self, option): + def readOptions(self, option) -> bool: """Read all commandline parameters for the global container.""" arg, _, value = option.partition(':') if not arg.startswith('-'): @@ -779,7 +779,7 @@ self.todo.clear() self.forcedStop = True
- def addIfNew(self, page, counter, linkingPage): + def addIfNew(self, page, counter, linkingPage) -> bool: """ Add the pagelink given to the todo list, if it hasn't been seen yet.
@@ -819,7 +819,7 @@ or self.namespaceMismatch(page, target, counter) \ or self.wiktionaryMismatch(target)
- def namespaceMismatch(self, linkingPage, linkedPage, counter): + def namespaceMismatch(self, linkingPage, linkedPage, counter) -> bool: """ Check whether or not the given page has a different namespace.
@@ -897,7 +897,7 @@ # or no origin page yet, also no problem return False
- def wiktionaryMismatch(self, page): + def wiktionaryMismatch(self, page) -> bool: """Check for ignoring pages.""" if self.origin and self.conf.same == 'wiktionary': if page.title().lower() != self.origin.title().lower(): @@ -999,7 +999,7 @@ # We can follow the page. return (False, None)
- def isIgnored(self, page): + def isIgnored(self, page) -> bool: """Return True if pages is to be ignored.""" if page.site.lang in self.conf.neverlink: pywikibot.output('Skipping link {} to an ignored language' @@ -1547,7 +1547,7 @@ if config.interwiki_backlink: self.reportBacklinks(new, updatedSites)
- def replaceLinks(self, page, newPages): + def replaceLinks(self, page, newPages) -> bool: """Return True if saving was successful.""" # In this case only continue on the Page we started with if self.conf.localonly and page != self.origin: @@ -2012,7 +2012,7 @@ # foreign page queries we can find. return self.maxOpenSite()
- def oneQuery(self): + def oneQuery(self) -> bool: """ Perform one step in the solution process.
@@ -2142,7 +2142,7 @@ return mods, mcomment, adding, removing, modifying
-def botMayEdit(page): +def botMayEdit(page) -> bool: """Test for allowed edits.""" tmpl = [] with suppress(KeyError): diff --git a/scripts/patrol.py b/scripts/patrol.py index 3dacb6f..c087486 100755 --- a/scripts/patrol.py +++ b/scripts/patrol.py @@ -167,7 +167,7 @@ raise pywikibot.error(str(e))
- def in_list(self, pagelist, title): + def in_list(self, pagelist, title) -> bool: """Check if title present in pagelist.""" verbose_output('Checking whitelist for: ' + title)
@@ -259,7 +259,7 @@
return dict(whitelist)
- def is_wikisource_author_page(self, title): + def is_wikisource_author_page(self, title) -> bool: """Patrol a single item.""" if self.site.family.name != 'wikisource': return False @@ -344,7 +344,7 @@ self.page_title = page_title self.linkedpages = None
- def match(self, page_title): + def match(self, page_title) -> bool: """Match page_title to linkedpages elements.""" if page_title == self.page_title: return True diff --git a/scripts/reflinks.py b/scripts/reflinks.py index d42ce0d..23458ce 100755 --- a/scripts/reflinks.py +++ b/scripts/reflinks.py @@ -219,12 +219,12 @@ self.url = re.sub('#.*', '', self.link) self.title = None
- def refTitle(self): + def refTitle(self) -> str: """Return the <ref> with its new title.""" return '<ref{r.name}>[{r.link} {r.title}<!-- {r.comment} -->]</ref>' \ .format(r=self)
- def refLink(self): + def refLink(self) -> str: """No title has been found, return the unbracketed link.""" return '<ref{r.name}>{r.link}</ref>'.format(r=self)
diff --git a/scripts/replace.py b/scripts/replace.py index 00c9419..f19690f 100755 --- a/scripts/replace.py +++ b/scripts/replace.py @@ -458,7 +458,7 @@ 'To resume, use "-xmlstart:{}" on the command line.' .format(entry.title))
- def isTitleExcepted(self, title): + def isTitleExcepted(self, title) -> bool: """ Return True if one of the exceptions applies for the given title.
@@ -771,7 +771,7 @@ summary=self.generate_summary(applied), ignore_save_related_errors=True, **kwargs)
- def user_confirm(self, question): + def user_confirm(self, question) -> bool: """Always return True due to our own input choice.""" return True
diff --git a/scripts/replicate_wiki.py b/scripts/replicate_wiki.py index 8f9a516..9621252 100755 --- a/scripts/replicate_wiki.py +++ b/scripts/replicate_wiki.py @@ -175,7 +175,7 @@ sync_overview_page.text = output sync_overview_page.save(self.put_message(site))
- def put_message(self, site): + def put_message(self, site) -> str: """Return synchronization message.""" return ('{} replicate_wiki.py synchronization from {}' .format(site.user(), str(self.original))) diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py index f8eb86a..2a2a2d1 100755 --- a/scripts/weblinkchecker.py +++ b/scripts/weblinkchecker.py @@ -441,7 +441,7 @@ else: self.history_dict[url] = [(page.title(), now, error)]
- def set_link_alive(self, url): + def set_link_alive(self, url) -> bool: """ Record that the link is now alive.
pywikibot-commits@lists.wikimedia.org