jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[IMPR] Replaced basestring by str

Bug: T265128
Change-Id: Ib43659d1ac070c37912559994ae4d9bf30798192
---
M pywikibot/config2.py
M pywikibot/cosmetic_changes.py
M pywikibot/date.py
M pywikibot/diff.py
4 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index cfc3d68..f65d25e 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -48,7 +48,7 @@
from locale import getdefaultlocale
from os import getenv, environ
from textwrap import fill
-from typing import Dict, List, Tuple
+from typing import Dict, List, Optional, Tuple
from warnings import warn

from pywikibot.__metadata__ import __version__ as pwb_version
@@ -271,7 +271,7 @@
return os.path.join(os.path.expanduser('~'), path)


-def get_base_dir(test_directory=None):
+def get_base_dir(test_directory: Optional[str] = None) -> str:
r"""Return the directory in which user-specific information is stored.

This is determined in the following order:
@@ -292,8 +292,6 @@
@param test_directory: Assume that a user config file exists in this
directory. Used to test whether placing a user config file in this
directory will cause it to be selected as the base directory.
- @type test_directory: str or None
- @rtype: str
"""
def exists(directory):
directory = os.path.abspath(directory)
@@ -883,7 +881,7 @@
# #############################################


-def makepath(path, create=True):
+def makepath(path: str, create: bool = True):
"""Return a normalized absolute version of the path argument.

If the given path already exists in the filesystem or create is False
@@ -895,10 +893,8 @@
from holger@trillke.net 2002/03/18

@param path: path in the filesystem
- @type path: str
@param create: create the directory if it is True. Otherwise do not change
the filesystem. Default is True.
- @type create: bool
"""
dpath = os.path.normpath(os.path.dirname(path))
if create and not os.path.exists(dpath):
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index b5406d6..f84d6c8 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -480,7 +480,7 @@
return textlib.replaceExcept(
text, regex, replace_magicword, exceptions)

- def cleanUpLinks(self, text):
+ def cleanUpLinks(self, text: str) -> str:
"""Tidy up wikilinks found in a string.

This function will:
@@ -497,9 +497,7 @@
* Capitalize the article title of the link, if appropriate

@param text: string to perform the clean-up on
- @type text: str
@return: text with tidied wikilinks
- @rtype: str
"""
# helper function which works on one link and either returns it
# unmodified, or returns a replacement.
diff --git a/pywikibot/date.py b/pywikibot/date.py
index 848a08e..7b9d641 100644
--- a/pywikibot/date.py
+++ b/pywikibot/date.py
@@ -1814,7 +1814,7 @@
formats[monthOfYear] = {}


-def addFmt1(lang, isMnthOfYear, patterns):
+def addFmt1(lang: str, isMnthOfYear, patterns):
"""Add 12 month formats for a specific type ('January', 'Feb.').

The function must accept one parameter for the ->int or ->string
@@ -1822,7 +1822,6 @@
The patterns parameter is a list of 12 elements to be used for each month.

@param lang: language code
- @type lang: str
"""
assert len(patterns) == 12, 'pattern %s does not have 12 elements' % lang

@@ -2234,7 +2233,6 @@
"""Format a date localized to given lang.

@param month: month in range of 1..12
- @type month: int
@param day: day of month in range of 1..31
@type day: int
@param lang: a site object or language key. Defaults to current site.
diff --git a/pywikibot/diff.py b/pywikibot/diff.py
index 3b48a05..a77918d 100644
--- a/pywikibot/diff.py
+++ b/pywikibot/diff.py
@@ -579,7 +579,7 @@
return text


-def html_comparator(compare_string):
+def html_comparator(compare_string: str) -> dict:
"""List of added and deleted contexts from 'action=compare' html string.

This function is useful when combineds with site.py's "compare" method.
@@ -587,9 +587,7 @@
Here we use BeautifulSoup to get the un-HTML-ify the context of changes.
Finally we present the added and deleted contexts.
@param compare_string: HTML string from mediawiki API
- @type compare_string: str
@return: deleted and added list of contexts
- @rtype: dict
"""
from bs4 import BeautifulSoup


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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ib43659d1ac070c37912559994ae4d9bf30798192
Gerrit-Change-Number: 634785
Gerrit-PatchSet: 4
Gerrit-Owner: Udoka <UdokakuUgochukwu@gmail.com>
Gerrit-Reviewer: Reviewer-bot <gerritreviewerbot@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged