summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHervé Beraud <hberaud@redhat.com>2019-11-20 19:37:27 +0100
committerHervé Beraud <hberaud@redhat.com>2020-04-23 14:49:12 +0200
commit8c96a4d85674e164d562f9e7907c18bc997d0efb (patch)
treed1a61bdc0e5ff7b7c475b24b643024c830cc1a33
parent062ce29a3b60f8457b09f9abd98f32ee632ddde4 (diff)
downloadheat-8c96a4d85674e164d562f9e7907c18bc997d0efb.tar.gz
Remove six and python 2.7 full support
Six is in use to help us to keep support for python 2.7. Since the ussuri cycle we decide to remove the python 2.7 support so we can go ahead and also remove six usage from the python code. Review process and help ----------------------- Removing six introduce a lot of changes and an huge amount of modified files To simplify reviews we decided to split changes into several patches to avoid painful reviews and avoid mistakes. To review this patch you can use the six documentation [1] to obtain help and understand choices. Additional informations ----------------------- Changes related to 'six.b(data)' [2] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ six.b [2] encode the given datas in latin-1 in python3 so I did the same things in this patch. Latin-1 is equal to iso-8859-1 [3]. This encoding is the default encoding [4] of certain descriptive HTTP headers. I suggest to keep latin-1 for the moment and to move to another encoding in a follow-up patch if needed to move to most powerful encoding (utf8). HTML4 support utf8 charset and utf8 is the default charset for HTML5 [5]. Note that this commit message is autogenerated and not necesserly contains changes related to 'six.b' [1] https://six.readthedocs.io/ [2] https://six.readthedocs.io/#six.b [3] https://docs.python.org/3/library/codecs.html#standard-encodings [4] https://www.w3schools.com/charsets/ref_html_8859.asp [5] https://www.w3schools.com/html/html_charset.asp Patch 28 of a serie of 28 patches six fully removed now! Thank you six for the rendered services! Change-Id: If44ee4b565cc9390fa0422fba4dda080b4f90b98
-rw-r--r--heat/tests/test_validate.py37
-rw-r--r--heat_integrationtests/common/test.py5
-rw-r--r--heat_integrationtests/functional/test_autoscaling.py3
-rw-r--r--heat_integrationtests/functional/test_aws_stack.py2
-rw-r--r--heat_integrationtests/functional/test_resource_group.py5
-rw-r--r--heat_integrationtests/functional/test_template_resource.py5
-rw-r--r--requirements.txt1
-rw-r--r--tools/custom_guidelines.py7
8 files changed, 29 insertions, 36 deletions
diff --git a/heat/tests/test_validate.py b/heat/tests/test_validate.py
index 94780f5db..febef0d4e 100644
--- a/heat/tests/test_validate.py
+++ b/heat/tests/test_validate.py
@@ -13,7 +13,6 @@
import mock
from oslo_messaging.rpc import dispatcher
-import six
import webob
from heat.common import exception
@@ -1309,7 +1308,7 @@ class ValidateTest(common.HeatTestCase):
res = dict(self.engine.validate_template(self.ctx, t, {}))
self.assertEqual({'Error': 'Resources must contain Resource. '
- 'Found a [%s] instead' % six.text_type},
+ 'Found a [%s] instead' % str},
res)
def test_invalid_section_cfn(self):
@@ -1621,7 +1620,7 @@ class ValidateTest(common.HeatTestCase):
'parameter_groups.Database '
'Group: The InstanceType parameter must be '
'assigned to one parameter group only.'),
- six.text_type(exc))
+ str(exc))
def test_validate_duplicate_parameters_no_label(self):
t = template_format.parse(test_template_parameters_duplicate_no_label)
@@ -1634,7 +1633,7 @@ class ValidateTest(common.HeatTestCase):
'parameter_groups.: '
'The key_name parameter must be '
'assigned to one parameter group only.'),
- six.text_type(exc))
+ str(exc))
def test_validate_invalid_parameter_in_group(self):
t = template_format.parse(test_template_invalid_parameter_name)
@@ -1652,7 +1651,7 @@ class ValidateTest(common.HeatTestCase):
'parameter_groups.Database Group: The grouped '
'parameter SomethingNotHere does not '
'reference a valid parameter.'),
- six.text_type(exc))
+ str(exc))
def test_validate_invalid_parameter_no_label(self):
t = template_format.parse(test_template_invalid_parameter_no_label)
@@ -1666,7 +1665,7 @@ class ValidateTest(common.HeatTestCase):
'parameter_groups.: The grouped '
'parameter key_name does not '
'reference a valid parameter.'),
- six.text_type(exc))
+ str(exc))
def test_validate_no_parameters_in_group(self):
t = template_format.parse(test_template_no_parameters)
@@ -1677,7 +1676,7 @@ class ValidateTest(common.HeatTestCase):
self.assertEqual(_('Parameter Groups error: parameter_groups.Server '
'Group: The parameters must be provided for each '
- 'parameter group.'), six.text_type(exc))
+ 'parameter group.'), str(exc))
def test_validate_parameter_groups_not_list(self):
t = template_format.parse(test_template_parameter_groups_not_list)
@@ -1688,7 +1687,7 @@ class ValidateTest(common.HeatTestCase):
self.assertEqual(_('Parameter Groups error: parameter_groups: '
'The parameter_groups should be '
- 'a list.'), six.text_type(exc))
+ 'a list.'), str(exc))
def test_validate_parameters_not_list(self):
t = template_format.parse(test_template_parameters_not_list)
@@ -1700,7 +1699,7 @@ class ValidateTest(common.HeatTestCase):
self.assertEqual(_('Parameter Groups error: '
'parameter_groups.Server Group: '
'The parameters of parameter group should be '
- 'a list.'), six.text_type(exc))
+ 'a list.'), str(exc))
def test_validate_parameters_error_no_label(self):
t = template_format.parse(test_template_parameters_error_no_label)
@@ -1711,7 +1710,7 @@ class ValidateTest(common.HeatTestCase):
self.assertEqual(_('Parameter Groups error: parameter_groups.: '
'The parameters of parameter group should be '
- 'a list.'), six.text_type(exc))
+ 'a list.'), str(exc))
def test_validate_allowed_values_integer(self):
t = template_format.parse(test_template_allowed_integers)
@@ -1750,7 +1749,7 @@ class ValidateTest(common.HeatTestCase):
err = self.assertRaises(exception.StackValidationFailed,
stack.validate)
self.assertIn('"3" is not an allowed value [1, 4, 8]',
- six.text_type(err))
+ str(err))
# test with size parameter provided as number
template.env = environment.Environment({'size': 3})
@@ -1758,7 +1757,7 @@ class ValidateTest(common.HeatTestCase):
err = self.assertRaises(exception.StackValidationFailed,
stack.validate)
self.assertIn('3 is not an allowed value [1, 4, 8]',
- six.text_type(err))
+ str(err))
def test_validate_not_allowed_values_integer_str(self):
t = template_format.parse(test_template_allowed_integers_str)
@@ -1770,7 +1769,7 @@ class ValidateTest(common.HeatTestCase):
err = self.assertRaises(exception.StackValidationFailed,
stack.validate)
self.assertIn('"3" is not an allowed value ["1", "4", "8"]',
- six.text_type(err))
+ str(err))
# test with size parameter provided as number
template.env = environment.Environment({'size': 3})
@@ -1778,7 +1777,7 @@ class ValidateTest(common.HeatTestCase):
err = self.assertRaises(exception.StackValidationFailed,
stack.validate)
self.assertIn('3 is not an allowed value ["1", "4", "8"]',
- six.text_type(err))
+ str(err))
def test_validate_invalid_outputs(self):
t = template_format.parse(test_template_invalid_outputs)
@@ -1789,7 +1788,7 @@ class ValidateTest(common.HeatTestCase):
error_message = ('outputs.string.value.get_attr: Arguments to '
'"get_attr" must be of the form '
'[resource_name, attribute, (path), ...]')
- self.assertEqual(error_message, six.text_type(err))
+ self.assertEqual(error_message, str(err))
def test_validate_resource_attr_invalid_type(self):
t = template_format.parse("""
@@ -1802,7 +1801,7 @@ class ValidateTest(common.HeatTestCase):
stack = parser.Stack(self.ctx, 'test_stack', template)
ex = self.assertRaises(exception.StackValidationFailed, stack.validate)
self.assertEqual('Resource resource type type must be string',
- six.text_type(ex))
+ str(ex))
def test_validate_resource_attr_invalid_type_cfn(self):
t = template_format.parse("""
@@ -1814,7 +1813,7 @@ class ValidateTest(common.HeatTestCase):
stack = parser.Stack(self.ctx, 'test_stack', tmpl.Template(t))
ex = self.assertRaises(exception.StackValidationFailed, stack.validate)
self.assertEqual('Resource Resource Type type must be string',
- six.text_type(ex))
+ str(ex))
def test_validate_resource_invalid_key(self):
t = template_format.parse("""
@@ -1827,7 +1826,7 @@ class ValidateTest(common.HeatTestCase):
template = tmpl.Template(t)
stack = parser.Stack(self.ctx, 'test_stack', template)
ex = self.assertRaises(exception.StackValidationFailed, stack.validate)
- self.assertIn('wibble', six.text_type(ex))
+ self.assertIn('wibble', str(ex))
def test_validate_resource_invalid_cfn_key_in_hot(self):
t = template_format.parse("""
@@ -1840,7 +1839,7 @@ class ValidateTest(common.HeatTestCase):
template = tmpl.Template(t)
stack = parser.Stack(self.ctx, 'test_stack', template)
ex = self.assertRaises(exception.StackValidationFailed, stack.validate)
- self.assertIn('Properties', six.text_type(ex))
+ self.assertIn('Properties', str(ex))
def test_validate_resource_invalid_key_cfn(self):
t = template_format.parse("""
diff --git a/heat_integrationtests/common/test.py b/heat_integrationtests/common/test.py
index d5c259501..afa1ec20d 100644
--- a/heat_integrationtests/common/test.py
+++ b/heat_integrationtests/common/test.py
@@ -15,14 +15,13 @@ import random
import re
import subprocess
import time
+import urllib
import fixtures
from heatclient import exc as heat_exceptions
from keystoneauth1 import exceptions as kc_exceptions
from oslo_log import log as logging
from oslo_utils import timeutils
-import six
-from six.moves import urllib
from tempest import config
import testscenarios
import testtools
@@ -59,7 +58,7 @@ def call_until_true(duration, sleep_for, func, *args, **kwargs):
def rand_name(name=''):
- randbits = six.text_type(random.randint(1, 0x7fffffff))
+ randbits = str(random.randint(1, 0x7fffffff))
if name:
return name + '-' + randbits
else:
diff --git a/heat_integrationtests/functional/test_autoscaling.py b/heat_integrationtests/functional/test_autoscaling.py
index 369fa000c..46da2a86e 100644
--- a/heat_integrationtests/functional/test_autoscaling.py
+++ b/heat_integrationtests/functional/test_autoscaling.py
@@ -15,7 +15,6 @@ import json
from heatclient import exc
from oslo_log import log as logging
-import six
from testtools import matchers
from heat_integrationtests.common import test
@@ -736,7 +735,7 @@ outputs:
stack_identifier, 'ScaleUpPolicy')
error_msg = 'Signal resource during SUSPEND is not supported'
- self.assertIn(error_msg, six.text_type(ex))
+ self.assertIn(error_msg, str(ex))
ev = self.wait_for_event_with_reason(
stack_identifier,
reason='Cannot signal resource during SUSPEND',
diff --git a/heat_integrationtests/functional/test_aws_stack.py b/heat_integrationtests/functional/test_aws_stack.py
index 05539dca8..3e775ca7a 100644
--- a/heat_integrationtests/functional/test_aws_stack.py
+++ b/heat_integrationtests/functional/test_aws_stack.py
@@ -13,8 +13,8 @@
import hashlib
import json
import random
+from urllib import parse
-from six.moves.urllib import parse
from swiftclient import utils as swiftclient_utils
import yaml
diff --git a/heat_integrationtests/functional/test_resource_group.py b/heat_integrationtests/functional/test_resource_group.py
index 95ae7799f..ebce70df7 100644
--- a/heat_integrationtests/functional/test_resource_group.py
+++ b/heat_integrationtests/functional/test_resource_group.py
@@ -14,7 +14,6 @@ import copy
import json
from heatclient import exc
-import six
import yaml
from heat_integrationtests.functional import functional_base
@@ -88,12 +87,12 @@ resources:
ex = self.assertRaises(exc.HTTPBadRequest, self.update_stack,
stack_identifier, template_two_nested,
environment=env, files=files)
- self.assertIn(expected_err, six.text_type(ex))
+ self.assertIn(expected_err, str(ex))
ex = self.assertRaises(exc.HTTPBadRequest, self.stack_create,
template=template_two_nested,
environment=env, files=files)
- self.assertIn(expected_err, six.text_type(ex))
+ self.assertIn(expected_err, str(ex))
def _validate_resources(self, stack_identifier, expected_count):
resources = self.list_group_resources(stack_identifier,
diff --git a/heat_integrationtests/functional/test_template_resource.py b/heat_integrationtests/functional/test_template_resource.py
index 21a4ec061..f2a513b3a 100644
--- a/heat_integrationtests/functional/test_template_resource.py
+++ b/heat_integrationtests/functional/test_template_resource.py
@@ -13,7 +13,6 @@
import json
from heatclient import exc as heat_exceptions
-import six
import yaml
from heat_integrationtests.common import test
@@ -804,7 +803,7 @@ outputs:
except heat_exceptions.HTTPBadRequest as exc:
exp = ('ERROR: Required property two for facade '
'OS::Thingy missing in provider')
- self.assertEqual(exp, six.text_type(exc))
+ self.assertEqual(exp, str(exc))
def test_missing_output(self):
templ_missing_output = '''
@@ -828,7 +827,7 @@ resources:
except heat_exceptions.HTTPBadRequest as exc:
exp = ('ERROR: Attribute here-it-is for facade '
'OS::Thingy missing in provider')
- self.assertEqual(exp, six.text_type(exc))
+ self.assertEqual(exp, str(exc))
class TemplateResourceNewParamTest(functional_base.FunctionalTestsBase):
diff --git a/requirements.txt b/requirements.txt
index f77d011a4..ad414aa17 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -59,7 +59,6 @@ PyYAML>=3.12 # MIT
requests>=2.14.2 # Apache-2.0
tenacity>=4.4.0 # Apache-2.0
Routes>=2.3.1 # MIT
-six>=1.10.0 # MIT
SQLAlchemy!=1.1.5,!=1.1.6,!=1.1.7,!=1.1.8,>=1.0.10 # MIT
sqlalchemy-migrate>=0.11.0 # Apache-2.0
stevedore>=1.20.0 # Apache-2.0
diff --git a/tools/custom_guidelines.py b/tools/custom_guidelines.py
index 3e8f4e2c7..53306d0cc 100644
--- a/tools/custom_guidelines.py
+++ b/tools/custom_guidelines.py
@@ -16,7 +16,6 @@ import re
import sys
from oslo_log import log
-import six
from heat.common.i18n import _
from heat.engine import constraints
@@ -101,7 +100,7 @@ class HeatCustomGuidelines(object):
def _check_resource_schemas(self, resource, schema, schema_name,
error_path=None):
- for key, value in six.iteritems(schema):
+ for key, value in schema.items():
if error_path is None:
error_path = [resource.__name__, key]
else:
@@ -129,7 +128,7 @@ class HeatCustomGuidelines(object):
error_path.pop()
def _check_resource_methods(self, resource):
- for method in six.itervalues(resource.__dict__):
+ for method in resource.__dict__.values():
# need to skip non-functions attributes
if not callable(method):
continue
@@ -159,7 +158,7 @@ class HeatCustomGuidelines(object):
cls_file = open(cls.__module__.replace('.', '/') + '.py')
except IOError as ex:
LOG.warning('Cannot perform trailing spaces check on '
- 'resource module: %s', six.text_type(ex))
+ 'resource module: %s', str(ex))
continue
lines = [line.strip() for line in cls_file.readlines()]
idx = 0