Remove usage of six

With python3.x, classes can use 'metaclass=' instead of
'six.add_metaclass', 'six.integer_type' can be replaced
by 'int', 'six.string_type' and 'six.text_type' are just
'str'.

Change-Id: I40a020aa4a8e69a8dd7e800352dc54a9e694d500
This commit is contained in:
zhanghao 2020-05-26 04:18:41 -04:00
parent f51744b4fe
commit f8f9463cf7
8 changed files with 7 additions and 21 deletions

View File

@ -123,7 +123,7 @@ deprecated-modules=
[TYPECHECK] [TYPECHECK]
# List of module names for which member attributes should not be checked # List of module names for which member attributes should not be checked
ignored-modules=six.moves,_MovedItems ignored-modules=
[REPORTS] [REPORTS]
# Tells whether to display a full report or only the messages # Tells whether to display a full report or only the messages

View File

@ -119,7 +119,6 @@ requestsexceptions==1.2.0
rfc3986==0.3.1 rfc3986==0.3.1
Routes==2.3.1 Routes==2.3.1
simplejson==3.5.1 simplejson==3.5.1
six==1.10.0
snowballstemmer==1.2.1 snowballstemmer==1.2.1
Sphinx==1.6.5 Sphinx==1.6.5
sphinxcontrib-svg2pdfconverter==0.1.0 # BSD sphinxcontrib-svg2pdfconverter==0.1.0 # BSD

View File

@ -15,10 +15,5 @@
import gettext import gettext
import six
gettext.install('neutron')
if six.PY2:
gettext.install('neutron', unicode=1)
else:
gettext.install('neutron')

View File

@ -24,7 +24,6 @@ from neutron_lib import exceptions as n_exc
from neutron_lib.exceptions import agent as agent_exc from neutron_lib.exceptions import agent as agent_exc
from neutron_lib.plugins import directory from neutron_lib.plugins import directory
from oslo_log import log as logging from oslo_log import log as logging
import six
import webob import webob
from neutron_dynamic_routing._i18n import _, _LE from neutron_dynamic_routing._i18n import _, _LE
@ -145,8 +144,7 @@ class Bgp_dragentscheduler(api_extensions.ExtensionDescriptor):
return {} return {}
@six.add_metaclass(abc.ABCMeta) class BgpDrSchedulerPluginBase(object, metaclass=abc.ABCMeta):
class BgpDrSchedulerPluginBase(object):
"""REST API to operate BGP dynamic routing agent scheduler. """REST API to operate BGP dynamic routing agent scheduler.
All the methods must be executed in admin context. All the methods must be executed in admin context.

View File

@ -15,11 +15,8 @@
import abc import abc
import six
class BgpDriverBase(object, metaclass=abc.ABCMeta):
@six.add_metaclass(abc.ABCMeta)
class BgpDriverBase(object):
"""Base class for BGP Speaking drivers. """Base class for BGP Speaking drivers.
Any class which provides BGP functionality should extend this Any class which provides BGP functionality should extend this

View File

@ -14,7 +14,6 @@
# limitations under the License. # limitations under the License.
import netaddr import netaddr
import six
from neutron_lib import constants as lib_consts from neutron_lib import constants as lib_consts
@ -24,7 +23,7 @@ from neutron_dynamic_routing.services.bgp.common import constants as bgp_consts
# Parameter validation functions provided are provided by the base. # Parameter validation functions provided are provided by the base.
def validate_as_num(param, as_num): def validate_as_num(param, as_num):
if not isinstance(as_num, six.integer_types): if not isinstance(as_num, int):
raise bgp_driver_exc.InvalidParamType(param=param, raise bgp_driver_exc.InvalidParamType(param=param,
param_type='integer') param_type='integer')
@ -61,7 +60,7 @@ def validate_ip_addr(ip_addr):
def validate_string(param): def validate_string(param):
if param is not None: if param is not None:
if not isinstance(param, six.string_types): if not isinstance(param, str):
raise bgp_driver_exc.InvalidParamType(param=param, raise bgp_driver_exc.InvalidParamType(param=param,
param_type='string') param_type='string')

View File

@ -20,7 +20,6 @@ from os_ken.services.protocols.bgp import bgpspeaker
from os_ken.services.protocols.bgp.rtconf.neighbors import CONNECT_MODE_ACTIVE from os_ken.services.protocols.bgp.rtconf.neighbors import CONNECT_MODE_ACTIVE
from oslo_config import cfg from oslo_config import cfg
from oslo_utils import encodeutils from oslo_utils import encodeutils
import six
from neutron_dynamic_routing.services.bgp.agent import config as bgp_config from neutron_dynamic_routing.services.bgp.agent import config as bgp_config
from neutron_dynamic_routing.services.bgp.agent.driver import exceptions as bgp_driver_exc # noqa from neutron_dynamic_routing.services.bgp.agent.driver import exceptions as bgp_driver_exc # noqa
@ -112,7 +111,7 @@ class TestOsKenBgpDriver(base.BaseTestCase):
self.os_ken_bgp_driver.add_bgp_speaker(FAKE_LOCAL_AS1) self.os_ken_bgp_driver.add_bgp_speaker(FAKE_LOCAL_AS1)
self.assertEqual(1, self.assertEqual(1,
self.os_ken_bgp_driver.cache.get_hosted_bgp_speakers_count()) self.os_ken_bgp_driver.cache.get_hosted_bgp_speakers_count())
NEW_FAKE_PEER_PASSWORD = six.text_type(FAKE_PEER_PASSWORD) NEW_FAKE_PEER_PASSWORD = str(FAKE_PEER_PASSWORD)
self.os_ken_bgp_driver.add_bgp_peer( self.os_ken_bgp_driver.add_bgp_peer(
FAKE_LOCAL_AS1, FAKE_LOCAL_AS1,
FAKE_PEER_IP, FAKE_PEER_IP,

View File

@ -8,7 +8,6 @@ httplib2>=0.9.1 # MIT
netaddr>=0.7.18 # BSD netaddr>=0.7.18 # BSD
SQLAlchemy>=1.2.0 # MIT SQLAlchemy>=1.2.0 # MIT
alembic>=0.8.10 # MIT alembic>=0.8.10 # MIT
six>=1.10.0 # MIT
neutron-lib>=1.26.0 # Apache-2.0 neutron-lib>=1.26.0 # Apache-2.0
os-ken>=0.3.0 # Apache-2.0 os-ken>=0.3.0 # Apache-2.0
oslo.config>=5.2.0 # Apache-2.0 oslo.config>=5.2.0 # Apache-2.0