Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{Pylint} Fix super-with-arguments #30367

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ disable=
no-value-for-parameter,
raise-missing-from,
subprocess-run-check,
super-with-arguments,
too-many-arguments,
too-many-positional-arguments,
too-many-function-args,
Expand Down
2 changes: 1 addition & 1 deletion scripts/dump_command_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Exporter(json.JSONEncoder):

def default(self, o):#pylint: disable=method-hidden
try:
return super(Exporter, self).default(o)
return super().default(o)
except TypeError:
return str(o)

Expand Down
2 changes: 1 addition & 1 deletion scripts/dump_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Exporter(json.JSONEncoder):

def default(self, o):#pylint: disable=method-hidden
try:
return super(Exporter, self).default(o)
return super().default(o)
except TypeError:
return str(o)

Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_command_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Exporter(json.JSONEncoder):

def default(self, o):#pylint: disable=method-hidden
try:
return super(Exporter, self).default(o)
return super().default(o)
except TypeError:
return str(o)

Expand Down
10 changes: 5 additions & 5 deletions src/azure-cli-core/azure/cli/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _configure_knack():
class AzCli(CLI):

def __init__(self, **kwargs):
super(AzCli, self).__init__(**kwargs)
super().__init__(**kwargs)

from azure.cli.core.breaking_change import register_upcoming_breaking_change_info
from azure.cli.core.commands import register_cache_arguments
Expand Down Expand Up @@ -200,7 +200,7 @@ class MainCommandsLoader(CLICommandsLoader):
item_ext_format_string = item_format_string + " %s"

def __init__(self, cli_ctx=None):
super(MainCommandsLoader, self).__init__(cli_ctx)
super().__init__(cli_ctx)
self.cmd_to_loader_map = {}
self.loaders = []

Expand Down Expand Up @@ -677,9 +677,9 @@ def __init__(self, cli_ctx=None, command_group_cls=None, argument_context_cls=No
suppress_extension=None, **kwargs):
from azure.cli.core.commands import AzCliCommand, AzCommandGroup, AzArgumentContext

super(AzCommandsLoader, self).__init__(cli_ctx=cli_ctx,
command_cls=AzCliCommand,
excluded_command_handler_args=EXCLUDED_PARAMS)
super().__init__(cli_ctx=cli_ctx,
command_cls=AzCliCommand,
excluded_command_handler_args=EXCLUDED_PARAMS)
self.suppress_extension = suppress_extension
self.module_kwargs = kwargs
self.command_name = None
Expand Down
30 changes: 13 additions & 17 deletions src/azure-cli-core/azure/cli/core/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
# Most of these methods override print methods in CLIHelp
class CLIPrintMixin(CLIHelp):
def _print_header(self, cli_name, help_file):
super(CLIPrintMixin, self)._print_header(cli_name, help_file)
super()._print_header(cli_name, help_file)

links = help_file.links
if links:
Expand All @@ -61,7 +61,7 @@ def _print_header(self, cli_name, help_file):

def _print_detailed_help(self, cli_name, help_file):
CLIPrintMixin._print_extensions_msg(help_file)
super(CLIPrintMixin, self)._print_detailed_help(cli_name, help_file)
super()._print_detailed_help(cli_name, help_file)
self._print_az_find_message(help_file.command)

@staticmethod
Expand Down Expand Up @@ -131,12 +131,11 @@ def _print_extensions_msg(help_file):
class AzCliHelp(CLIPrintMixin, CLIHelp):

def __init__(self, cli_ctx):
super(AzCliHelp, self).__init__(cli_ctx,
privacy_statement=PRIVACY_STATEMENT,
welcome_message=WELCOME_MESSAGE,
command_help_cls=CliCommandHelpFile,
group_help_cls=CliGroupHelpFile,
help_cls=CliHelpFile)
super().__init__(cli_ctx, privacy_statement=PRIVACY_STATEMENT,
welcome_message=WELCOME_MESSAGE,
command_help_cls=CliCommandHelpFile,
group_help_cls=CliGroupHelpFile,
help_cls=CliHelpFile)
from knack.help import HelpObject

# TODO: This workaround is used to avoid a bizarre bug in Python 2.7. It
Expand Down Expand Up @@ -247,7 +246,7 @@ class CliHelpFile(KnackHelpFile):

def __init__(self, help_ctx, delimiters):
# Each help file (for a command or group) has a version denoting the source of its data.
super(CliHelpFile, self).__init__(help_ctx, delimiters)
super().__init__(help_ctx, delimiters)
self.links = []

from knack.deprecation import resolve_deprecate_info, ImplicitDeprecated, Deprecated
Expand Down Expand Up @@ -376,7 +375,7 @@ def load(self, options):
class CliCommandHelpFile(KnackCommandHelpFile, CliHelpFile):

def __init__(self, help_ctx, delimiters, parser):
super(CliCommandHelpFile, self).__init__(help_ctx, delimiters, parser)
super().__init__(help_ctx, delimiters, parser)
self.type = 'command'
self.command_source = getattr(parser, 'command_source', None)

Expand Down Expand Up @@ -409,7 +408,7 @@ def __init__(self, help_ctx, delimiters, parser):
param.__class__ = HelpParameter

def _load_from_data(self, data):
super(CliCommandHelpFile, self)._load_from_data(data)
super()._load_from_data(data)

if isinstance(data, str) or not self.parameters or not data.get('parameters'):
return
Expand All @@ -433,7 +432,7 @@ class ArgumentGroupRegistry(KnackArgumentGroupRegistry): # pylint: disable=too-

def __init__(self, group_list):

super(ArgumentGroupRegistry, self).__init__(group_list)
super().__init__(group_list)
self.priorities = {
None: 0,
'Resource Id Arguments': 1,
Expand All @@ -454,7 +453,7 @@ def __init__(self, **_data):
# Old attributes
_data['name'] = _data.get('name', '')
_data['text'] = _data.get('text', '')
super(HelpExample, self).__init__(_data)
super().__init__(_data)

self.name = _data.get('summary', '') if _data.get('summary', '') else self.name
self.text = _data.get('command', '') if _data.get('command', '') else self.text
Expand Down Expand Up @@ -483,11 +482,8 @@ def command(self, value):

class HelpParameter(KnackHelpParameter): # pylint: disable=too-many-instance-attributes

def __init__(self, **kwargs):
super(HelpParameter, self).__init__(**kwargs)

def update_from_data(self, data):
super(HelpParameter, self).update_from_data(data)
super().update_from_data(data)
# original help.py value_sources are strings, update command strings to value-source dict
if self.value_sources:
self.value_sources = [str_or_dict if isinstance(str_or_dict, dict) else {"link": {"command": str_or_dict}}
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Session(MutableMapping):
"""

def __init__(self, encoding=None):
super(Session, self).__init__()
super().__init__()
self.filename = None
self.data = {}
self._encoding = encoding if encoding else 'utf-8-sig'
Expand Down
3 changes: 0 additions & 3 deletions src/azure-cli-core/azure/cli/core/aaz/_arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,6 @@ def _type_in_help(self):

class AAZCompoundTypeArg(AAZBaseArg):

def __init__(self, **kwargs):
super().__init__(**kwargs)

@abc.abstractmethod
def _build_cmd_action(self):
raise NotImplementedError()
Expand Down
6 changes: 0 additions & 6 deletions src/azure-cli-core/azure/cli/core/aaz/_field_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ class AAZSimpleType(AAZBaseType):

_ValueCls = AAZSimpleValue

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def process_data(self, data, **kwargs):
if data == None: # noqa: E711, pylint: disable=singleton-comparison
# data can be None or AAZSimpleValue == None
Expand Down Expand Up @@ -276,9 +273,6 @@ class AAZBaseDictType(AAZBaseType):

_PatchDataCls = dict

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

@abc.abstractmethod
def __getitem__(self, key):
raise NotImplementedError()
Expand Down
4 changes: 2 additions & 2 deletions src/azure-cli-core/azure/cli/core/azlogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ class AzCliLogging(CLILogging):
COMMAND_METADATA_LOGGER = 'az_command_data_logger'

def __init__(self, name, cli_ctx=None):
super(AzCliLogging, self).__init__(name, cli_ctx)
super().__init__(name, cli_ctx)
self.command_log_dir = os.path.join(cli_ctx.config.config_dir, 'commands')
self.command_logger_handler = None
self.command_metadata_logger = None
self.cli_ctx.register_event(EVENT_INVOKER_PRE_CMD_TBL_TRUNCATE, AzCliLogging.init_command_file_logging)
self.cli_ctx.register_event(EVENT_CLI_POST_EXECUTE, AzCliLogging.deinit_cmd_metadata_logging)

def configure(self, args):
super(AzCliLogging, self).configure(args)
super().configure(args)
from knack.log import CliLogLevel
if self.log_level == CliLogLevel.DEBUG:
# As azure.core.pipeline.policies.http_logging_policy is a redacted version of
Expand Down
4 changes: 2 additions & 2 deletions src/azure-cli-core/azure/cli/core/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

class CloudNotRegisteredException(Exception):
def __init__(self, cloud_name):
super(CloudNotRegisteredException, self).__init__(cloud_name)
super().__init__(cloud_name)
self.cloud_name = cloud_name

def __str__(self):
Expand All @@ -38,7 +38,7 @@ def __str__(self):

class CloudAlreadyRegisteredException(Exception):
def __init__(self, cloud_name):
super(CloudAlreadyRegisteredException, self).__init__(cloud_name)
super().__init__(cloud_name)
self.cloud_name = cloud_name

def __str__(self):
Expand Down
24 changes: 12 additions & 12 deletions src/azure-cli-core/azure/cli/core/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,24 +255,24 @@ def __getattribute__(self, key):
payload = object.__getattribute__(self, '_payload')
return payload.__getattribute__(key)
except AttributeError:
return super(CacheObject, self).__getattribute__(key)
return super().__getattribute__(key)

def __setattr__(self, key, value):
try:
return self._payload.__setattr__(key, value)
except AttributeError:
return super(CacheObject, self).__setattr__(key, value)
return super().__setattr__(key, value)


class AzCliCommand(CLICommand):

def __init__(self, loader, name, handler, description=None, table_transformer=None,
arguments_loader=None, description_loader=None,
formatter_class=None, sensitive_info=None, deprecate_info=None, validator=None, **kwargs):
super(AzCliCommand, self).__init__(loader.cli_ctx, name, handler, description=description,
table_transformer=table_transformer, arguments_loader=arguments_loader,
description_loader=description_loader, formatter_class=formatter_class,
deprecate_info=deprecate_info, validator=validator, **kwargs)
super().__init__(loader.cli_ctx, name, handler, description=description,
table_transformer=table_transformer, arguments_loader=arguments_loader,
description_loader=description_loader, formatter_class=formatter_class,
deprecate_info=deprecate_info, validator=validator, **kwargs)
self.loader = loader
self.command_source = None
self.sensitive_info = sensitive_info
Expand All @@ -299,7 +299,7 @@ def _resolve_default_value_from_config_file(self, arg, overrides):

# same blunt mechanism like we handled id-parts, for create command, no name default
if not (self.name.split()[-1] == 'create' and overrides.settings.get('metavar', None) == 'NAME'):
super(AzCliCommand, self)._resolve_default_value_from_config_file(arg, overrides)
super()._resolve_default_value_from_config_file(arg, overrides)

self._resolve_default_value_from_local_context(arg, overrides)

Expand All @@ -318,7 +318,7 @@ def _resolve_default_value_from_local_context(self, arg, overrides):
overrides.settings['default_value_source'] = 'Local Context'

def load_arguments(self):
super(AzCliCommand, self).load_arguments()
super().load_arguments()
if self.arguments_loader:
cmd_args = self.arguments_loader()
if self.supports_no_wait or self.no_wait_param:
Expand Down Expand Up @@ -1089,7 +1089,7 @@ def __call__(self, result):

if isinstance(result, poller_classes()):
# most deployment operations return a poller
result = super(DeploymentOutputLongRunningOperation, self).__call__(result)
result = super().__call__(result)
outputs = None
try:
if isinstance(result, str) and result:
Expand Down Expand Up @@ -1151,7 +1151,7 @@ class ExtensionCommandSource:
""" Class for commands contributed by an extension """

def __init__(self, overrides_command=False, extension_name=None, preview=False, experimental=False):
super(ExtensionCommandSource, self).__init__()
super().__init__()
# True if the command overrides a CLI command
self.overrides_command = overrides_command
self.extension_name = extension_name
Expand Down Expand Up @@ -1257,8 +1257,8 @@ def __init__(self, command_loader, group_name, **kwargs):
"""
merged_kwargs = self._merge_kwargs(kwargs, base_kwargs=command_loader.module_kwargs)
operations_tmpl = merged_kwargs.pop('operations_tmpl', None)
super(AzCommandGroup, self).__init__(command_loader, group_name,
operations_tmpl, **merged_kwargs)
super().__init__(command_loader, group_name,
operations_tmpl, **merged_kwargs)
self.group_kwargs = merged_kwargs
if operations_tmpl:
self.group_kwargs['operations_tmpl'] = operations_tmpl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class CommandOperation(BaseCommandOperation):
def __init__(self, command_loader, op_path, **merged_kwargs):
if not isinstance(op_path, str):
raise TypeError("Operation must be a string. Got '{}'".format(op_path))
super(CommandOperation, self).__init__(command_loader, **merged_kwargs)
super().__init__(command_loader, **merged_kwargs)
self.op_path = op_path

def handler(self, command_args):
Expand Down Expand Up @@ -151,7 +151,7 @@ def __init__(self, command_loader, getter_op_path, setter_op_path, setter_arg_na
raise TypeError("Setter operation must be a string. Got '{}'".format(setter_op_path))
if custom_function_op_path and not isinstance(custom_function_op_path, str):
raise TypeError("Custom function operation must be a string. Got '{}'".format(custom_function_op_path))
super(GenericUpdateCommandOperation, self).__init__(command_loader, **merged_kwargs)
super().__init__(command_loader, **merged_kwargs)

self.getter_op_path = getter_op_path
self.setter_op_path = setter_op_path
Expand Down Expand Up @@ -335,7 +335,7 @@ class ShowCommandOperation(BaseCommandOperation):
def __init__(self, command_loader, op_path, **merged_kwargs):
if not isinstance(op_path, str):
raise TypeError("operation must be a string. Got '{}'".format(op_path))
super(ShowCommandOperation, self).__init__(command_loader, **merged_kwargs)
super().__init__(command_loader, **merged_kwargs)
self.op_path = op_path

def handler(self, command_args):
Expand Down Expand Up @@ -378,7 +378,7 @@ class WaitCommandOperation(BaseCommandOperation):
def __init__(self, command_loader, op_path, **merged_kwargs):
if not isinstance(op_path, str):
raise TypeError("operation must be a string. Got '{}'".format(op_path))
super(WaitCommandOperation, self).__init__(command_loader, **merged_kwargs)
super().__init__(command_loader, **merged_kwargs)
self.op_path = op_path

def handler(self, command_args): # pylint: disable=too-many-statements, too-many-locals
Expand Down
10 changes: 5 additions & 5 deletions src/azure-cli-core/azure/cli/core/commands/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ class AzArgumentContext(ArgumentsContext):

def __init__(self, command_loader, scope, **kwargs):
from azure.cli.core.commands import _merge_kwargs as merge_kwargs
super(AzArgumentContext, self).__init__(command_loader, scope)
super().__init__(command_loader, scope)
self.scope = scope # this is called "command" in knack, but that is not an accurate name
self.group_kwargs = merge_kwargs(kwargs, command_loader.module_kwargs, CLI_PARAM_KWARGS)

Expand Down Expand Up @@ -363,7 +363,7 @@ def _ignore_if_not_registered(self, dest):
arg_registry = self.command_loader.argument_registry
match = arg_registry.arguments[scope].get(dest, {})
if not match:
super(AzArgumentContext, self).argument(dest, arg_type=ignore_type)
super().argument(dest, arg_type=ignore_type)

# pylint: disable=arguments-differ
def argument(self, dest, arg_type=None, **kwargs):
Expand All @@ -384,7 +384,7 @@ def argument(self, dest, arg_type=None, **kwargs):
min_api=min_api,
max_api=max_api,
operation_group=operation_group):
super(AzArgumentContext, self).argument(dest, **merged_kwargs)
super().argument(dest, **merged_kwargs)
else:
self._ignore_if_not_registered(dest)

Expand All @@ -405,7 +405,7 @@ def positional(self, dest, arg_type=None, **kwargs):
min_api=min_api,
max_api=max_api,
operation_group=operation_group):
super(AzArgumentContext, self).positional(dest, **merged_kwargs)
super().positional(dest, **merged_kwargs)
else:
self._ignore_if_not_registered(dest)

Expand Down Expand Up @@ -473,7 +473,7 @@ def ignore(self, *args):
return

for arg in args:
super(AzArgumentContext, self).ignore(arg)
super().ignore(arg)

def extra(self, dest, arg_type=None, **kwargs):

Expand Down
Loading