Remove usage of six

The repo is python 3 only, remove six usage.

Change-Id: I8c0b0446a88a12b5da8c6502f8eee75ed1793095
This commit is contained in:
Andreas Jaeger 2020-02-04 14:37:21 +01:00
parent 60699c1b06
commit ab3eb972bf
8 changed files with 10 additions and 17 deletions

View File

@ -1,6 +1,5 @@
docutils==0.11
dulwich==0.15.0
PyYAML==3.10.0
six==1.9.0
Sphinx==1.6.1
stestr==2.0.0

View File

@ -13,7 +13,6 @@
from docutils import nodes
from docutils.parsers import rst
from docutils.statemachine import ViewList
import six
from sphinx.util import logging
from sphinx.util.nodes import nested_parse_with_titles
@ -37,7 +36,7 @@ def _format_option_help(options):
for l in _multi_line_string(opt.help, ' '):
yield l
yield ''
if isinstance(opt.default, six.string_types) and '\n' in opt.default:
if isinstance(opt.default, str) and '\n' in opt.default:
# Multi-line string
yield ' Defaults to'
yield ''

View File

@ -14,7 +14,6 @@ import collections
import logging
import os.path
import six
import yaml
from reno import scanner
@ -107,7 +106,7 @@ class Loader(object):
for section_name, section_content in content.items():
if section_name == self._config.prelude_section_name:
if not isinstance(section_content, six.string_types):
if not isinstance(section_content, str):
LOG.warning(
('The %s section of %s '
'does not parse as a single string. '
@ -115,7 +114,7 @@ class Loader(object):
(self._config.prelude_section_name, filename),
)
else:
if isinstance(section_content, six.string_types):
if isinstance(section_content, str):
# A single string is OK, but wrap it with a list
# so the rest of the code can treat the data model
# consistently.
@ -129,7 +128,7 @@ class Loader(object):
)
else:
for item in section_content:
if not isinstance(item, six.string_types):
if not isinstance(item, str):
LOG.warning(
('The item %r in the %s section of %s '
'parses as a %s instead of a string. '

View File

@ -24,7 +24,6 @@ from distutils import cmd
from distutils import errors
from distutils import log
import six
from reno import cache
from reno import config
@ -108,7 +107,7 @@ class BuildReno(cmd.Command):
if val is None:
setattr(self, option, default)
return default
elif not isinstance(val, six.string_types):
elif not isinstance(val, str):
raise errors.DistutilsOptionError("'%s' must be a %s (got `%s`)"
% (option, what, val))
return val

View File

@ -17,7 +17,6 @@ import textwrap
import fixtures
import mock
import six
import yaml
from reno import config
@ -73,7 +72,7 @@ class TestValidate(base.TestCase):
This is a single string.
'''))
print(type(note_bodies['issues']))
self.assertIsInstance(note_bodies['issues'], six.string_types)
self.assertIsInstance(note_bodies['issues'], str)
ldr = self._make_loader(note_bodies)
parse_results = ldr.parse_note_file('note1', None)
self.assertIsInstance(parse_results['issues'], list)

View File

@ -13,7 +13,6 @@
# under the License.
import mock
import six
from reno.tests import base
from reno import utils
@ -28,7 +27,7 @@ class TestGetRandomString(base.TestCase):
randrange.return_value = ord('a')
actual = utils.get_random_string()
expected = '61' * 8 # hex for ord('a')
self.assertIsInstance(actual, six.text_type)
self.assertIsInstance(actual, str)
self.assertEqual(expected, actual)
@mock.patch('random.randrange')
@ -38,5 +37,5 @@ class TestGetRandomString(base.TestCase):
randrange.return_value = ord('a')
actual = utils.get_random_string()
expected = '62' * 8 # hex for ord('b')
self.assertIsInstance(actual, six.text_type)
self.assertIsInstance(actual, str)
self.assertEqual(expected, actual)

View File

@ -23,11 +23,11 @@ LOG = logging.getLogger(__name__)
def get_random_string(nbytes=8):
"""Return a fixed-length random string
:rtype: six.text_type
:rtype: str
"""
try:
# NOTE(dhellmann): Not all systems support urandom().
# hexlify returns six.binary_type, decode to convert to six.text_type.
# hexlify returns binary, decode to convert to str.
val = binascii.hexlify(os.urandom(nbytes)).decode('utf-8')
except Exception as e:
print('ERROR, perhaps urandom is not supported: %s' % e)

View File

@ -4,5 +4,4 @@
pbr
PyYAML>=3.10
six>=1.9.0
dulwich>=0.15.0 # Apache-2.0