Remove py2.7 support
The underlying library (charms.reactive) no longer support py27, and reactive charms are only py35 and later supported. Thus, there is no reason to support py27 in charms.openstack. Note: the zuul gate still has a py27 test so that is left in the tox.ini but it simply evaluates to true. Change-Id: I9a4e18038b706286f60e64fcf67f3e63a90feda9
This commit is contained in:
parent
e67bce05d4
commit
747b5e1d87
|
@ -19,8 +19,6 @@ import itertools
|
|||
import re
|
||||
import weakref
|
||||
|
||||
import six
|
||||
|
||||
import charms.reactive as reactive
|
||||
import charms.reactive.bus
|
||||
import charmhelpers.contrib.hahelpers.cluster as ch_cluster
|
||||
|
@ -437,7 +435,7 @@ def make_default_configuration_adapter_class(base_cls=None,
|
|||
if not custom_properties:
|
||||
return base_cls
|
||||
# turns the functions into properties on the class
|
||||
properties = {n: property(f) for n, f in six.iteritems(custom_properties)}
|
||||
properties = {n: property(f) for n, f in custom_properties.items()}
|
||||
# build a custom class with the custom properties
|
||||
return type('DefaultConfigurationAdapter', (base_cls, ), properties)
|
||||
|
||||
|
@ -466,8 +464,7 @@ class ConfigurationAdapter(object):
|
|||
if charm_instance is not None:
|
||||
self._charm_instance_weakref = weakref.ref(charm_instance)
|
||||
# copy over (statically) the items of the charms Juju configuration
|
||||
_config = hookenv.config()
|
||||
for k, v in six.iteritems(_config):
|
||||
for k, v in hookenv.config().items():
|
||||
k = k.replace('-', '_')
|
||||
setattr(self, k, v)
|
||||
|
||||
|
@ -850,7 +847,7 @@ def make_default_relation_adapter(base_cls, relation, properties):
|
|||
if not properties:
|
||||
return base_cls
|
||||
# convert the functions into properties
|
||||
props = {n: property(f) for n, f in six.iteritems(properties)}
|
||||
props = {n: property(f) for n, f in properties.items()}
|
||||
# turn 'my-Something_interface' into 'MySomethingInterface'
|
||||
# future proof incase other chars come in which can't be in an Python Class
|
||||
# name.
|
||||
|
@ -923,10 +920,9 @@ class OpenStackRelationAdapters(object):
|
|||
for cls in reversed(self.__class__.mro()):
|
||||
self._adapters.update(
|
||||
{k.replace('-', '_'): v
|
||||
for k, v in six.iteritems(
|
||||
getattr(cls, 'relation_adapters', {}))})
|
||||
for k, v in getattr(cls, 'relation_adapters', {}).items()})
|
||||
# now we have to add in any customisations to those adapters
|
||||
for relation, properties in six.iteritems(_custom_adapter_properties):
|
||||
for relation, properties in _custom_adapter_properties.items():
|
||||
relation = relation.replace('-', '_')
|
||||
try:
|
||||
cls = self._adapters[relation]
|
||||
|
|
|
@ -15,9 +15,6 @@
|
|||
# OpenStackCharm() - base class for build OpenStack charms from for the
|
||||
# reactive framework.
|
||||
|
||||
# need/want absolute imports for the package imports to work properly
|
||||
from __future__ import absolute_import
|
||||
|
||||
import base64
|
||||
import collections
|
||||
import contextlib
|
||||
|
@ -30,7 +27,6 @@ import string
|
|||
import subprocess
|
||||
|
||||
import apt_pkg as apt
|
||||
import six
|
||||
|
||||
import charmhelpers.contrib.network.ip as ch_ip
|
||||
import charmhelpers.contrib.openstack.templating as os_templating
|
||||
|
@ -478,8 +474,7 @@ class OpenStackCharmMeta(type):
|
|||
return _singleton
|
||||
|
||||
|
||||
@six.add_metaclass(OpenStackCharmMeta)
|
||||
class OpenStackCharm(object):
|
||||
class OpenStackCharm(object, metaclass=OpenStackCharmMeta):
|
||||
"""
|
||||
Base class for all OpenStack Charm classes;
|
||||
encapulates general OpenStack charm payload operations
|
||||
|
@ -993,7 +988,7 @@ class OpenStackCharm(object):
|
|||
available_states = reactive.bus.get_states().keys()
|
||||
status = None
|
||||
messages = []
|
||||
for relation, states in six.iteritems(states_to_check):
|
||||
for relation, states in states_to_check.items():
|
||||
for state, err_status, err_msg in states:
|
||||
if state not in available_states:
|
||||
messages.append(err_msg)
|
||||
|
@ -1144,7 +1139,7 @@ class OpenStackCharm(object):
|
|||
return None
|
||||
|
||||
vers_map = os_utils.OPENSTACK_CODENAMES
|
||||
for version, cname in six.iteritems(vers_map):
|
||||
for version, cname in vers_map.items():
|
||||
if cname == codename:
|
||||
return version
|
||||
|
||||
|
|
2
tox.ini
2
tox.ini
|
@ -26,7 +26,7 @@ basepython = python3.5
|
|||
deps = -r{toxinidir}/test-requirements.txt
|
||||
|
||||
[testenv:pep8]
|
||||
basepython = python2.7
|
||||
basepython = python3.5
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = flake8 {posargs} charms_openstack unit_tests
|
||||
|
||||
|
|
|
@ -18,14 +18,8 @@
|
|||
import contextlib
|
||||
import io
|
||||
import mock
|
||||
import six
|
||||
import unittest
|
||||
|
||||
if not six.PY3:
|
||||
builtin_open = '__builtin__.open'
|
||||
else:
|
||||
builtin_open = 'builtins.open'
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def patch_open():
|
||||
|
@ -41,7 +35,7 @@ def patch_open():
|
|||
mock_open(*args, **kwargs)
|
||||
yield mock_file
|
||||
|
||||
with mock.patch(builtin_open, stub_open):
|
||||
with mock.patch('builtins.open', stub_open):
|
||||
yield mock_open, mock_file
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue