Skip to content

Commit d1a5844

Browse files
authored
{Pylint} Fix super-with-arguments (#30367)
1 parent a9c6b39 commit d1a5844

File tree

181 files changed

+467
-496
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+467
-496
lines changed

pylintrc

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ disable=
3030
no-value-for-parameter,
3131
raise-missing-from,
3232
subprocess-run-check,
33-
super-with-arguments,
3433
too-many-arguments,
3534
too-many-positional-arguments,
3635
too-many-function-args,

scripts/dump_command_table.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Exporter(json.JSONEncoder):
1616

1717
def default(self, o):#pylint: disable=method-hidden
1818
try:
19-
return super(Exporter, self).default(o)
19+
return super().default(o)
2020
except TypeError:
2121
return str(o)
2222

scripts/dump_help.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Exporter(json.JSONEncoder):
1616

1717
def default(self, o):#pylint: disable=method-hidden
1818
try:
19-
return super(Exporter, self).default(o)
19+
return super().default(o)
2020
except TypeError:
2121
return str(o)
2222

scripts/generate_command_inventory.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Exporter(json.JSONEncoder):
1414

1515
def default(self, o):#pylint: disable=method-hidden
1616
try:
17-
return super(Exporter, self).default(o)
17+
return super().default(o)
1818
except TypeError:
1919
return str(o)
2020

src/azure-cli-core/azure/cli/core/__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _configure_knack():
5656
class AzCli(CLI):
5757

5858
def __init__(self, **kwargs):
59-
super(AzCli, self).__init__(**kwargs)
59+
super().__init__(**kwargs)
6060

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

202202
def __init__(self, cli_ctx=None):
203-
super(MainCommandsLoader, self).__init__(cli_ctx)
203+
super().__init__(cli_ctx)
204204
self.cmd_to_loader_map = {}
205205
self.loaders = []
206206

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

680-
super(AzCommandsLoader, self).__init__(cli_ctx=cli_ctx,
681-
command_cls=AzCliCommand,
682-
excluded_command_handler_args=EXCLUDED_PARAMS)
680+
super().__init__(cli_ctx=cli_ctx,
681+
command_cls=AzCliCommand,
682+
excluded_command_handler_args=EXCLUDED_PARAMS)
683683
self.suppress_extension = suppress_extension
684684
self.module_kwargs = kwargs
685685
self.command_name = None

src/azure-cli-core/azure/cli/core/_help.py

+13-17
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
# Most of these methods override print methods in CLIHelp
5151
class CLIPrintMixin(CLIHelp):
5252
def _print_header(self, cli_name, help_file):
53-
super(CLIPrintMixin, self)._print_header(cli_name, help_file)
53+
super()._print_header(cli_name, help_file)
5454

5555
links = help_file.links
5656
if links:
@@ -61,7 +61,7 @@ def _print_header(self, cli_name, help_file):
6161

6262
def _print_detailed_help(self, cli_name, help_file):
6363
CLIPrintMixin._print_extensions_msg(help_file)
64-
super(CLIPrintMixin, self)._print_detailed_help(cli_name, help_file)
64+
super()._print_detailed_help(cli_name, help_file)
6565
self._print_az_find_message(help_file.command)
6666

6767
@staticmethod
@@ -131,12 +131,11 @@ def _print_extensions_msg(help_file):
131131
class AzCliHelp(CLIPrintMixin, CLIHelp):
132132

133133
def __init__(self, cli_ctx):
134-
super(AzCliHelp, self).__init__(cli_ctx,
135-
privacy_statement=PRIVACY_STATEMENT,
136-
welcome_message=WELCOME_MESSAGE,
137-
command_help_cls=CliCommandHelpFile,
138-
group_help_cls=CliGroupHelpFile,
139-
help_cls=CliHelpFile)
134+
super().__init__(cli_ctx, privacy_statement=PRIVACY_STATEMENT,
135+
welcome_message=WELCOME_MESSAGE,
136+
command_help_cls=CliCommandHelpFile,
137+
group_help_cls=CliGroupHelpFile,
138+
help_cls=CliHelpFile)
140139
from knack.help import HelpObject
141140

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

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

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

378377
def __init__(self, help_ctx, delimiters, parser):
379-
super(CliCommandHelpFile, self).__init__(help_ctx, delimiters, parser)
378+
super().__init__(help_ctx, delimiters, parser)
380379
self.type = 'command'
381380
self.command_source = getattr(parser, 'command_source', None)
382381

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

411410
def _load_from_data(self, data):
412-
super(CliCommandHelpFile, self)._load_from_data(data)
411+
super()._load_from_data(data)
413412

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

434433
def __init__(self, group_list):
435434

436-
super(ArgumentGroupRegistry, self).__init__(group_list)
435+
super().__init__(group_list)
437436
self.priorities = {
438437
None: 0,
439438
'Resource Id Arguments': 1,
@@ -454,7 +453,7 @@ def __init__(self, **_data):
454453
# Old attributes
455454
_data['name'] = _data.get('name', '')
456455
_data['text'] = _data.get('text', '')
457-
super(HelpExample, self).__init__(_data)
456+
super().__init__(_data)
458457

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

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

486-
def __init__(self, **kwargs):
487-
super(HelpParameter, self).__init__(**kwargs)
488-
489485
def update_from_data(self, data):
490-
super(HelpParameter, self).update_from_data(data)
486+
super().update_from_data(data)
491487
# original help.py value_sources are strings, update command strings to value-source dict
492488
if self.value_sources:
493489
self.value_sources = [str_or_dict if isinstance(str_or_dict, dict) else {"link": {"command": str_or_dict}}

src/azure-cli-core/azure/cli/core/_session.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Session(MutableMapping):
2121
"""
2222

2323
def __init__(self, encoding=None):
24-
super(Session, self).__init__()
24+
super().__init__()
2525
self.filename = None
2626
self.data = {}
2727
self._encoding = encoding if encoding else 'utf-8-sig'

src/azure-cli-core/azure/cli/core/aaz/_arg.py

-3
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,6 @@ def _type_in_help(self):
358358

359359
class AAZCompoundTypeArg(AAZBaseArg):
360360

361-
def __init__(self, **kwargs):
362-
super().__init__(**kwargs)
363-
364361
@abc.abstractmethod
365362
def _build_cmd_action(self):
366363
raise NotImplementedError()

src/azure-cli-core/azure/cli/core/aaz/_field_type.py

-6
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ class AAZSimpleType(AAZBaseType):
2424

2525
_ValueCls = AAZSimpleValue
2626

27-
def __init__(self, *args, **kwargs):
28-
super().__init__(*args, **kwargs)
29-
3027
def process_data(self, data, **kwargs):
3128
if data == None: # noqa: E711, pylint: disable=singleton-comparison
3229
# data can be None or AAZSimpleValue == None
@@ -276,9 +273,6 @@ class AAZBaseDictType(AAZBaseType):
276273

277274
_PatchDataCls = dict
278275

279-
def __init__(self, *args, **kwargs):
280-
super().__init__(*args, **kwargs)
281-
282276
@abc.abstractmethod
283277
def __getitem__(self, key):
284278
raise NotImplementedError()

src/azure-cli-core/azure/cli/core/azlogging.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ class AzCliLogging(CLILogging):
4242
COMMAND_METADATA_LOGGER = 'az_command_data_logger'
4343

4444
def __init__(self, name, cli_ctx=None):
45-
super(AzCliLogging, self).__init__(name, cli_ctx)
45+
super().__init__(name, cli_ctx)
4646
self.command_log_dir = os.path.join(cli_ctx.config.config_dir, 'commands')
4747
self.command_logger_handler = None
4848
self.command_metadata_logger = None
4949
self.cli_ctx.register_event(EVENT_INVOKER_PRE_CMD_TBL_TRUNCATE, AzCliLogging.init_command_file_logging)
5050
self.cli_ctx.register_event(EVENT_CLI_POST_EXECUTE, AzCliLogging.deinit_cmd_metadata_logging)
5151

5252
def configure(self, args):
53-
super(AzCliLogging, self).configure(args)
53+
super().configure(args)
5454
from knack.log import CliLogLevel
5555
if self.log_level == CliLogLevel.DEBUG:
5656
# As azure.core.pipeline.policies.http_logging_policy is a redacted version of

src/azure-cli-core/azure/cli/core/cloud.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
class CloudNotRegisteredException(Exception):
3131
def __init__(self, cloud_name):
32-
super(CloudNotRegisteredException, self).__init__(cloud_name)
32+
super().__init__(cloud_name)
3333
self.cloud_name = cloud_name
3434

3535
def __str__(self):
@@ -38,7 +38,7 @@ def __str__(self):
3838

3939
class CloudAlreadyRegisteredException(Exception):
4040
def __init__(self, cloud_name):
41-
super(CloudAlreadyRegisteredException, self).__init__(cloud_name)
41+
super().__init__(cloud_name)
4242
self.cloud_name = cloud_name
4343

4444
def __str__(self):

src/azure-cli-core/azure/cli/core/commands/__init__.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -255,24 +255,24 @@ def __getattribute__(self, key):
255255
payload = object.__getattribute__(self, '_payload')
256256
return payload.__getattribute__(key)
257257
except AttributeError:
258-
return super(CacheObject, self).__getattribute__(key)
258+
return super().__getattribute__(key)
259259

260260
def __setattr__(self, key, value):
261261
try:
262262
return self._payload.__setattr__(key, value)
263263
except AttributeError:
264-
return super(CacheObject, self).__setattr__(key, value)
264+
return super().__setattr__(key, value)
265265

266266

267267
class AzCliCommand(CLICommand):
268268

269269
def __init__(self, loader, name, handler, description=None, table_transformer=None,
270270
arguments_loader=None, description_loader=None,
271271
formatter_class=None, sensitive_info=None, deprecate_info=None, validator=None, **kwargs):
272-
super(AzCliCommand, self).__init__(loader.cli_ctx, name, handler, description=description,
273-
table_transformer=table_transformer, arguments_loader=arguments_loader,
274-
description_loader=description_loader, formatter_class=formatter_class,
275-
deprecate_info=deprecate_info, validator=validator, **kwargs)
272+
super().__init__(loader.cli_ctx, name, handler, description=description,
273+
table_transformer=table_transformer, arguments_loader=arguments_loader,
274+
description_loader=description_loader, formatter_class=formatter_class,
275+
deprecate_info=deprecate_info, validator=validator, **kwargs)
276276
self.loader = loader
277277
self.command_source = None
278278
self.sensitive_info = sensitive_info
@@ -299,7 +299,7 @@ def _resolve_default_value_from_config_file(self, arg, overrides):
299299

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

304304
self._resolve_default_value_from_local_context(arg, overrides)
305305

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

320320
def load_arguments(self):
321-
super(AzCliCommand, self).load_arguments()
321+
super().load_arguments()
322322
if self.arguments_loader:
323323
cmd_args = self.arguments_loader()
324324
if self.supports_no_wait or self.no_wait_param:
@@ -1089,7 +1089,7 @@ def __call__(self, result):
10891089

10901090
if isinstance(result, poller_classes()):
10911091
# most deployment operations return a poller
1092-
result = super(DeploymentOutputLongRunningOperation, self).__call__(result)
1092+
result = super().__call__(result)
10931093
outputs = None
10941094
try:
10951095
if isinstance(result, str) and result:
@@ -1151,7 +1151,7 @@ class ExtensionCommandSource:
11511151
""" Class for commands contributed by an extension """
11521152

11531153
def __init__(self, overrides_command=False, extension_name=None, preview=False, experimental=False):
1154-
super(ExtensionCommandSource, self).__init__()
1154+
super().__init__()
11551155
# True if the command overrides a CLI command
11561156
self.overrides_command = overrides_command
11571157
self.extension_name = extension_name
@@ -1257,8 +1257,8 @@ def __init__(self, command_loader, group_name, **kwargs):
12571257
"""
12581258
merged_kwargs = self._merge_kwargs(kwargs, base_kwargs=command_loader.module_kwargs)
12591259
operations_tmpl = merged_kwargs.pop('operations_tmpl', None)
1260-
super(AzCommandGroup, self).__init__(command_loader, group_name,
1261-
operations_tmpl, **merged_kwargs)
1260+
super().__init__(command_loader, group_name,
1261+
operations_tmpl, **merged_kwargs)
12621262
self.group_kwargs = merged_kwargs
12631263
if operations_tmpl:
12641264
self.group_kwargs['operations_tmpl'] = operations_tmpl

src/azure-cli-core/azure/cli/core/commands/command_operation.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class CommandOperation(BaseCommandOperation):
9797
def __init__(self, command_loader, op_path, **merged_kwargs):
9898
if not isinstance(op_path, str):
9999
raise TypeError("Operation must be a string. Got '{}'".format(op_path))
100-
super(CommandOperation, self).__init__(command_loader, **merged_kwargs)
100+
super().__init__(command_loader, **merged_kwargs)
101101
self.op_path = op_path
102102

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

155155
self.getter_op_path = getter_op_path
156156
self.setter_op_path = setter_op_path
@@ -334,7 +334,7 @@ class ShowCommandOperation(BaseCommandOperation):
334334
def __init__(self, command_loader, op_path, **merged_kwargs):
335335
if not isinstance(op_path, str):
336336
raise TypeError("operation must be a string. Got '{}'".format(op_path))
337-
super(ShowCommandOperation, self).__init__(command_loader, **merged_kwargs)
337+
super().__init__(command_loader, **merged_kwargs)
338338
self.op_path = op_path
339339

340340
def handler(self, command_args):
@@ -377,7 +377,7 @@ class WaitCommandOperation(BaseCommandOperation):
377377
def __init__(self, command_loader, op_path, **merged_kwargs):
378378
if not isinstance(op_path, str):
379379
raise TypeError("operation must be a string. Got '{}'".format(op_path))
380-
super(WaitCommandOperation, self).__init__(command_loader, **merged_kwargs)
380+
super().__init__(command_loader, **merged_kwargs)
381381
self.op_path = op_path
382382

383383
def handler(self, command_args): # pylint: disable=too-many-statements, too-many-locals

src/azure-cli-core/azure/cli/core/commands/parameters.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ class AzArgumentContext(ArgumentsContext):
335335

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

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

368368
# pylint: disable=arguments-differ
369369
def argument(self, dest, arg_type=None, **kwargs):
@@ -384,7 +384,7 @@ def argument(self, dest, arg_type=None, **kwargs):
384384
min_api=min_api,
385385
max_api=max_api,
386386
operation_group=operation_group):
387-
super(AzArgumentContext, self).argument(dest, **merged_kwargs)
387+
super().argument(dest, **merged_kwargs)
388388
else:
389389
self._ignore_if_not_registered(dest)
390390

@@ -405,7 +405,7 @@ def positional(self, dest, arg_type=None, **kwargs):
405405
min_api=min_api,
406406
max_api=max_api,
407407
operation_group=operation_group):
408-
super(AzArgumentContext, self).positional(dest, **merged_kwargs)
408+
super().positional(dest, **merged_kwargs)
409409
else:
410410
self._ignore_if_not_registered(dest)
411411

@@ -473,7 +473,7 @@ def ignore(self, *args):
473473
return
474474

475475
for arg in args:
476-
super(AzArgumentContext, self).ignore(arg)
476+
super().ignore(arg)
477477

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

0 commit comments

Comments
 (0)