From 4dd8e3d407a4f388431efdafb07015ab4c814207 Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Sun, 2 Dec 2018 06:15:29 +0900 Subject: [PATCH] pylint: fix bad-mcs-classmethod-argument warning Change-Id: Idfa421774ac23f673007fe7a7381c5199ccda5e0 --- .pylintrc | 1 - horizon/forms/fields.py | 6 +++--- horizon/tables/actions.py | 4 ++-- horizon/tables/base.py | 4 ++-- horizon/workflows/base.py | 29 ++++++++++++++--------------- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/.pylintrc b/.pylintrc index 5c0fe878fe..165d1e5747 100644 --- a/.pylintrc +++ b/.pylintrc @@ -43,7 +43,6 @@ disable= anomalous-backslash-in-string, bad-builtin, bad-continuation, - bad-mcs-classmethod-argument, deprecated-lambda, expression-not-assigned, global-statement, diff --git a/horizon/forms/fields.py b/horizon/forms/fields.py index 334d86f288..0c7135db9f 100644 --- a/horizon/forms/fields.py +++ b/horizon/forms/fields.py @@ -624,7 +624,7 @@ class ExternalUploadMeta(forms.DeclarativeFieldsMetaclass): process form clean() phase as usual. Actual file upload happens entirely on client-side. """ - def __new__(mcs, name, bases, attrs): + def __new__(cls, name, bases, attrs): def get_double_name(name): suffix = '__hidden' slen = len(suffix) @@ -649,5 +649,5 @@ class ExternalUploadMeta(forms.DeclarativeFieldsMetaclass): new_attrs[new_attr_name] = hidden_field meth_name = 'clean_' + new_attr_name new_attrs[meth_name] = make_clean_method(new_attr_name) - return super(ExternalUploadMeta, mcs).__new__( - mcs, name, bases, new_attrs) + return super(ExternalUploadMeta, cls).__new__( + cls, name, bases, new_attrs) diff --git a/horizon/tables/actions.py b/horizon/tables/actions.py index 30126bbf74..957810a12e 100644 --- a/horizon/tables/actions.py +++ b/horizon/tables/actions.py @@ -51,7 +51,7 @@ class BaseActionMetaClass(type): parameters for the initializer of the object. The object is then initialized clean way. Similar principle is used in DataTableMetaclass. """ - def __new__(mcs, name, bases, attrs): + def __new__(cls, name, bases, attrs): # Options of action are set as class attributes, loading them. options = {} if attrs: @@ -74,7 +74,7 @@ class BaseActionMetaClass(type): # instantiating of the specific Action. attrs['base_options'] = options - return type.__new__(mcs, name, bases, attrs) + return type.__new__(cls, name, bases, attrs) def __call__(cls, *args, **kwargs): cls.base_options.update(kwargs) diff --git a/horizon/tables/base.py b/horizon/tables/base.py index daf64019e4..82b74138cb 100644 --- a/horizon/tables/base.py +++ b/horizon/tables/base.py @@ -1171,7 +1171,7 @@ class DataTableOptions(object): class DataTableMetaclass(type): """Metaclass to add options to DataTable class and collect columns.""" - def __new__(mcs, name, bases, attrs): + def __new__(cls, name, bases, attrs): # Process options from Meta class_name = name dt_attrs = {} @@ -1243,7 +1243,7 @@ class DataTableMetaclass(type): opts._filter_action = actions_dict[opts._filter_action.name] # Create our new class! - return type.__new__(mcs, name, bases, dt_attrs) + return type.__new__(cls, name, bases, dt_attrs) @six.python_2_unicode_compatible diff --git a/horizon/workflows/base.py b/horizon/workflows/base.py index ae39f5efa4..3334d29f93 100644 --- a/horizon/workflows/base.py +++ b/horizon/workflows/base.py @@ -61,22 +61,21 @@ class WorkflowContext(dict): class ActionMetaclass(forms.forms.DeclarativeFieldsMetaclass): - def __new__(mcs, name, bases, attrs): + def __new__(cls, name, bases, attrs): # Pop Meta for later processing opts = attrs.pop("Meta", None) # Create our new class - cls = super(ActionMetaclass, mcs).__new__(mcs, name, bases, attrs) + cls_ = super(ActionMetaclass, cls).__new__(cls, name, bases, attrs) # Process options from Meta - cls.name = getattr(opts, "name", name) - cls.slug = getattr(opts, "slug", slugify(name)) - cls.permissions = getattr(opts, "permissions", ()) - cls.policy_rules = getattr(opts, "policy_rules", ()) - cls.progress_message = getattr(opts, - "progress_message", - _("Processing...")) - cls.help_text = getattr(opts, "help_text", "") - cls.help_text_template = getattr(opts, "help_text_template", None) - return cls + cls_.name = getattr(opts, "name", name) + cls_.slug = getattr(opts, "slug", slugify(name)) + cls_.permissions = getattr(opts, "permissions", ()) + cls_.policy_rules = getattr(opts, "policy_rules", ()) + cls_.progress_message = getattr(opts, "progress_message", + _("Processing...")) + cls_.help_text = getattr(opts, "help_text", "") + cls_.help_text_template = getattr(opts, "help_text_template", None) + return cls_ @six.python_2_unicode_compatible @@ -482,10 +481,10 @@ class Step(object): class WorkflowMetaclass(type): - def __new__(mcs, name, bases, attrs): - super(WorkflowMetaclass, mcs).__new__(mcs, name, bases, attrs) + def __new__(cls, name, bases, attrs): + super(WorkflowMetaclass, cls).__new__(cls, name, bases, attrs) attrs["_cls_registry"] = [] - return type.__new__(mcs, name, bases, attrs) + return type.__new__(cls, name, bases, attrs) class UpdateMembersStep(Step):