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

Change subject: [4.0] replace str('string') by 'string'
......................................................................

[4.0] replace str('string') by 'string'

Change-Id: I2ac37eb9827b741708cedc08d82092a34f4a874f
---
M pywikibot/config2.py
M pywikibot/page/__init__.py
M pywikibot/userinterfaces/terminal_interface_win32.py
M pywikibot/xmlreader.py
M tests/api_tests.py
5 files changed, 10 insertions(+), 17 deletions(-)

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



diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index c193e8f..d74c505 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -50,11 +50,10 @@
 from distutils.version import StrictVersion
 from locale import getdefaultlocale
 from os import getenv, environ
+from requests import __version__ as requests_version
 from textwrap import fill
 from warnings import warn

-from requests import __version__ as requests_version
-
 from pywikibot import __version__ as pwb_version
 from pywikibot.logging import error, output, warning
 from pywikibot.tools import PY2, issue_deprecation_warning
@@ -313,7 +312,7 @@

     base_dir = ''
     for arg in sys.argv[1:]:
-        if arg.startswith(str('-dir:')):
+        if arg.startswith('-dir:'):
             base_dir = arg[5:]
             base_dir = os.path.expanduser(base_dir)
             break
@@ -378,7 +377,7 @@
 base_dir = get_base_dir()

 for arg in sys.argv[1:]:
-    if arg.startswith(str('-verbose')) or arg == str('-v'):
+    if arg.startswith('-verbose') or arg == '-v':
         output('The base directory is ' + base_dir)
         break
 family_files = {}
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py
index 0c5a31d..04621d9 100644
--- a/pywikibot/page/__init__.py
+++ b/pywikibot/page/__init__.py
@@ -373,7 +373,7 @@
             title = title.replace(' ', '_')
         if as_url:
             encoded_title = title.encode(self.site.encoding())
-            title = quote_from_bytes(encoded_title, safe=str(''))
+            title = quote_from_bytes(encoded_title, safe='')
         if as_filename:
             # Replace characters that are not possible in file names on some
             # systems, but still are valid in MediaWiki titles:
@@ -415,7 +415,7 @@
             except UnicodeEncodeError:
                 # okay console encoding didn't work, at least try something
                 title = self.title().encode('unicode_escape')
-        return str('{0}({1})').format(self.__class__.__name__, title)
+        return '{0}({1})'.format(self.__class__.__name__, title)

     def _cmpkey(self):
         """
diff --git a/pywikibot/userinterfaces/terminal_interface_win32.py 
b/pywikibot/userinterfaces/terminal_interface_win32.py
index 78f18c9..898a847 100755
--- a/pywikibot/userinterfaces/terminal_interface_win32.py
+++ b/pywikibot/userinterfaces/terminal_interface_win32.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 """User interface for Win32 terminals."""
 #
-# (C) Pywikibot team, 2003-2019
+# (C) Pywikibot team, 2003-2020
 #
 # Distributed under the terms of the MIT license.
 #
@@ -77,9 +77,7 @@

     def _raw_input(self):
         data = self.stdin.readline()
-        # data is in both Python versions str but '\x1a' is unicode in Python 2
-        # so explicitly convert into str as it otherwise tries to decode data
-        if str('\x1a') in data:
+        if '\x1a' in data:
             raise EOFError()
         return data.strip()

diff --git a/pywikibot/xmlreader.py b/pywikibot/xmlreader.py
index b46315b..9c1f883 100644
--- a/pywikibot/xmlreader.py
+++ b/pywikibot/xmlreader.py
@@ -118,10 +118,7 @@
     def parse(self):
         """Generator using ElementTree iterparse function."""
         with open_archive(self.filename) as source:
-            # iterparse's event must be a str but they are unicode with
-            # unicode_literals in Python 2
-            context = iterparse(source, events=(str('start'), str('end'),
-                                                str('start-ns')))
+            context = iterparse(source, events=('start', 'end', 'start-ns'))
             self.root = None

             for event, elem in context:
@@ -131,8 +128,7 @@
                 if event == 'start' and self.root is None:
                     self.root = elem
                     continue
-                for rev in self._parse(event, elem):
-                    yield rev
+                yield from self._parse(event, elem)

     def _parse_only_latest(self, event, elem):
         """Parser that yields only the latest revision."""
diff --git a/tests/api_tests.py b/tests/api_tests.py
index 55c32b7..1774800 100644
--- a/tests/api_tests.py
+++ b/tests/api_tests.py
@@ -1102,7 +1102,7 @@
     def test_url_encoding_from_basestring(self):
         """Test encoding basestring values."""
         query = {'token': 'test\xe2\x80\x94test'}
-        expect = str('token=test%C3%A2%C2%80%C2%94test')
+        expect = 'token=test%C3%A2%C2%80%C2%94test'
         result = api.encode_url(query)
         self.assertEqual(result, expect)
         self.assertIsInstance(result, str)

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/610392
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: I2ac37eb9827b741708cedc08d82092a34f4a874f
Gerrit-Change-Number: 610392
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Zhuyifei1999 <[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