diff --git a/horizon/tables/actions.py b/horizon/tables/actions.py index d7234cf664..015d67a5c2 100644 --- a/horizon/tables/actions.py +++ b/horizon/tables/actions.py @@ -24,6 +24,7 @@ from django.utils.functional import Promise # noqa from django.utils.http import urlencode # noqa from django.utils.translation import pgettext_lazy from django.utils.translation import ugettext_lazy as _ +import six from horizon import exceptions from horizon import messages @@ -80,9 +81,9 @@ class BaseActionMetaClass(type): return klass +@six.add_metaclass(BaseActionMetaClass) class BaseAction(html.HTMLElement): """Common base class for all ``Action`` classes.""" - __metaclass__ = BaseActionMetaClass def __init__(self, **kwargs): super(BaseAction, self).__init__() diff --git a/horizon/tables/base.py b/horizon/tables/base.py index d3bad41f68..df8f7af2a7 100644 --- a/horizon/tables/base.py +++ b/horizon/tables/base.py @@ -33,6 +33,7 @@ from django.utils.http import urlencode from django.utils.safestring import mark_safe from django.utils import termcolors from django.utils.translation import ugettext_lazy as _ +import six from horizon import conf from horizon import exceptions @@ -1015,6 +1016,7 @@ class DataTableMetaclass(type): return type.__new__(mcs, name, bases, attrs) +@six.add_metaclass(DataTableMetaclass) class DataTable(object): """A class which defines a table with all data and associated actions. @@ -1039,7 +1041,6 @@ class DataTable(object): :class:`~horizon.tables.FilterAction` class (if one is provided) using the current request's query parameters. """ - __metaclass__ = DataTableMetaclass def __init__(self, request, data=None, needs_form_wrapper=None, **kwargs): self.request = request diff --git a/horizon/workflows/base.py b/horizon/workflows/base.py index cfb9e5bad0..dfce78a6ef 100644 --- a/horizon/workflows/base.py +++ b/horizon/workflows/base.py @@ -26,6 +26,7 @@ from django.template.defaultfilters import slugify # noqa from django.utils.encoding import force_unicode from django.utils.importlib import import_module # noqa from django.utils.translation import ugettext_lazy as _ +import six from horizon import base from horizon import exceptions @@ -73,6 +74,7 @@ class ActionMetaclass(forms.forms.DeclarativeFieldsMetaclass): return cls +@six.add_metaclass(ActionMetaclass) class Action(forms.Form): """An ``Action`` represents an atomic logical interaction you can have with the system. This is easier to understand with a conceptual example: in the @@ -123,8 +125,6 @@ class Action(forms.Form): customize your help text template to display practically anything. """ - __metaclass__ = ActionMetaclass - def __init__(self, request, context, *args, **kwargs): if request.method == "POST": super(Action, self).__init__(request.POST, initial=context) @@ -484,6 +484,7 @@ class UpdateMembersStep(Step): return self.slug + "_role_" + role_id +@six.add_metaclass(WorkflowMetaclass) class Workflow(html.HTMLElement): """A Workflow is a collection of Steps. Its interface is very straightforward, but it is responsible for handling some very @@ -587,7 +588,6 @@ class Workflow(html.HTMLElement): Defaults to ``False``. """ - __metaclass__ = WorkflowMetaclass slug = None default_steps = () template_name = "horizon/common/_workflow.html" diff --git a/openstack_dashboard/api/network_base.py b/openstack_dashboard/api/network_base.py index a917f9cb61..9c19b8d963 100644 --- a/openstack_dashboard/api/network_base.py +++ b/openstack_dashboard/api/network_base.py @@ -21,7 +21,10 @@ methods defined in this module. import abc +import six + +@six.add_metaclass(abc.ABCMeta) class FloatingIpManager(object): """Abstract class to implement Floating IP methods @@ -37,8 +40,6 @@ class FloatingIpManager(object): * instance_id: Instance ID of an associated with the Floating IP """ - __metaclass__ = abc.ABCMeta - @abc.abstractmethod def list_pools(self): """Fetches a list of all floating IP pools. @@ -129,6 +130,7 @@ class FloatingIpManager(object): pass +@six.add_metaclass(abc.ABCMeta) class SecurityGroupManager(object): """Abstract class to implement Security Group methods @@ -159,8 +161,6 @@ class SecurityGroupManager(object): """ - __metaclass__ = abc.ABCMeta - @abc.abstractmethod def list(self): """Fetches a list all security groups. diff --git a/tox.ini b/tox.ini index f3588b8611..f59b720e40 100644 --- a/tox.ini +++ b/tox.ini @@ -60,6 +60,7 @@ exclude = .venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,build,panel_ # H702 Formatting operation should be outside of localization method call # H803 git commit title should not end with period (disabled on purpose, see bug #1236621) ignore = E127,E128,H701,H702,H803 +select = H236 [hacking] import_exceptions = collections.defaultdict,