diff --git a/oslo_config/cfg.py b/oslo_config/cfg.py index 06d50bb8..638e4ff2 100644 --- a/oslo_config/cfg.py +++ b/oslo_config/cfg.py @@ -17,15 +17,9 @@ import argparse import collections - -# TODO(smcginnis) update this once six has support for collections.abc -# (https://github.com/benjaminp/six/pull/241) or clean up once we drop py2.7. -try: - from collections.abc import Mapping -except ImportError: - from collections import Mapping - +from collections import abc import copy +import enum import errno import functools import glob @@ -36,8 +30,6 @@ import os import string import sys -import enum -import six # NOTE(bnemec): oslo.log depends on oslo.config, so we can't # have a hard dependency on oslo.log. However, in most cases # oslo.log will be installed so we can use it. @@ -607,7 +599,7 @@ class Opt(object): def _default_is_ref(self): """Check if default is a reference to another var.""" - if isinstance(self.default, six.string_types): + if isinstance(self.default, str): tmpl = self.default.replace(r'\$', '').replace('$$', '') return '$' in tmpl return False @@ -939,7 +931,7 @@ class StrOpt(Opt): return '' elif choice == '': return "''" - return six.text_type(choice) + return str(choice) def _get_argparse_kwargs(self, group, **kwargs): """Extends the base argparse keyword dict for the config dir option.""" @@ -1564,7 +1556,7 @@ class ConfigParser(iniparser.BaseParser): def parse(self): with open(self.filename) as f: - return super(ConfigParser, self).parse(f) + return super(ConfigParser, self).parse(f.readlines()) def new_section(self, section): self.section = section @@ -1930,7 +1922,7 @@ class _CachedArgumentParser(argparse.ArgumentParser): super(_CachedArgumentParser, self).print_usage(file) -class ConfigOpts(Mapping): +class ConfigOpts(abc.Mapping): """Config options which may be set on the command line or in config files. @@ -3121,7 +3113,7 @@ class ConfigOpts(Mapping): value, loc = self._do_get(name, opt_group, None) return loc - class GroupAttr(Mapping): + class GroupAttr(abc.Mapping): """Helper class. diff --git a/oslo_config/generator.py b/oslo_config/generator.py index ba75c4ce..1f509eff 100644 --- a/oslo_config/generator.py +++ b/oslo_config/generator.py @@ -32,7 +32,6 @@ import textwrap import json import pkg_resources -import six import yaml @@ -119,7 +118,7 @@ def _format_defaults(opt): default_str = str(opt.default) elif isinstance(opt, (cfg.ListOpt, cfg._ConfigFileOpt, cfg._ConfigDirOpt)): - default_str = ','.join(six.text_type(d) for d in opt.default) + default_str = ','.join(str(d) for d in opt.default) elif isinstance(opt, cfg.DictOpt): sorted_items = sorted(opt.default.items(), key=operator.itemgetter(0)) @@ -131,8 +130,8 @@ def _format_defaults(opt): results = [] for default_str in defaults: - if not isinstance(default_str, six.text_type): - default_str = six.text_type(default_str) + if not isinstance(default_str, str): + default_str = str(default_str) if default_str.strip() != default_str: default_str = '"%s"' % default_str results.append(default_str) @@ -201,7 +200,7 @@ class _OptFormatter(object): return '' elif choice == '': return "''" - return six.text_type(choice) + return str(choice) def format_group(self, group_or_groupname): """Format the description of a group header to the output file diff --git a/oslo_config/sources/__init__.py b/oslo_config/sources/__init__.py index a37c6c4c..e3e99af2 100644 --- a/oslo_config/sources/__init__.py +++ b/oslo_config/sources/__init__.py @@ -42,7 +42,6 @@ The Configuration Source Class """ import abc -import six # We cannot use None as a sentinel indicating a missing value because it @@ -50,8 +49,7 @@ import six _NoValue = object() -@six.add_metaclass(abc.ABCMeta) -class ConfigurationSourceDriver(object): +class ConfigurationSourceDriver(object, metaclass=abc.ABCMeta): """A backend driver option for oslo.config. For each group name listed in **config_source** on the **DEFAULT** group, @@ -114,8 +112,7 @@ class ConfigurationSourceDriver(object): """ -@six.add_metaclass(abc.ABCMeta) -class ConfigurationSource(object): +class ConfigurationSource(object, metaclass=abc.ABCMeta): """A configuration source option for oslo.config. A configuration source is able to fetch configuration values based on diff --git a/oslo_config/sphinxext.py b/oslo_config/sphinxext.py index 0f32c203..905490c7 100644 --- a/oslo_config/sphinxext.py +++ b/oslo_config/sphinxext.py @@ -15,7 +15,6 @@ from docutils.parsers import rst from docutils.parsers.rst import directives from docutils.statemachine import ViewList import oslo_i18n -import six from sphinx import addnodes from sphinx.directives import ObjectDescription from sphinx.domains import Domain @@ -89,7 +88,7 @@ def _get_choice_text(choice): return '' elif choice == '': return "''" - return six.text_type(choice) + return str(choice) def _format_opt(opt, group_name): diff --git a/oslo_config/tests/test_cfg.py b/oslo_config/tests/test_cfg.py index e304807f..302f39fd 100644 --- a/oslo_config/tests/test_cfg.py +++ b/oslo_config/tests/test_cfg.py @@ -15,6 +15,7 @@ import argparse import errno import functools +import io import logging import os import shutil @@ -24,8 +25,6 @@ import tempfile import fixtures import mock from oslotest import base -import six -from six import moves import testscenarios from oslo_config import cfg @@ -139,7 +138,7 @@ class BaseTestCase(base.BaseTestCase): class UsageTestCase(BaseTestCase): def test_print_usage(self): - f = moves.StringIO() + f = io.StringIO() self.conf([]) self.conf.print_usage(file=f) self.assertIn( @@ -154,7 +153,7 @@ class UsageTestCase(BaseTestCase): conf = self.TestConfigOpts() self.tempdirs = [] - f = moves.StringIO() + f = io.StringIO() conf([], usage='%(prog)s FOO BAR') conf.print_usage(file=f) self.assertIn('usage: test FOO BAR', f.getvalue()) @@ -163,7 +162,7 @@ class UsageTestCase(BaseTestCase): self.assertNotIn('optional:', f.getvalue()) def test_print_help(self): - f = moves.StringIO() + f = io.StringIO() self.conf([]) self.conf.print_help(file=f) self.assertIn( @@ -178,7 +177,7 @@ class UsageTestCase(BaseTestCase): class HelpTestCase(BaseTestCase): def test_print_help(self): - f = moves.StringIO() + f = io.StringIO() self.conf([]) self.conf.print_help(file=f) self.assertIn( @@ -189,7 +188,7 @@ class HelpTestCase(BaseTestCase): self.assertIn('-h, --help', f.getvalue()) def test_print_strOpt_with_choices_help(self): - f = moves.StringIO() + f = io.StringIO() cli_opts = [ cfg.StrOpt('aa', short='a', default='xx', choices=['xx', 'yy', 'zz'], @@ -218,7 +217,7 @@ class HelpTestCase(BaseTestCase): f.getvalue()) def test_print_sorted_help(self): - f = moves.StringIO() + f = io.StringIO() self.conf.register_cli_opt(cfg.StrOpt('abc')) self.conf.register_cli_opt(cfg.StrOpt('zba')) self.conf.register_cli_opt(cfg.StrOpt('ghi')) @@ -233,7 +232,7 @@ class HelpTestCase(BaseTestCase): self.assertEqual(sorted(list), list) def test_print_sorted_help_with_positionals(self): - f = moves.StringIO() + f = io.StringIO() self.conf.register_cli_opt( cfg.StrOpt('pst', positional=True, required=False)) self.conf.register_cli_opt(cfg.StrOpt('abc')) @@ -248,7 +247,7 @@ class HelpTestCase(BaseTestCase): self.assertEqual(sorted(list), list) def test_print_help_with_deprecated(self): - f = moves.StringIO() + f = io.StringIO() abc = cfg.StrOpt('a-bc', deprecated_opts=[cfg.DeprecatedOpt('d-ef')]) uvw = cfg.StrOpt('u-vw', @@ -779,7 +778,7 @@ class CliOptsTestCase(BaseTestCase): class CliSpecialOptsTestCase(BaseTestCase): def test_help(self): - self.useFixture(fixtures.MonkeyPatch('sys.stdout', moves.StringIO())) + self.useFixture(fixtures.MonkeyPatch('sys.stdout', io.StringIO())) self.assertRaises(SystemExit, self.conf, ['--help']) self.assertIn('usage: test', sys.stdout.getvalue()) self.assertIn('[--version]', sys.stdout.getvalue()) @@ -796,7 +795,7 @@ class CliSpecialOptsTestCase(BaseTestCase): else: stream_name = 'stderr' self.useFixture(fixtures.MonkeyPatch("sys.%s" % stream_name, - moves.StringIO())) + io.StringIO())) self.assertRaises(SystemExit, self.conf, ['--version']) self.assertIn('1.0', getattr(sys, stream_name).getvalue()) @@ -925,7 +924,7 @@ class PositionalTestCase(BaseTestCase): self.conf.register_cli_opt( cfg.StrOpt('foo', required=True, positional=True)) - self.useFixture(fixtures.MonkeyPatch('sys.stdout', moves.StringIO())) + self.useFixture(fixtures.MonkeyPatch('sys.stdout', io.StringIO())) self.assertRaises(SystemExit, self.conf, ['--help']) self.assertIn(' foo\n', sys.stdout.getvalue()) @@ -938,7 +937,7 @@ class PositionalTestCase(BaseTestCase): self.conf.register_cli_opt( cfg.StrOpt('foo', required=True, positional=True)) - self.useFixture(fixtures.MonkeyPatch('sys.stdout', moves.StringIO())) + self.useFixture(fixtures.MonkeyPatch('sys.stdout', io.StringIO())) self.assertRaises(SystemExit, self.conf, ['--help']) self.assertIn(' foo\n', sys.stdout.getvalue()) @@ -948,7 +947,7 @@ class PositionalTestCase(BaseTestCase): self.conf.register_cli_opt( cfg.StrOpt('foo', required=False, positional=True)) - self.useFixture(fixtures.MonkeyPatch('sys.stdout', moves.StringIO())) + self.useFixture(fixtures.MonkeyPatch('sys.stdout', io.StringIO())) self.assertRaises(SystemExit, self.conf, ['--help']) self.assertIn(' [foo]\n', sys.stdout.getvalue()) @@ -961,7 +960,7 @@ class PositionalTestCase(BaseTestCase): self.conf.register_cli_opt( cfg.StrOpt('foo', required=False, positional=True)) - self.useFixture(fixtures.MonkeyPatch('sys.stdout', moves.StringIO())) + self.useFixture(fixtures.MonkeyPatch('sys.stdout', io.StringIO())) self.assertRaises(SystemExit, self.conf, ['--help']) self.assertIn(' [foo]\n', sys.stdout.getvalue()) @@ -974,7 +973,7 @@ class PositionalTestCase(BaseTestCase): self.conf.register_cli_opt( cfg.StrOpt('foo-bar', required=False, positional=True)) - self.useFixture(fixtures.MonkeyPatch('sys.stdout', moves.StringIO())) + self.useFixture(fixtures.MonkeyPatch('sys.stdout', io.StringIO())) self.assertRaises(SystemExit, self.conf, ['--help']) self.assertIn(' [foo_bar]\n', sys.stdout.getvalue()) @@ -986,7 +985,7 @@ class PositionalTestCase(BaseTestCase): self.conf.register_cli_opt( cfg.StrOpt('foo-bar', required=False, positional=True)) - self.useFixture(fixtures.MonkeyPatch('sys.stdout', moves.StringIO())) + self.useFixture(fixtures.MonkeyPatch('sys.stdout', io.StringIO())) self.assertRaises(SystemExit, self.conf, ['--help']) self.assertIn(' [foo_bar]\n', sys.stdout.getvalue()) @@ -998,7 +997,7 @@ class PositionalTestCase(BaseTestCase): self.conf.register_cli_opt( cfg.StrOpt('foo-bar', required=True, positional=True)) - self.useFixture(fixtures.MonkeyPatch('sys.stdout', moves.StringIO())) + self.useFixture(fixtures.MonkeyPatch('sys.stdout', io.StringIO())) self.assertRaises(SystemExit, self.conf, ['--help']) self.assertIn(' foo_bar\n', sys.stdout.getvalue()) @@ -1010,7 +1009,7 @@ class PositionalTestCase(BaseTestCase): self.conf.register_cli_opt( cfg.StrOpt('foo-bar', required=True, positional=True)) - self.useFixture(fixtures.MonkeyPatch('sys.stdout', moves.StringIO())) + self.useFixture(fixtures.MonkeyPatch('sys.stdout', io.StringIO())) self.assertRaises(SystemExit, self.conf, ['--help']) self.assertIn(' foo_bar\n', sys.stdout.getvalue()) @@ -3775,7 +3774,7 @@ class SadPathTestCase(BaseTestCase): def test_bad_cli_arg(self): self.conf.register_opt(cfg.BoolOpt('foo')) - self.useFixture(fixtures.MonkeyPatch('sys.stderr', moves.StringIO())) + self.useFixture(fixtures.MonkeyPatch('sys.stderr', io.StringIO())) self.assertRaises(SystemExit, self.conf, ['--foo']) @@ -3785,7 +3784,7 @@ class SadPathTestCase(BaseTestCase): def _do_test_bad_cli_value(self, opt_class): self.conf.register_cli_opt(opt_class('foo')) - self.useFixture(fixtures.MonkeyPatch('sys.stderr', moves.StringIO())) + self.useFixture(fixtures.MonkeyPatch('sys.stderr', io.StringIO())) self.assertRaises(SystemExit, self.conf, ['--foo', 'bar']) @@ -4071,7 +4070,7 @@ class ConfigParserTestCase(BaseTestCase): def test_no_section(self): with tempfile.NamedTemporaryFile() as tmpfile: - tmpfile.write(six.b('foo = bar')) + tmpfile.write(b'foo = bar') tmpfile.flush() parser = cfg.ConfigParser(tmpfile.name, {}) @@ -4306,7 +4305,7 @@ class SubCommandTestCase(BaseTestCase): def test_sub_command_no_handler(self): self.conf.register_cli_opt(cfg.SubCommandOpt('cmd')) - self.useFixture(fixtures.MonkeyPatch('sys.stderr', moves.StringIO())) + self.useFixture(fixtures.MonkeyPatch('sys.stderr', io.StringIO())) self.assertRaises(SystemExit, self.conf, []) self.assertIn('error', sys.stderr.getvalue()) @@ -4319,7 +4318,7 @@ class SubCommandTestCase(BaseTestCase): description='bar bar', help='blaa blaa', handler=add_parsers)) - self.useFixture(fixtures.MonkeyPatch('sys.stdout', moves.StringIO())) + self.useFixture(fixtures.MonkeyPatch('sys.stdout', io.StringIO())) self.assertRaises(SystemExit, self.conf, ['--help']) self.assertIn('foo foo', sys.stdout.getvalue()) self.assertIn('bar bar', sys.stdout.getvalue()) @@ -4340,7 +4339,7 @@ class SubCommandTestCase(BaseTestCase): def test_sub_command_multiple(self): self.conf.register_cli_opt(cfg.SubCommandOpt('cmd1')) self.conf.register_cli_opt(cfg.SubCommandOpt('cmd2')) - self.useFixture(fixtures.MonkeyPatch('sys.stderr', moves.StringIO())) + self.useFixture(fixtures.MonkeyPatch('sys.stderr', io.StringIO())) self.assertRaises(SystemExit, self.conf, []) self.assertIn('multiple', sys.stderr.getvalue()) diff --git a/oslo_config/tests/test_generator.py b/oslo_config/tests/test_generator.py index f28e5eaa..becd49a1 100644 --- a/oslo_config/tests/test_generator.py +++ b/oslo_config/tests/test_generator.py @@ -12,13 +12,13 @@ # License for the specific language governing permissions and limitations # under the License. +import io import sys import textwrap import fixtures import mock from oslotest import base -from six import moves import tempfile import testscenarios @@ -963,7 +963,7 @@ class GeneratorTestCase(base.BaseTestCase): def _capture_stream(self, stream_name): self.useFixture(fixtures.MonkeyPatch("sys.%s" % stream_name, - moves.StringIO())) + io.StringIO())) return getattr(sys, stream_name) def _capture_stdout(self): @@ -1103,7 +1103,7 @@ class DriverOptionTestCase(base.BaseTestCase): # Initialize the generator to produce YAML output to a buffer. generator.register_cli_opts(self.conf) self.config(namespace=['test_generator'], format_='yaml') - stdout = moves.StringIO() + stdout = io.StringIO() # Generate the output and parse it back to a data structure. generator.generate(self.conf, output_file=stdout) @@ -1609,7 +1609,7 @@ class GeneratorAdditionalTestCase(base.BaseTestCase): class GeneratorMutableOptionTestCase(base.BaseTestCase): def test_include_message(self): - out = moves.StringIO() + out = io.StringIO() opt = cfg.StrOpt('foo', help='foo option', mutable=True) gen = build_formatter(out) gen.format(opt, 'group1') @@ -1620,7 +1620,7 @@ class GeneratorMutableOptionTestCase(base.BaseTestCase): ) def test_do_not_include_message(self): - out = moves.StringIO() + out = io.StringIO() opt = cfg.StrOpt('foo', help='foo option', mutable=False) gen = build_formatter(out) gen.format(opt, 'group1') @@ -1854,7 +1854,7 @@ class HostAddressTestCase(base.BaseTestCase): config = [("namespace", [("alpha", self.opts)])] groups = generator._get_groups(config) - out = moves.StringIO() + out = io.StringIO() formatter = build_formatter(out) generator._output_opts(formatter, 'alpha', groups.pop('alpha')) result = out.getvalue() @@ -1871,5 +1871,6 @@ class HostAddressTestCase(base.BaseTestCase): ''').lstrip() self.assertEqual(expected, result) + GeneratorTestCase.generate_scenarios() MachineReadableGeneratorTestCase.generate_scenarios() diff --git a/oslo_config/tests/test_sources.py b/oslo_config/tests/test_sources.py index dca83b88..656f61ef 100644 --- a/oslo_config/tests/test_sources.py +++ b/oslo_config/tests/test_sources.py @@ -12,7 +12,9 @@ import os +from oslotest import base from requests import HTTPError +import requests_mock from oslo_config import _list_opts from oslo_config import cfg @@ -20,9 +22,6 @@ from oslo_config import fixture from oslo_config import sources from oslo_config.sources import _uri -from oslotest import base -import requests_mock - class TestProcessingSources(base.BaseTestCase): diff --git a/oslo_config/tests/test_sphinxconfiggen.py b/oslo_config/tests/test_sphinxconfiggen.py index f28c7319..982641ed 100644 --- a/oslo_config/tests/test_sphinxconfiggen.py +++ b/oslo_config/tests/test_sphinxconfiggen.py @@ -10,7 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. - import mock from oslotest import base diff --git a/oslo_config/tests/test_types.py b/oslo_config/tests/test_types.py index e4f47792..644a2393 100644 --- a/oslo_config/tests/test_types.py +++ b/oslo_config/tests/test_types.py @@ -16,7 +16,6 @@ import re import unittest from oslo_config import types -from six.moves import range as compat_range class ConfigTypeTests(unittest.TestCase): @@ -601,7 +600,7 @@ class RangeTypeTests(TypeTestHelper, unittest.TestCase): type = types.Range() def assertRange(self, s, r1, r2, step=1): - self.assertEqual(list(compat_range(r1, r2, step)), + self.assertEqual(list(range(r1, r2, step)), list(self.type_instance(s))) def test_range(self): diff --git a/oslo_config/tests/test_validator.py b/oslo_config/tests/test_validator.py index 9d4aef8c..a2ffde7c 100644 --- a/oslo_config/tests/test_validator.py +++ b/oslo_config/tests/test_validator.py @@ -14,7 +14,6 @@ import mock from oslotest import base -import six from oslo_config import cfg from oslo_config import fixture @@ -49,10 +48,6 @@ class TestValidator(base.BaseTestCase): self.conf = cfg.ConfigOpts() self.conf_fixture = self.useFixture(fixture.Config(self.conf)) validator._register_cli_opts(self.conf) - if six.PY2: - self.open_name = '__builtin__.open' - else: - self.open_name = 'builtins.open' @mock.patch('oslo_config.validator.load_opt_data') def test_passing(self, mock_lod): @@ -60,7 +55,7 @@ class TestValidator(base.BaseTestCase): self.conf_fixture.config(opt_data='mocked.yaml', input_file='mocked.conf') m = mock.mock_open(read_data=VALID_CONF) - with mock.patch(self.open_name, m): + with mock.patch('builtins.open', m): self.assertEqual(0, validator._validate(self.conf)) @mock.patch('oslo_config.validator.load_opt_data') @@ -69,7 +64,7 @@ class TestValidator(base.BaseTestCase): self.conf_fixture.config(opt_data='mocked.yaml', input_file='mocked.conf') m = mock.mock_open(read_data=DEPRECATED_CONF) - with mock.patch(self.open_name, m): + with mock.patch('builtins.open', m): self.assertEqual(0, validator._validate(self.conf)) @mock.patch('oslo_config.validator.load_opt_data') @@ -79,7 +74,7 @@ class TestValidator(base.BaseTestCase): input_file='mocked.conf', fatal_warnings=True) m = mock.mock_open(read_data=DEPRECATED_CONF) - with mock.patch(self.open_name, m): + with mock.patch('builtins.open', m): self.assertEqual(1, validator._validate(self.conf)) @mock.patch('oslo_config.validator.load_opt_data') @@ -88,7 +83,7 @@ class TestValidator(base.BaseTestCase): self.conf_fixture.config(opt_data='mocked.yaml', input_file='mocked.conf') m = mock.mock_open(read_data=INVALID_CONF) - with mock.patch(self.open_name, m): + with mock.patch('builtins.open', m): self.assertEqual(1, validator._validate(self.conf)) @mock.patch('oslo_config.validator.load_opt_data') @@ -97,7 +92,7 @@ class TestValidator(base.BaseTestCase): self.conf_fixture.config(opt_data='mocked.yaml', input_file='mocked.conf') m = mock.mock_open(read_data=MISSING_GROUP_CONF) - with mock.patch(self.open_name, m): + with mock.patch('builtins.open', m): self.assertEqual(1, validator._validate(self.conf)) @mock.patch('oslo_config.validator.load_opt_data') @@ -107,7 +102,7 @@ class TestValidator(base.BaseTestCase): input_file='mocked.conf', exclude_group=['oo']) m = mock.mock_open(read_data=MISSING_GROUP_CONF) - with mock.patch(self.open_name, m): + with mock.patch('builtins.open', m): self.assertEqual(0, validator._validate(self.conf)) def test_invalid_options(self): diff --git a/oslo_config/types.py b/oslo_config/types.py index 223fffbb..dfd89bce 100644 --- a/oslo_config/types.py +++ b/oslo_config/types.py @@ -28,12 +28,10 @@ import abc from debtcollector import removals import netaddr import rfc3986 -import six -from six.moves import range as compat_range -@six.add_metaclass(abc.ABCMeta) -class ConfigType(object): +class ConfigType(object, metaclass=abc.ABCMeta): + def __init__(self, type_name='unknown type'): self.type_name = type_name @@ -44,7 +42,7 @@ class ConfigType(object): """ if sample_default is not None: - if isinstance(sample_default, six.string_types): + if isinstance(sample_default, str): default_str = sample_default else: default_str = self._formatter(sample_default) @@ -55,9 +53,9 @@ class ConfigType(object): return [default_str] def quote_trailing_and_leading_space(self, str_val): - if not isinstance(str_val, six.string_types): + if not isinstance(str_val, str): warnings.warn('converting \'%s\' to a string' % str_val) - str_val = six.text_type(str_val) + str_val = str(str_val) if str_val.strip() != str_val: return '"%s"' % str_val return str_val @@ -135,7 +133,7 @@ class String(ConfigType): re_flags = re.IGNORECASE if self.ignore_case else 0 # Check if regex is a string or an already compiled regex - if isinstance(regex, six.string_types): + if isinstance(regex, str): self.regex = re.compile(regex, re_flags) else: self.regex = re.compile(regex.pattern, re_flags | regex.flags) @@ -351,7 +349,7 @@ class Number(ConfigType): ) def _formatter(self, value): - return six.text_type(value) + return str(value) class Integer(Number): @@ -484,7 +482,7 @@ class List(ConfigType): def __call__(self, value): if isinstance(value, (list, tuple)): - return list(six.moves.map(self.item_type, value)) + return list(map(self.item_type, value)) s = value.strip().rstrip(',') if self.bounds: @@ -531,7 +529,7 @@ class List(ConfigType): def _formatter(self, value): fmtstr = '[{}]' if self.bounds else '{}' - if isinstance(value, six.string_types): + if isinstance(value, str): return fmtstr.format(value) if isinstance(value, list): value = [ @@ -585,7 +583,7 @@ class Range(ConfigType): step = -1 if self.inclusive: right += step - return compat_range(left, right, step) + return range(left, right, step) def __eq__(self, other): return ( diff --git a/requirements.txt b/requirements.txt index 5a20c04d..70a27d78 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,6 @@ debtcollector>=1.2.0 # Apache-2.0 netaddr>=0.7.18 # BSD -six>=1.10.0 # MIT stevedore>=1.20.0 # Apache-2.0 oslo.i18n>=3.15.3 # Apache-2.0 rfc3986>=1.2.0 # Apache-2.0 diff --git a/test-requirements.txt b/test-requirements.txt index b6e4dda5..0d3ddef0 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -20,7 +20,8 @@ oslo.log>=3.36.0 # Apache-2.0 # deps = {[testenv]deps} coverage coverage!=4.4,>=4.0 # Apache-2.0 -# mocking framework +# we can switch to unittest.mock once we drop support for Python 3.6 as that +# includes https://bugs.python.org/issue32933 mock>=3.0.0 # BSD requests_mock>=1.5.0 # Apache-2.0