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

Change subject: [IMPR] Replaced basestring by str
......................................................................

[IMPR] Replaced basestring by str

Bug: T265128
Change-Id: I6487433ca0cc3cde522f45fdabb557d734d43bea
---
M pywikibot/editor.py
M pywikibot/exceptions.py
M pywikibot/family.py
M pywikibot/flow.py
M pywikibot/interwiki_graph.py
M pywikibot/logentries.py
6 files changed, 36 insertions(+), 75 deletions(-)

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



diff --git a/pywikibot/editor.py b/pywikibot/editor.py
index a95401d..97528fc 100644
--- a/pywikibot/editor.py
+++ b/pywikibot/editor.py
@@ -76,7 +76,8 @@
         """Return editor selected in user-config.py."""
         return TextEditor._concat(self._command(tempFilename, text, jumpIndex))

-    def edit(self, text: str, jumpIndex=None, highlight=None) -> Optional[str]:
+    def edit(self, text: str, jumpIndex: Optional[int] = None,
+             highlight: Optional[str] = None) -> Optional[str]:
         """
         Call the editor and thus allows the user to change the text.

@@ -84,9 +85,7 @@

         @param text: the text to be edited
         @param jumpIndex: position at which to put the caret
-        @type jumpIndex: int
         @param highlight: each occurrence of this substring will be highlighted
-        @type highlight: str
         @return: the modified text, or None if the user didn't save the text
             file in his text editor
         """
diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index 9a9dd28..662a1dd 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -87,7 +87,7 @@
 #
 # Distributed under the terms of the MIT license.
 #
-from typing import Optional
+from typing import Optional, Union

 from pywikibot.tools import deprecated, _NotImplementedWarning

@@ -190,11 +190,10 @@

     message = 'Edit to page %(title)s failed:\n%(reason)s'

-    def __init__(self, page, reason):
+    def __init__(self, page, reason: Union[str, Exception]):
         """Initializer.

         @param reason: Details of the problem
-        @type reason: Exception or basestring
         """
         self.reason = reason
         super().__init__(page)
@@ -247,13 +246,12 @@

     """Page receives a title inconsistent with query."""

-    def __init__(self, page, actual):
+    def __init__(self, page, actual: str):
         """Initializer.

         @param page: Page that caused the exception
         @type page: Page object
         @param actual: title obtained by query
-        @type actual: basestring

         """
         self.message = "Query on %s returned data on '{0}'".format(actual)
diff --git a/pywikibot/family.py b/pywikibot/family.py
index 7b1d78b..1aea0c0 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -681,11 +681,10 @@

     @staticmethod
     @deprecated_args(fatal=None)
-    def load(fam=None):
+    def load(fam: Optional[str] = None):
         """Import the named family.

         @param fam: family name (if omitted, uses the configured default)
-        @type fam: str
         @return: a Family instance configured for the named family.
         @raises pywikibot.exceptions.UnknownFamily: family not known
         """
@@ -827,27 +826,23 @@
             .format(code))

     # Methods
-    def protocol(self, code):
+    def protocol(self, code: str) -> str:
         """
         The protocol to use to connect to the site.

         May be overridden to return 'https'. Other protocols are not supported.

         @param code: language code
-        @type code: str
         @return: protocol that this family uses
-        @rtype: str
         """
         return 'http'

-    def ignore_certificate_error(self, code):
+    def ignore_certificate_error(self, code: str) -> bool:
         """
         Return whether a HTTPS certificate error should be ignored.

         @param code: language code
-        @type code: str
         @return: flag to allow access if certificate has an error.
-        @rtype: bool
         """
         return False

@@ -859,7 +854,7 @@
         """The hostname to use for SSL connections."""
         return self.hostname(code)

-    def scriptpath(self, code):
+    def scriptpath(self, code: str) -> str:
         """The prefix used to locate scripts on this wiki.

         This is the value displayed when you enter {{SCRIPTPATH}} on a
@@ -871,10 +866,8 @@
         uses a different value.

         @param code: Site code
-        @type code: str
         @raises KeyError: code is not recognised
         @return: URL path without ending '/'
-        @rtype: str
         """
         return '/w'

@@ -893,18 +886,15 @@
             host = self.hostname(code)
         return protocol, host

-    def base_url(self, code, uri, protocol=None):
+    def base_url(self, code: str, uri: str, protocol=None) -> str:
         """
         Prefix uri with port and hostname.

         @param code: The site code
-        @type code: str
         @param uri: The absolute path after the hostname
-        @type uri: str
         @param protocol: The protocol which is used. If None it'll determine
             the protocol from the code.
         @return: The full URL ending with uri
-        @rtype: str
         """
         protocol, host = self._hostname(code, protocol)
         if protocol == 'https':
@@ -964,7 +954,7 @@

         return config.site_interface

-    def from_url(self, url):
+    def from_url(self, url: str) -> Optional[str]:
         """
         Return whether this family matches the given url.

@@ -980,10 +970,8 @@
         @param url: the URL which may contain a C{$1}. If it's missing it is
             assumed to be at the end and if it's present nothing is allowed
             after it.
-        @type url: str
         @return: The language code of the url. None if that url is not from
             this family.
-        @rtype: str or None
         @raises RuntimeError: When there are multiple languages in this family
             which would work with the given URL.
         @raises ValueError: When text is present after $1.
@@ -1153,7 +1141,7 @@

         These domains may also exist in another family.

-        @rtype: iterable of str
+        @rtype: set of str
         """
         return set(cls.langs.values())

@@ -1162,7 +1150,7 @@
         """
         Get list of codes used by this family.

-        @rtype: iterable of str
+        @rtype: set of str
         """
         return set(cls.langs.keys())

@@ -1401,14 +1389,12 @@


 @deprecated_args(site=None)
-def AutoFamily(name, url):
+def AutoFamily(name: str, url: str):
     """
     Family that automatically loads the site configuration.

     @param name: Name for the family
-    @type name: str
     @param url: API endpoint URL of the wiki
-    @type url: str
     @return: Generated family class
     @rtype: SingleSiteFamily
     """
diff --git a/pywikibot/flow.py b/pywikibot/flow.py
index 792ca54..fea2130 100644
--- a/pywikibot/flow.py
+++ b/pywikibot/flow.py
@@ -26,13 +26,12 @@
     It cannot be instantiated directly.
     """

-    def __init__(self, source, title=''):
+    def __init__(self, source, title: str = ''):
         """Initializer.

         @param source: A Flow-enabled site or a Link or Page on such a site
         @type source: Site, pywikibot.page.Link, or pywikibot.page.Page
         @param title: normalized title of the page
-        @type title: str

         @raises TypeError: incorrect use of parameters
         @raises ValueError: use of non-Flow-enabled Site
@@ -52,11 +51,10 @@
         raise NotImplementedError

     @property
-    def uuid(self):
+    def uuid(self) -> str:
         """Return the UUID of the page.

         @return: UUID of the page
-        @rtype: str
         """
         if not hasattr(self, '_uuid'):
             self._uuid = self._load()['workflowId']
@@ -187,15 +185,13 @@
         return cls(board.site, data['topic-page'])

     @classmethod
-    def from_topiclist_data(cls, board, root_uuid, topiclist_data):
+    def from_topiclist_data(cls, board, root_uuid: str, topiclist_data: dict):
         """Create a Topic object from API data.

         @param board: The topic's parent Flow board
         @type board: Board
         @param root_uuid: The UUID of the topic and its root post
-        @type root_uuid: str
         @param topiclist_data: The data returned by view-topiclist
-        @type topiclist_data: dict
         @return: A Topic object derived from the supplied data
         @rtype: Topic
         @raises TypeError: any passed parameters have wrong types
@@ -253,56 +249,50 @@
         return self.root.reply(content, content_format)

     # Moderation
-    def lock(self, reason):
+    def lock(self, reason: str):
         """Lock this topic.

         @param reason: The reason for locking this topic
-        @type reason: str
         """
         self.site.lock_topic(self, True, reason)
         self._reload()

-    def unlock(self, reason):
+    def unlock(self, reason: str):
         """Unlock this topic.

         @param reason: The reason for unlocking this topic
-        @type reason: str
         """
         self.site.lock_topic(self, False, reason)
         self._reload()

-    def delete_mod(self, reason):
+    def delete_mod(self, reason: str):
         """Delete this topic through the Flow moderation system.

         @param reason: The reason for deleting this topic.
-        @type reason: str
         """
         self.site.delete_topic(self, reason)
         self._reload()

-    def hide(self, reason):
+    def hide(self, reason: str):
         """Hide this topic.

         @param reason: The reason for hiding this topic.
-        @type reason: str
         """
         self.site.hide_topic(self, reason)
         self._reload()

-    def suppress(self, reason):
+    def suppress(self, reason: str):
         """Suppress this topic.

         @param reason: The reason for suppressing this topic.
-        @type reason: str
         """
         self.site.suppress_topic(self, reason)
         self._reload()

-    def restore(self, reason):
+    def restore(self, reason: str):
         """Restore this topic.
 
         @param reason: The reason for restoring this topic.
-        @type reason: str
         """
         self.site.restore_topic(self, reason)
         self._reload()
@@ -313,14 +303,13 @@

     """A post to a Flow discussion topic."""

-    def __init__(self, page, uuid):
+    def __init__(self, page, uuid: str):
         """
         Initializer.

         @param page: Flow topic
         @type page: Topic
         @param uuid: UUID of a Flow post
-        @type uuid: str

         @raises TypeError: incorrect types of parameters
         """
@@ -337,16 +326,14 @@
         self._content = {}

     @classmethod
-    def fromJSON(cls, page, post_uuid, data):
+    def fromJSON(cls, page, post_uuid: str, data: dict):
         """
         Create a Post object using the data returned from the API call.

         @param page: A Flow topic
         @type page: Topic
         @param post_uuid: The UUID of the post
-        @type post_uuid: str
         @param data: The JSON data returned from the API
-        @type data: dict

         @return: A Post object
         @raises TypeError: data is not a dict
@@ -357,11 +344,10 @@

         return post

-    def _set_data(self, data):
+    def _set_data(self, data: dict):
         """Set internal data and cache content.

         @param data: The data to store internally
-        @type data: dict
         @raises TypeError: data is not a dict
         @raises ValueError: missing data entries or post/revision not found
         """
@@ -399,11 +385,10 @@
         return self._current_revision

     @property
-    def uuid(self):
+    def uuid(self) -> str:
         """Return the UUID of the post.

         @return: UUID of the post
-        @rtype: str
         """
         return self._uuid

@@ -508,38 +493,34 @@
         return post

     # Moderation
-    def delete(self, reason):
+    def delete(self, reason: str):
         """Delete this post through the Flow moderation system.

         @param reason: The reason for deleting this post.
-        @type reason: str
         """
         self.site.delete_post(self, reason)
         self._load()

-    def hide(self, reason):
+    def hide(self, reason: str):
         """Hide this post.

         @param reason: The reason for hiding this post.
-        @type reason: str
         """
         self.site.hide_post(self, reason)
         self._load()

-    def suppress(self, reason):
+    def suppress(self, reason: str):
         """Suppress this post.

         @param reason: The reason for suppressing this post.
-        @type reason: str
         """
         self.site.suppress_post(self, reason)
         self._load()

-    def restore(self, reason):
+    def restore(self, reason: str):
         """Restore this post.

         @param reason: The reason for restoring this post.
-        @type reason: str
         """
         self.site.restore_post(self, reason)
         self._load()
diff --git a/pywikibot/interwiki_graph.py b/pywikibot/interwiki_graph.py
index b7ba7a2..4078774 100644
--- a/pywikibot/interwiki_graph.py
+++ b/pywikibot/interwiki_graph.py
@@ -10,6 +10,7 @@
 from collections import Counter
 import itertools
 import threading
+from typing import Optional

 try:
     import pydot
@@ -250,16 +251,14 @@
         self.saveGraphFile()


-def getFilename(page, extension=None):
+def getFilename(page, extension: Optional[str] = None) -> str:
     """
     Create a filename that is unique for the page.

     @param page: page used to create the new filename
     @type page: pywikibot.page.Page
     @param extension: file extension
-    @type extension: str
     @return: filename of <family>-<lang>-<page>.<ext>
-    @rtype: str
     """
     filename = '%s-%s-%s' % (page.site.family.name,
                              page.site.code,
diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py
index 7ffa816..1015ea9 100644
--- a/pywikibot/logentries.py
+++ b/pywikibot/logentries.py
@@ -6,7 +6,7 @@
 # Distributed under the terms of the MIT license.
 #
 from collections import UserDict
-from typing import Optional
+from typing import List, Optional

 import pywikibot
 from pywikibot.exceptions import Error, HiddenKeyError
@@ -189,14 +189,13 @@
         else:
             return super(BlockEntry, self).page()

-    def flags(self):
+    def flags(self) -> List[str]:
         """
         Return a list of (str) flags associated with the block entry.

         It raises an Error if the entry is an unblocking log entry.

         @return: list of flags strings
-        @rtype: list
         """
         if self.action() == 'unblock':
             return []
@@ -449,12 +448,11 @@
                 classname, bases, {'_expected_type': logtype})
         return cls._logtypes[logtype]

-    def _createFromData(self, logdata):
+    def _createFromData(self, logdata: dict):
         """
         Check for logtype from data, and creates the correct LogEntry.

         @param logdata: log entry data
-        @type logdata: dict
         @rtype: LogEntry
         """
         try:

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/634735
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: I6487433ca0cc3cde522f45fdabb557d734d43bea
Gerrit-Change-Number: 634735
Gerrit-PatchSet: 2
Gerrit-Owner: Udoka <[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