From fc328e591d64a2ba2ebf6c46b3af39d7885006e7 Mon Sep 17 00:00:00 2001 From: jiasli <4003950+jiasli@users.noreply.github.com> Date: Thu, 14 Nov 2024 11:52:15 +0800 Subject: [PATCH] arguments-renamed --- pylintrc | 1 - .../azure/cli/core/commands/__init__.py | 8 +++--- .../azure/cli/core/commands/parameters.py | 26 +++++++++---------- .../azure/cli/command_modules/ams/_utils.py | 22 ++++++++-------- 4 files changed, 28 insertions(+), 29 deletions(-) diff --git a/pylintrc b/pylintrc index bbf7f0544f9..e03bf98de05 100644 --- a/pylintrc +++ b/pylintrc @@ -40,7 +40,6 @@ disable= consider-using-f-string, unspecified-encoding, use-maxsplit-arg, - arguments-renamed, consider-using-in, use-dict-literal, consider-using-dict-items, diff --git a/src/azure-cli-core/azure/cli/core/commands/__init__.py b/src/azure-cli-core/azure/cli/core/commands/__init__.py index f17e7862bba..e9b4d08b2cf 100644 --- a/src/azure-cli-core/azure/cli/core/commands/__init__.py +++ b/src/azure-cli-core/azure/cli/core/commands/__init__.py @@ -1291,13 +1291,13 @@ def _flatten_kwargs(self, kwargs, default_source_name): return merged_kwargs # pylint: disable=arguments-differ - def command(self, name, method_name=None, **kwargs): + def command(self, name, handler_name=None, **kwargs): """ Register a CLI command. :param name: Name of the command as it will be called on the command line :type name: str - :param method_name: Name of the method the command maps to - :type method_name: str + :param handler_name: Name of the method the command maps to + :type handler_name: str :param kwargs: Keyword arguments. Supported keyword arguments include: - client_factory: Callable which returns a client needed to access the underlying command method. (function) - confirmation: Prompt prior to the action being executed. This is useful if the action @@ -1314,7 +1314,7 @@ def command(self, name, method_name=None, **kwargs): - max_api: Maximum API version required for commands within the group (string) :rtype: None """ - return self._command(name, method_name=method_name, **kwargs) + return self._command(name, method_name=handler_name, **kwargs) def custom_command(self, name, method_name=None, **kwargs): """ diff --git a/src/azure-cli-core/azure/cli/core/commands/parameters.py b/src/azure-cli-core/azure/cli/core/commands/parameters.py index 9ddc09ed34b..75243578ded 100644 --- a/src/azure-cli-core/azure/cli/core/commands/parameters.py +++ b/src/azure-cli-core/azure/cli/core/commands/parameters.py @@ -366,7 +366,7 @@ def _ignore_if_not_registered(self, dest): super(AzArgumentContext, self).argument(dest, arg_type=ignore_type) # pylint: disable=arguments-differ - def argument(self, dest, arg_type=None, **kwargs): + def argument(self, argument_dest, arg_type=None, **kwargs): self._check_stale() if not self._applicable(): return @@ -384,11 +384,11 @@ 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(AzArgumentContext, self).argument(argument_dest, **merged_kwargs) else: - self._ignore_if_not_registered(dest) + self._ignore_if_not_registered(argument_dest) - def positional(self, dest, arg_type=None, **kwargs): + def positional(self, argument_dest, arg_type=None, **kwargs): self._check_stale() if not self._applicable(): return @@ -405,9 +405,9 @@ 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(AzArgumentContext, self).positional(argument_dest, **merged_kwargs) else: - self._ignore_if_not_registered(dest) + self._ignore_if_not_registered(argument_dest) def expand(self, dest, model_type, group_name=None, patches=None): # TODO: @@ -475,7 +475,7 @@ def ignore(self, *args): for arg in args: super(AzArgumentContext, self).ignore(arg) - def extra(self, dest, arg_type=None, **kwargs): + def extra(self, argument_dest, arg_type=None, **kwargs): merged_kwargs = self._flatten_kwargs(kwargs, arg_type) resource_type = merged_kwargs.get('resource_type', None) @@ -487,8 +487,8 @@ def extra(self, dest, arg_type=None, **kwargs): max_api=max_api, operation_group=operation_group): # Restore when knack #132 is fixed - # merged_kwargs.pop('dest', None) - # super(AzArgumentContext, self).extra(dest, **merged_kwargs) + # merged_kwargs.pop('argument_dest', None) + # super(AzArgumentContext, self).extra(argument_dest, **merged_kwargs) from knack.arguments import CLICommandArgument self._check_stale() if not self._applicable(): @@ -497,11 +497,11 @@ def extra(self, dest, arg_type=None, **kwargs): if self.command_scope in self.command_loader.command_group_table: raise ValueError("command authoring error: extra argument '{}' cannot be registered to a group-level " "scope '{}'. It must be registered to a specific command.".format( - dest, self.command_scope)) + argument_dest, self.command_scope)) - deprecate_action = self._handle_deprecations(dest, **merged_kwargs) + deprecate_action = self._handle_deprecations(argument_dest, **merged_kwargs) if deprecate_action: merged_kwargs['action'] = deprecate_action merged_kwargs.pop('dest', None) - self.command_loader.extra_argument_registry[self.command_scope][dest] = CLICommandArgument( - dest, **merged_kwargs) + self.command_loader.extra_argument_registry[self.command_scope][argument_dest] = CLICommandArgument( + argument_dest, **merged_kwargs) diff --git a/src/azure-cli/azure/cli/command_modules/ams/_utils.py b/src/azure-cli/azure/cli/command_modules/ams/_utils.py index 8661b613654..61cc8f63de7 100644 --- a/src/azure-cli/azure/cli/command_modules/ams/_utils.py +++ b/src/azure-cli/azure/cli/command_modules/ams/_utils.py @@ -60,22 +60,22 @@ class JsonBytearrayEncoder(json.JSONEncoder): DATE_FORMAT = "%Y-%m-%d" TIME_FORMAT = "%H:%M:%S" - def default(self, obj): # pylint: disable=E0202,W0221 - if isinstance(obj, datetime): - return obj.strftime("%s %s" % (self.DATE_FORMAT, self.TIME_FORMAT)) + def default(self, o): # pylint: disable=E0202,W0221 + if isinstance(o, datetime): + return o.strftime("%s %s" % (self.DATE_FORMAT, self.TIME_FORMAT)) - if isinstance(obj, bytearray): - return bytes(obj).decode('utf-8', 'ignore') + if isinstance(o, bytearray): + return bytes(o).decode('utf-8', 'ignore') try: - return obj.toJSON() + return o.toJSON() except Exception: # pylint: disable=W0703 - obj = vars(obj) - obj.pop('additional_properties', None) - keys = list(obj.keys()) + o = vars(o) + o.pop('additional_properties', None) + keys = list(o.keys()) for key in keys: - obj[snake_to_camel_case(key)] = obj.pop(key) - return obj + o[snake_to_camel_case(key)] = o.pop(key) + return o def create_ip_range(resource_name, ip):