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

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

[IMPR] Replaced basestring to str

Bug: T265128
Change-Id: I548cb45e6b147ddcda7930c379040482070765ec
---
M generate_user_files.py
M pywikibot/__init__.py
M pywikibot/bot_choice.py
3 files changed, 31 insertions(+), 52 deletions(-)

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



diff --git a/generate_user_files.py b/generate_user_files.py
index f8437f2..7d5a7bf 100755
--- a/generate_user_files.py
+++ b/generate_user_files.py
@@ -11,6 +11,8 @@
 import re
 import sys

+from typing import Optional, Tuple
+
 from collections import namedtuple
 from textwrap import fill

@@ -95,18 +97,16 @@
     return False


-def get_site_and_lang(default_family='wikipedia', default_lang='en',
-                      default_username=None, force=False):
+def get_site_and_lang(default_family: Optional[str] = 'wikipedia',
+                      default_lang: Optional[str] = 'en',
+                      default_username: Optional[str] = None, force=False):
     """
     Ask the user for the family, language and username.

     @param default_family: The default family which should be chosen.
-    @type default_family: None or str
     @param default_lang: The default language which should be chosen, if the
         family supports this language.
-    @type default_lang: None or str
     @param default_username: The default username which should be chosen.
-    @type default_username: None or str
     @return: The family, language and username
     @rtype: tuple of three str
     """
@@ -425,14 +425,13 @@
     return userfile, passfile


-def main(*args):
+def main(*args: Tuple[str, ...]):
     """
     Process command line arguments and generate user-config.

     If args is an empty list, sys.argv is used.

     @param args: command line arguments
-    @type args: str
     """
     # set the config family and mylang values to an invalid state so that
     # the script can detect that the command line arguments -family & -lang
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index b552b49..7f83449 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -133,11 +133,10 @@
         return cls._ISO8601Format()

     @classmethod
-    def _ISO8601Format(cls, sep='T'):
+    def _ISO8601Format(cls, sep: str = 'T'):
         """ISO8601 format string.

         @param sep: one-character separator, placed between the date and time
-        @type sep: str
         @return: ISO8601 format string
         @rtype: str
         """
@@ -145,13 +144,12 @@
         return '%Y-%m-%d{0}%H:%M:%SZ'.format(sep)

     @classmethod
-    def fromISOformat(cls, ts, sep='T'):
+    def fromISOformat(cls, ts, sep: str = 'T'):
         """Convert an ISO 8601 timestamp to a Timestamp object.

         @param ts: ISO 8601 timestamp or a Timestamp object already
         @type ts: str or Timestamp
         @param sep: one-character separator, placed between the date and time
-        @type sep: str
         @return: Timestamp object
         @rtype: Timestamp
         """
@@ -216,27 +214,23 @@
     _items = ('lat', 'lon', 'entity')

     @_deprecate_arg('entity', 'globe_item')
-    def __init__(self, lat, lon, alt=None, precision=None, globe=None,
-                 typ='', name='', dim=None, site=None, globe_item=None,
-                 primary=False):
+    def __init__(self, lat: float, lon: float, alt=None,
+                 precision: Optional[float] = None,
+                 globe: Optional[str] = None, typ: str = '',
+                 name: str = '', dim: Optional[int] = None,
+                 site=None, globe_item=None, primary: bool = False):
         """
         Represent a geo coordinate.

         @param lat: Latitude
-        @type lat: float
         @param lon: Longitude
-        @type lon: float
         @param alt: Altitude? TODO FIXME
         @param precision: precision
         @type precision: float
         @param globe: Which globe the point is on
-        @type globe: str
         @param typ: The type of coordinate point
-        @type typ: str
         @param name: The name
-        @type name: str
         @param dim: Dimension (in meters)
-        @type dim: int
         @param site: The Wikibase site
         @type site: pywikibot.site.DataSite
         @param globe_item: The Wikibase item for the globe, or the entity URI
@@ -244,7 +238,6 @@
                            if present.
         @type globe_item: pywikibot.ItemPage or str
         @param primary: True for a primary set of coordinates
-        @type primary: bool
         """
         self.lat = lat
         self.lon = lon
@@ -576,25 +569,22 @@
                    precision, before, after, timezone, calendarmodel, site)

     @classmethod
-    def fromTimestamp(cls, timestamp, precision=14, before=0, after=0,
-                      timezone=0, calendarmodel=None, site=None):
+    def fromTimestamp(cls, timestamp, precision: Union[int, str] = 14,
+                      before: int = 0, after: int = 0,
+                      timezone: int = 0, calendarmodel: Optional[str] = None,
+                      site=None):
         """
         Create a new WbTime object from a pywikibot.Timestamp.

         @param timestamp: Timestamp
         @type timestamp: pywikibot.Timestamp
         @param precision: The unit of the precision of the time.
-        @type precision: int or str
         @param before: Number of units after the given time it could be, if
             uncertain. The unit is given by the precision.
-        @type before: int
         @param after: Number of units before the given time it could be, if
             uncertain. The unit is given by the precision.
-        @type after: int
         @param timezone: Timezone information in minutes.
-        @type timezone: int
         @param calendarmodel: URI identifying the calendar model
-        @type calendarmodel: str
         @param site: The Wikibase site
         @type site: pywikibot.site.DataSite
         @rtype: pywikibot.WbTime
@@ -655,12 +645,11 @@
         return json

     @classmethod
-    def fromWikibase(cls, wb, site=None):
+    def fromWikibase(cls, wb: dict, site=None):
         """
         Create a WbTime from the JSON data given by the Wikibase API.

         @param wb: Wikibase JSON
-        @type wb: dict
         @param site: The Wikibase site
         @type site: pywikibot.site.DataSite
         @rtype: pywikibot.WbTime
@@ -695,14 +684,13 @@
         return site.mw_version < '1.29.0-wmf.2'

     @staticmethod
-    def _todecimal(value):
+    def _todecimal(value: str):
         """
         Convert a string to a Decimal for use in WbQuantity.

         None value is returned as is.

         @param value: decimal number to convert
-        @type value: str
         @rtype: Decimal
         """
         if isinstance(value, Decimal):
@@ -814,12 +802,11 @@
         return json

     @classmethod
-    def fromWikibase(cls, wb, site=None):
+    def fromWikibase(cls, wb: dict, site=None):
         """
         Create a WbQuantity from the JSON data given by the Wikibase API.

         @param wb: Wikibase JSON
-        @type wb: dict
         @param site: The Wikibase site
         @type site: pywikibot.site.DataSite
         @rtype: pywikibot.WbQuantity
@@ -843,14 +830,12 @@

     _items = ('text', 'language')

-    def __init__(self, text, language):
+    def __init__(self, text: str, language: str):
         """
         Create a new WbMonolingualText object.

         @param text: text string
-        @type text: str
         @param language: language code of the string
-        @type language: str
         """
         if not text or not language:
             raise ValueError('text and language cannot be empty')
@@ -870,12 +855,11 @@
         return json

     @classmethod
-    def fromWikibase(cls, wb):
+    def fromWikibase(cls, wb: dict):
         """
         Create a WbMonolingualText from the JSON data given by Wikibase API.

         @param wb: Wikibase JSON
-        @type wb: dict
         @rtype: pywikibot.WbMonolingualText
         """
         return cls(wb['text'], wb['language'])
@@ -925,7 +909,7 @@
         raise NotImplementedError

     @staticmethod
-    def _validate(page, data_site, ending, label):
+    def _validate(page, data_site, ending: str, label):
         """
         Validate the provided page against general and type specific rules.

@@ -936,7 +920,6 @@
         @type data_site: pywikibot.site.APISite
         @param ending: Required filetype-like ending in page titles.
             E.g. '.map'
-        @type ending: str
         @param label: Label describing the data type in error messages.
         @type site: str
         """
@@ -997,12 +980,11 @@
         return self.page.title()

     @classmethod
-    def fromWikibase(cls, page_name, site):
+    def fromWikibase(cls, page_name: str, site):
         """
         Create a _WbDataPage from the JSON data given by the Wikibase API.
 
         @param page_name: page name from Wikibase value
-        @type page_name: str
         @param site: The Wikibase site
         @type site: pywikibot.site.DataSite
         @rtype: pywikibot._WbDataPage
@@ -1147,7 +1129,8 @@


 @_deprecate_arg('sysop', None)
-def Site(code=None, fam=None, user=None, sysop=None, interface=None, url=None):
+def Site(code: Optional[str] = None, fam=None, user: Optional[str] = None,
+         sysop=None, interface=None, url: Optional[str] = None):
     """A factory method to obtain a Site object.

     Site objects are cached and reused by this method.
@@ -1156,17 +1139,14 @@
     using the method parameters.

     @param code: language code (override config.mylang)
-    @type code: str
     @param fam: family name or object (override config.family)
     @type fam: str or pywikibot.family.Family
     @param user: bot user name to use on this site (override config.usernames)
-    @type user: str
     @param interface: site class or name of class in pywikibot.site
         (override config.site_interface)
     @type interface: subclass of L{pywikibot.site.BaseSite} or string
     @param url: Instead of code and fam, does try to get a Site based on the
         URL. Still requires that the family supporting that URL exists.
-    @type url: str
     @rtype: pywikibot.site.APISite
     @raises ValueError: URL and pair of code and family given
     @raises ValueError: Invalid interface name
diff --git a/pywikibot/bot_choice.py b/pywikibot/bot_choice.py
index 2242c94..7a00159 100755
--- a/pywikibot/bot_choice.py
+++ b/pywikibot/bot_choice.py
@@ -6,7 +6,9 @@
 # Distributed under the terms of the MIT license.
 #
 import re
+
 from textwrap import fill
+from typing import Optional

 import pywikibot

@@ -106,13 +108,12 @@

     """An option with a description and shortcut and returning the shortcut."""
 
-    def __init__(self, option: str, shortcut, **kwargs):
+    def __init__(self, option: str, shortcut: str, **kwargs):
         """
         Initializer.

         @param option: option string
         @param shortcut: Shortcut of the option
-        @type shortcut: str
         """
         super().__init__(**kwargs)
         self.option = option
@@ -432,13 +433,12 @@

     before_question = True

-    def __init__(self, sequence, prefix='', pre=None, post=None, **kwargs):
+    def __init__(self, sequence, prefix='', pre: Optional[str] = None,
+                 post: Optional[str] = None, **kwargs):
         """Initializer.

         @param pre: Additional comment printed before the list.
-        @type pre: str
         @param post: Additional comment printed after the list.
-        @type post: str
         """
         super().__init__(sequence, prefix, **kwargs)
         self.pre = pre

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/634285
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: I548cb45e6b147ddcda7930c379040482070765ec
Gerrit-Change-Number: 634285
Gerrit-PatchSet: 7
Gerrit-Owner: Udoka <[email protected]>
Gerrit-Reviewer: Dr0ptp4kt <[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