Remove six.add_metaclass

With python 3.x, classes can use the metaclass= logic
to not require usage of the six library.

Subsequent patches will replace other six usages.

Change-Id: I02b6fbbdc70b228e1734c6085ae4e06a484a556e
This commit is contained in:
Q.hongtao 2020-09-18 22:19:02 +08:00
parent 71d4993edc
commit a80f3d4f0e
12 changed files with 20 additions and 57 deletions

View File

@ -13,7 +13,6 @@
# under the License.
import abc
import six
from oslo_log import log
@ -24,8 +23,7 @@ from vitrage.utils import datetime as datetime_utils
LOG = log.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class DriverBase(object):
class DriverBase(object, metaclass=abc.ABCMeta):
_datasource_name = None

View File

@ -15,7 +15,6 @@
import abc
from collections import namedtuple
import six
from oslo_config import cfg
from oslo_log import log as logging
@ -99,8 +98,7 @@ def is_update_event(event):
return event[DSProps.DATASOURCE_ACTION] == DatasourceAction.UPDATE
@six.add_metaclass(abc.ABCMeta)
class TransformerBase(object):
class TransformerBase(object, metaclass=abc.ABCMeta):
KEY_SEPARATOR = ':'
QUERY_RESULT = 'graph_query_result'

View File

@ -14,11 +14,8 @@
import abc
import six
@six.add_metaclass(abc.ABCMeta)
class HandlerBase(object):
class HandlerBase(object, metaclass=abc.ABCMeta):
def __init__(self):
pass

View File

@ -14,11 +14,8 @@
import abc
import six
@six.add_metaclass(abc.ABCMeta)
class ProcessorBase(object):
class ProcessorBase(object, metaclass=abc.ABCMeta):
def __init__(self):
pass

View File

@ -14,7 +14,6 @@
import abc
from collections import namedtuple
import six
ActionStepWrapper = namedtuple('ActionStepWrapper', ['type', 'params'])
@ -23,8 +22,7 @@ ActionStepWrapper = namedtuple('ActionStepWrapper', ['type', 'params'])
EVALUATOR_EVENT_TYPE = 'type'
@six.add_metaclass(abc.ABCMeta)
class Recipe(object):
class Recipe(object, metaclass=abc.ABCMeta):
@staticmethod
@abc.abstractmethod

View File

@ -13,7 +13,6 @@
# under the License.
import abc
import six
from oslo_log import log
from vitrage.evaluator.template_fields import TemplateFields
@ -66,8 +65,7 @@ def get_template_schema(template):
return get_content_fault_result(63), None
@six.add_metaclass(abc.ABCMeta)
class ActionValidator(object):
class ActionValidator(object, metaclass=abc.ABCMeta):
@staticmethod
@abc.abstractmethod

View File

@ -15,15 +15,12 @@
import abc
from collections import namedtuple
from osprofiler import profiler
import six
Mapping = \
namedtuple('Mapping', ['subgraph_element', 'graph_element', 'is_vertex'])
@six.add_metaclass(profiler.TracedMeta)
@six.add_metaclass(abc.ABCMeta)
class GraphAlgorithm(object):
class GraphAlgorithm(object, metaclass=profiler.TracedMeta):
__trace_args__ = {'name': 'graph',
'info': None,
'hide_args': False,

View File

@ -21,7 +21,6 @@ vitrage.graph.driver namespace.
"""
import abc
import copy
import six
from vitrage.graph.driver.elements import Edge
from vitrage.graph.driver.elements import Vertex
@ -34,8 +33,7 @@ class Direction(object):
BOTH = 3
@six.add_metaclass(abc.ABCMeta)
class Graph(object):
class Graph(object, metaclass=abc.ABCMeta):
def __init__(self, name, graph_type, vertices=None, edges=None):
"""Create a Graph instance

View File

@ -13,11 +13,9 @@
# under the License.
import abc
import six
@six.add_metaclass(abc.ABCMeta)
class MachineLearningBase(object):
class MachineLearningBase(object, metaclass=abc.ABCMeta):
@abc.abstractmethod
def process_event(self, data, event_type):

View File

@ -13,11 +13,9 @@
# under the License.
import abc
import six
@six.add_metaclass(abc.ABCMeta)
class NotifierBase(object):
class NotifierBase(object, metaclass=abc.ABCMeta):
@abc.abstractmethod
def process_event(self, data, event_type):

View File

@ -13,11 +13,8 @@
# under the License.
import abc
import six
@six.add_metaclass(abc.ABCMeta)
class SnmpSenderBase(object):
class SnmpSenderBase(object, metaclass=abc.ABCMeta):
"""Abstract Vitrage snmp trap sender"""
@abc.abstractmethod

View File

@ -13,11 +13,8 @@
# under the License.
import abc
import six
@six.add_metaclass(abc.ABCMeta)
class Connection(object):
class Connection(object, metaclass=abc.ABCMeta):
"""Base class for storage system connections."""
def __init__(self, url):
@ -64,8 +61,7 @@ class Connection(object):
raise NotImplementedError('clear is not implemented')
@six.add_metaclass(abc.ABCMeta)
class ActiveActionsConnection(object):
class ActiveActionsConnection(object, metaclass=abc.ABCMeta):
@abc.abstractmethod
def create(self, active_action):
"""Create a new action.
@ -112,8 +108,7 @@ class ActiveActionsConnection(object):
raise NotImplementedError('delete active actions is not implemented')
@six.add_metaclass(abc.ABCMeta)
class WebhooksConnection(object):
class WebhooksConnection(object, metaclass=abc.ABCMeta):
@abc.abstractmethod
def create(self, webhook):
@ -145,8 +140,7 @@ class WebhooksConnection(object):
raise NotImplementedError('delete webhook is not implemented')
@six.add_metaclass(abc.ABCMeta)
class TemplatesConnection(object):
class TemplatesConnection(object, metaclass=abc.ABCMeta):
@abc.abstractmethod
def create(self, template):
@ -183,8 +177,7 @@ class TemplatesConnection(object):
raise NotImplementedError('Delete Templates not implemented')
@six.add_metaclass(abc.ABCMeta)
class EventsConnection(object):
class EventsConnection(object, metaclass=abc.ABCMeta):
def create(self, event):
"""Create a new event.
@ -216,8 +209,7 @@ class EventsConnection(object):
raise NotImplementedError('delete events is not implemented')
@six.add_metaclass(abc.ABCMeta)
class GraphSnapshotsConnection(object):
class GraphSnapshotsConnection(object, metaclass=abc.ABCMeta):
def create(self, graph_snapshot):
"""Create a new graph snapshot.
@ -244,8 +236,7 @@ class GraphSnapshotsConnection(object):
raise NotImplementedError('delete graph snapshots not implemented')
@six.add_metaclass(abc.ABCMeta)
class AlarmsConnection(object):
class AlarmsConnection(object, metaclass=abc.ABCMeta):
def create(self, alarm):
raise NotImplementedError('create alarm not implemented')
@ -259,8 +250,7 @@ class AlarmsConnection(object):
raise NotImplementedError('delete alarms not implemented')
@six.add_metaclass(abc.ABCMeta)
class EdgesConnection(object):
class EdgesConnection(object, metaclass=abc.ABCMeta):
def create(self, edge):
raise NotImplementedError('create edge not implemented')
@ -274,8 +264,7 @@ class EdgesConnection(object):
raise NotImplementedError('delete edges not implemented')
@six.add_metaclass(abc.ABCMeta)
class ChangesConnection(object):
class ChangesConnection(object, metaclass=abc.ABCMeta):
def create(self, change):
raise NotImplementedError('create change not implemented')