Merge "pylint: fix bad-mcs-classmethod-argument warning"

This commit is contained in:
Zuul 2019-01-16 14:05:41 +00:00 committed by Gerrit Code Review
commit e325c56d03
5 changed files with 21 additions and 23 deletions

View File

@ -43,7 +43,6 @@ disable=
anomalous-backslash-in-string, anomalous-backslash-in-string,
bad-builtin, bad-builtin,
bad-continuation, bad-continuation,
bad-mcs-classmethod-argument,
deprecated-lambda, deprecated-lambda,
expression-not-assigned, expression-not-assigned,
global-statement, global-statement,

View File

@ -624,7 +624,7 @@ class ExternalUploadMeta(forms.DeclarativeFieldsMetaclass):
process form clean() phase as usual. Actual file upload happens entirely process form clean() phase as usual. Actual file upload happens entirely
on client-side. on client-side.
""" """
def __new__(mcs, name, bases, attrs): def __new__(cls, name, bases, attrs):
def get_double_name(name): def get_double_name(name):
suffix = '__hidden' suffix = '__hidden'
slen = len(suffix) slen = len(suffix)
@ -649,5 +649,5 @@ class ExternalUploadMeta(forms.DeclarativeFieldsMetaclass):
new_attrs[new_attr_name] = hidden_field new_attrs[new_attr_name] = hidden_field
meth_name = 'clean_' + new_attr_name meth_name = 'clean_' + new_attr_name
new_attrs[meth_name] = make_clean_method(new_attr_name) new_attrs[meth_name] = make_clean_method(new_attr_name)
return super(ExternalUploadMeta, mcs).__new__( return super(ExternalUploadMeta, cls).__new__(
mcs, name, bases, new_attrs) cls, name, bases, new_attrs)

View File

@ -51,7 +51,7 @@ class BaseActionMetaClass(type):
parameters for the initializer of the object. The object is then parameters for the initializer of the object. The object is then
initialized clean way. Similar principle is used in DataTableMetaclass. 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 of action are set as class attributes, loading them.
options = {} options = {}
if attrs: if attrs:
@ -74,7 +74,7 @@ class BaseActionMetaClass(type):
# instantiating of the specific Action. # instantiating of the specific Action.
attrs['base_options'] = options attrs['base_options'] = options
return type.__new__(mcs, name, bases, attrs) return type.__new__(cls, name, bases, attrs)
def __call__(cls, *args, **kwargs): def __call__(cls, *args, **kwargs):
cls.base_options.update(kwargs) cls.base_options.update(kwargs)

View File

@ -1171,7 +1171,7 @@ class DataTableOptions(object):
class DataTableMetaclass(type): class DataTableMetaclass(type):
"""Metaclass to add options to DataTable class and collect columns.""" """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 # Process options from Meta
class_name = name class_name = name
dt_attrs = {} dt_attrs = {}
@ -1243,7 +1243,7 @@ class DataTableMetaclass(type):
opts._filter_action = actions_dict[opts._filter_action.name] opts._filter_action = actions_dict[opts._filter_action.name]
# Create our new class! # 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 @six.python_2_unicode_compatible

View File

@ -61,22 +61,21 @@ class WorkflowContext(dict):
class ActionMetaclass(forms.forms.DeclarativeFieldsMetaclass): class ActionMetaclass(forms.forms.DeclarativeFieldsMetaclass):
def __new__(mcs, name, bases, attrs): def __new__(cls, name, bases, attrs):
# Pop Meta for later processing # Pop Meta for later processing
opts = attrs.pop("Meta", None) opts = attrs.pop("Meta", None)
# Create our new class # 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 # Process options from Meta
cls.name = getattr(opts, "name", name) cls_.name = getattr(opts, "name", name)
cls.slug = getattr(opts, "slug", slugify(name)) cls_.slug = getattr(opts, "slug", slugify(name))
cls.permissions = getattr(opts, "permissions", ()) cls_.permissions = getattr(opts, "permissions", ())
cls.policy_rules = getattr(opts, "policy_rules", ()) cls_.policy_rules = getattr(opts, "policy_rules", ())
cls.progress_message = getattr(opts, cls_.progress_message = getattr(opts, "progress_message",
"progress_message", _("Processing..."))
_("Processing...")) cls_.help_text = getattr(opts, "help_text", "")
cls.help_text = getattr(opts, "help_text", "") cls_.help_text_template = getattr(opts, "help_text_template", None)
cls.help_text_template = getattr(opts, "help_text_template", None) return cls_
return cls
@six.python_2_unicode_compatible @six.python_2_unicode_compatible
@ -482,10 +481,10 @@ class Step(object):
class WorkflowMetaclass(type): class WorkflowMetaclass(type):
def __new__(mcs, name, bases, attrs): def __new__(cls, name, bases, attrs):
super(WorkflowMetaclass, mcs).__new__(mcs, name, bases, attrs) super(WorkflowMetaclass, cls).__new__(cls, name, bases, attrs)
attrs["_cls_registry"] = [] attrs["_cls_registry"] = []
return type.__new__(mcs, name, bases, attrs) return type.__new__(cls, name, bases, attrs)
class UpdateMembersStep(Step): class UpdateMembersStep(Step):