← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:remove-trivial-six into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:remove-trivial-six into launchpad:master.

Commit message:
Remove various trivial uses of six

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/420137

These are in doctests or similar, so weren't picked up by pyupgrade.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:remove-trivial-six into launchpad:master.
diff --git a/lib/lp/blueprints/stories/blueprints/xx-distrorelease.txt b/lib/lp/blueprints/stories/blueprints/xx-distrorelease.txt
index 19ceace..b4a0b07 100644
--- a/lib/lp/blueprints/stories/blueprints/xx-distrorelease.txt
+++ b/lib/lp/blueprints/stories/blueprints/xx-distrorelease.txt
@@ -79,8 +79,7 @@ a "proposed" goal.
 The spec will not show up immediately as a Grumpy goal since it must
 first be approved.
 
-    >>> import six
-    >>> result = six.text_type(http(r"""
+    >>> result = str(http(r"""
     ... GET /ubuntu/hoary/+specs HTTP/1.1
     ... """))
     >>> '<td>CD Media Integrity Check' not in result
diff --git a/lib/lp/bugs/doc/bugactivity.txt b/lib/lp/bugs/doc/bugactivity.txt
index 6af78f4..7c4ec8c 100644
--- a/lib/lp/bugs/doc/bugactivity.txt
+++ b/lib/lp/bugs/doc/bugactivity.txt
@@ -21,7 +21,6 @@ authenticated user--let's login:
 Bug activity tracking is done using event subscribers. The handlers
 are simple little functions.
 
-    >>> import six
     >>> from lp.bugs.interfaces.bugtask import IBugTaskSet
     >>> from lp.registry.interfaces.product import IProductSet
     >>> from lp.services.webapp.snapshot import notify_modified
@@ -148,7 +147,7 @@ Bug report is marked as a duplicate of another bug report
     marked as duplicate
     >>> latest_activity.oldvalue is None
     True
-    >>> latest_activity.newvalue == six.text_type(latest_bug.id)
+    >>> latest_activity.newvalue == str(latest_bug.id)
     True
 
 
@@ -164,9 +163,9 @@ Bug report has its duplicate marker changed to another bug report
     >>> latest_activity = bug.activity[-1]
     >>> print(latest_activity.whatchanged)
     changed duplicate marker
-    >>> latest_activity.oldvalue == six.text_type(latest_bug.id)
+    >>> latest_activity.oldvalue == str(latest_bug.id)
     True
-    >>> latest_activity.newvalue == six.text_type(another_bug.id)
+    >>> latest_activity.newvalue == str(another_bug.id)
     True
 
 
@@ -181,7 +180,7 @@ The bug report is un-duplicated
     >>> latest_activity = bug.activity[-1]
     >>> print(latest_activity.whatchanged)
     removed duplicate marker
-    >>> latest_activity.oldvalue == six.text_type(another_bug.id)
+    >>> latest_activity.oldvalue == str(another_bug.id)
     True
     >>> latest_activity.newvalue is None
     True
@@ -215,16 +214,16 @@ final_bug as their master bug.
     >>> latest_activity = dupe_one.activity[-1]
     >>> print(latest_activity.whatchanged)
     changed duplicate marker
-    >>> latest_activity.oldvalue == six.text_type(initial_bug.id)
+    >>> latest_activity.oldvalue == str(initial_bug.id)
     True
-    >>> latest_activity.newvalue == six.text_type(final_bug.id)
+    >>> latest_activity.newvalue == str(final_bug.id)
     True
     >>> latest_activity = dupe_two.activity[-1]
     >>> print(latest_activity.whatchanged)
     changed duplicate marker
-    >>> latest_activity.oldvalue == six.text_type(initial_bug.id)
+    >>> latest_activity.oldvalue == str(initial_bug.id)
     True
-    >>> latest_activity.newvalue == six.text_type(final_bug.id)
+    >>> latest_activity.newvalue == str(final_bug.id)
     True
 
 
diff --git a/lib/lp/bugs/stories/bugs/xx-incomplete-bugs.txt b/lib/lp/bugs/stories/bugs/xx-incomplete-bugs.txt
index 53f0cd4..f526479 100644
--- a/lib/lp/bugs/stories/bugs/xx-incomplete-bugs.txt
+++ b/lib/lp/bugs/stories/bugs/xx-incomplete-bugs.txt
@@ -277,8 +277,7 @@ response) bugs.
     >>> user_browser.getControl('Search', index=1).click()
     >>> ('<a class="bugtitle" '
     ...  'href="http://bugs.launchpad.test/jokosher/+bug/11";>' in
-    ...     six.text_type(
-    ...         find_tag_by_id(user_browser.contents, 'bugs-table-listing')))
+    ...     str(find_tag_by_id(user_browser.contents, 'bugs-table-listing')))
     True
 
 A default search turns that bug up as well.
@@ -289,6 +288,5 @@ A default search turns that bug up as well.
     http://bugs.launchpad.test/jokosher/+bugs?...&field.status%3Alist=INCOMPLETE_WITH_RESPONSE&field.status%3Alist=INCOMPLETE_WITHOUT_RESPONSE...
     >>> ('<a class="bugtitle" '
     ...  'href="http://bugs.launchpad.test/jokosher/+bug/11";>' in
-    ...     six.text_type(
-    ...         find_tag_by_id(user_browser.contents, 'bugs-table-listing')))
+    ...     str(find_tag_by_id(user_browser.contents, 'bugs-table-listing')))
     True
diff --git a/lib/lp/code/doc/codeimport-event.txt b/lib/lp/code/doc/codeimport-event.txt
index 573cf9c..7eaaf82 100644
--- a/lib/lp/code/doc/codeimport-event.txt
+++ b/lib/lp/code/doc/codeimport-event.txt
@@ -129,8 +129,7 @@ The database IDs of the CodeImport is also recorded. It is useful to
 collate events associated with deleted CodeImport objects.
 
     >>> event_dict = dict(svn_create_event.items())
-    >>> event_dict[CodeImportEventDataType.CODE_IMPORT] == (
-    ...     six.text_type(svn_import.id))
+    >>> event_dict[CodeImportEventDataType.CODE_IMPORT] == str(svn_import.id)
     True
 
 Different source details are recorded according to the type of the
@@ -261,8 +260,7 @@ The database ID of the requested CodeImport is also recorded. It is
 useful to collate events associated with deleted CodeImport objects.
 
     >>> event_dict = dict(request_event.items())
-    >>> event_dict[CodeImportEventDataType.CODE_IMPORT] == (
-    ...     six.text_type(svn_import.id))
+    >>> event_dict[CodeImportEventDataType.CODE_IMPORT] == str(svn_import.id)
     True
 
 
diff --git a/lib/lp/code/stories/branches/xx-code-review-comments.txt b/lib/lp/code/stories/branches/xx-code-review-comments.txt
index 0d075f6..2f4033a 100644
--- a/lib/lp/code/stories/branches/xx-code-review-comments.txt
+++ b/lib/lp/code/stories/branches/xx-code-review-comments.txt
@@ -204,7 +204,7 @@ log entries first.
     >>> hosting_fixture = GitHostingFixture()
     >>> for i in range(2):
     ...     hosting_fixture.getLog.result.insert(0, {
-    ...         u'sha1': six.text_type(i * 2) * 40,
+    ...         u'sha1': str(i * 2) * 40,
     ...         u'message': u'Testing commits in conversation',
     ...         u'author': {
     ...             u'name': bmp.registrant.display_name,
@@ -213,7 +213,7 @@ log entries first.
     ...             },
     ...         })
     ...     hosting_fixture.getLog.result.insert(0, {
-    ...         u'sha1': six.text_type(i * 2 + 1) * 40,
+    ...         u'sha1': str(i * 2 + 1) * 40,
     ...         u'message': u'and it works!',
     ...         u'author': {
     ...             u'name': bmp.registrant.display_name,
diff --git a/lib/lp/registry/interfaces/mailinglist.py b/lib/lp/registry/interfaces/mailinglist.py
index 4c255c2..3443f10 100644
--- a/lib/lp/registry/interfaces/mailinglist.py
+++ b/lib/lp/registry/interfaces/mailinglist.py
@@ -877,9 +877,9 @@ class BaseSubscriptionErrors(Exception):
     def __init__(self, error_string):
         """Instantiate a subscription exception.
 
-        :param error_string: a unicode error string, which may contain
+        :param error_string: an error string, which may contain
             non-ascii text (since a person's display name is used here).
-        :type error_string: unicode
+        :type error_string: str
         """
         assert isinstance(error_string, str), 'Unicode expected'
         Exception.__init__(self, error_string)
diff --git a/lib/lp/registry/stories/product/xx-product-files.txt b/lib/lp/registry/stories/product/xx-product-files.txt
index 0d99ad7..cb82bc6 100644
--- a/lib/lp/registry/stories/product/xx-product-files.txt
+++ b/lib/lp/registry/stories/product/xx-product-files.txt
@@ -418,7 +418,7 @@ XXX Mon May  7 10:02:49 2007 -- bac
     >>> redirect_resp = http("""
     ...     GET %s HTTP/1.1""" % url_path)
     >>> redirect_url = None
-    >>> for line in six.text_type(redirect_resp).splitlines()[1:]:
+    >>> for line in str(redirect_resp).splitlines()[1:]:
     ...     key, value = line.split(": ", 1)
     ...     if key.lower() == "location":
     ...         redirect_url = value
diff --git a/lib/lp/services/database/doc/textsearching.txt b/lib/lp/services/database/doc/textsearching.txt
index 5ced23b..ef581ef 100644
--- a/lib/lp/services/database/doc/textsearching.txt
+++ b/lib/lp/services/database/doc/textsearching.txt
@@ -31,7 +31,7 @@ against the database and display the results:
     ...     for row in store.execute(query, args):
     ...         line = ''
     ...         for col in row:
-    ...             if isinstance(col, (float, six.integer_types)):
+    ...             if isinstance(col, (float, int)):
     ...                 col = '%1.2f' % col
     ...             if len(col) > colsize:
     ...                 line += '%s... ' % col[:colsize-3]
diff --git a/lib/lp/services/database/sqlbase.py b/lib/lp/services/database/sqlbase.py
index 83434cc..ba90a83 100644
--- a/lib/lp/services/database/sqlbase.py
+++ b/lib/lp/services/database/sqlbase.py
@@ -319,7 +319,7 @@ def quote(x):
     before sending across the wire to the database).
 
     >>> quoted = quote(u"\N{TRADE MARK SIGN}")
-    >>> isinstance(quoted, six.text_type)
+    >>> isinstance(quoted, str)
     True
     >>> print(backslashreplace(quoted))
     E'\u2122'
diff --git a/lib/lp/services/feeds/stories/xx-navigation.txt b/lib/lp/services/feeds/stories/xx-navigation.txt
index 48db39e..8c53f9d 100644
--- a/lib/lp/services/feeds/stories/xx-navigation.txt
+++ b/lib/lp/services/feeds/stories/xx-navigation.txt
@@ -51,7 +51,7 @@ redirects to remote sites, but http() can be used instead.
     ... GET / HTTP/1.0
     ... Host: feeds.launchpad.test
     ... """)
-    >>> print(six.text_type(response))
+    >>> print(str(response))
     HTTP/1.0 301 Moved Permanently
     ...
     Location: https://help.launchpad.net/Feeds
diff --git a/lib/lp/services/helpers.py b/lib/lp/services/helpers.py
index 1a56835..ef5fc41 100644
--- a/lib/lp/services/helpers.py
+++ b/lib/lp/services/helpers.py
@@ -41,7 +41,7 @@ def text_replaced(text, replacements, _cache={}):
     Unicode strings work too.
 
     >>> replaced = text_replaced(u'1 2 3 4', {u'1': u'2', u'2': u'1'})
-    >>> isinstance(replaced, six.text_type)
+    >>> isinstance(replaced, str)
     True
     >>> print(replaced)
     2 1 3 4
diff --git a/lib/lp/services/messages/doc/message.txt b/lib/lp/services/messages/doc/message.txt
index 6d721af..dbdeb32 100644
--- a/lib/lp/services/messages/doc/message.txt
+++ b/lib/lp/services/messages/doc/message.txt
@@ -38,7 +38,7 @@ of this message are sent out. The message id is generated by the system
 if not provided
 
     >>> import six
-    >>> isinstance(msg.rfc822msgid, six.string_types)
+    >>> isinstance(msg.rfc822msgid, str)
     True
     >>> bool(msg.rfc822msgid)
     True
diff --git a/lib/lp/services/webapp/sorting.py b/lib/lp/services/webapp/sorting.py
index e39c464..12a26a7 100644
--- a/lib/lp/services/webapp/sorting.py
+++ b/lib/lp/services/webapp/sorting.py
@@ -51,7 +51,6 @@ def _reversed_number_sort_key(text):
 
     """
     assert isinstance(text, str)
-    assert isinstance(text, str)
     return text.translate(reversed_numbers_table)
 
 
diff --git a/lib/lp/services/webapp/tests/test_launchpad_login_source.txt b/lib/lp/services/webapp/tests/test_launchpad_login_source.txt
index f0cd8f7..d6889ac 100644
--- a/lib/lp/services/webapp/tests/test_launchpad_login_source.txt
+++ b/lib/lp/services/webapp/tests/test_launchpad_login_source.txt
@@ -5,7 +5,6 @@ LaunchpadLoginSource is used to create principals, from login
 information, passing the email address to getPrincipalByLogin. If no
 person is found with the given email address, None is returned
 
-    >>> import six
     >>> from lp.services.webapp.authentication import (
     ...     LaunchpadLoginSource)
     >>> login_source = LaunchpadLoginSource()
@@ -23,7 +22,7 @@ account id.
     >>> from lp.services.webapp.interfaces import ILaunchpadPrincipal
     >>> ILaunchpadPrincipal.providedBy(principal)
     True
-    >>> principal.id == six.text_type(account.id)
+    >>> principal.id == str(account.id)
     True
 
 The corresponding Account and Person records are also in the
diff --git a/lib/lp/services/webservice/stories/xx-service.txt b/lib/lp/services/webservice/stories/xx-service.txt
index c07704b..9ddf720 100644
--- a/lib/lp/services/webservice/stories/xx-service.txt
+++ b/lib/lp/services/webservice/stories/xx-service.txt
@@ -116,7 +116,7 @@ request, with the OAuth consumer name being equal to the User-Agent.
     ...     return http(request)
 
     >>> response = request_with_user_agent(agent)
-    >>> print(six.text_type(response))
+    >>> print(str(response))
     HTTP/1.1 200 Ok
     ...
     {...}
@@ -125,7 +125,7 @@ An unsigned request, like a request signed with the empty string,
 isn't logged in as any particular user:
 
     >>> response = request_with_user_agent(agent, "/devel/people/+me")
-    >>> print(six.text_type(response))
+    >>> print(str(response))
     HTTP/1.1 401 Unauthorized
     ...
     You need to be logged in to view this URL.
diff --git a/lib/lp/translations/browser/tests/distroseries-views.txt b/lib/lp/translations/browser/tests/distroseries-views.txt
index 086e9a2..4c7892d 100644
--- a/lib/lp/translations/browser/tests/distroseries-views.txt
+++ b/lib/lp/translations/browser/tests/distroseries-views.txt
@@ -3,7 +3,6 @@ DistroSeries translations view classes
 
 Let's use ubuntu/hoary for these tests.
 
-    >>> import six
     >>> from lp.services.webapp.servers import LaunchpadTestRequest
     >>> from lp.registry.interfaces.distribution import IDistributionSet
     >>> from lp.registry.interfaces.series import SeriesStatus
@@ -42,7 +41,7 @@ reveal its translations to the public or hide them from the public.
     ...     try:
     ...         view.checkTranslationsViewable()
     ...     except TranslationUnavailable as message:
-    ...         return six.text_type(message)
+    ...         return str(message)
     ...     return None
 
     >>> def check_effect_of_hiding(distroseries):