Skip to content
Merged
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 @@ -32,7 +32,6 @@ disable=
too-many-arguments,
too-many-function-args,
too-many-lines,
unnecessary-comprehension,
use-a-generator,
using-constant-test,
wrong-import-order,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def arguments_loader(self):
'force_string', action='store_true', arg_group=group_name,
help="When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON."
)
return [(k, v) for k, v in arguments.items()]
return list(arguments.items())

def load_setter_op_arguments(self):
op = self.get_op_handler(self.setter_op_path)
Expand Down Expand Up @@ -365,7 +365,7 @@ def handler(self, command_args):
def arguments_loader(self):
""" Callback function of CLICommand arguments_loader """
cmd_args = self.load_getter_op_arguments(self.op_path)
return [(k, v) for k, v in cmd_args.items()]
return list(cmd_args.items())

def description_loader(self):
""" Callback function of CLICommand description_loader """
Expand Down Expand Up @@ -503,7 +503,7 @@ def arguments_loader(self):
"provisioningState!='InProgress', "
"instanceView.statuses[?code=='PowerState/running']"
)
return [(k, v) for k, v in cmd_args.items()]
return list(cmd_args.items())

def description_loader(self):
""" Callback function of CLICommand description_loader """
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/extension/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def get_extensions(ext_type=None):
elif not isinstance(ext_type, list):
ext_type = [ext_type]
for t in ext_type:
extensions.extend([ext for ext in t.get_all()])
extensions.extend(t.get_all())
Copy link
Member Author

@jiasli jiasli May 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t.get_all() is already a list.

Even if it is not, extend accepts any iterable, so no need to convert t.get_all() to a list first.

return extensions


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def create_cluster(cmd, client, cluster_name, resource_group_name, cluster_type,

if component_version:
# See validator
component_version = {c: v for c, v in [version.split('=') for version in component_version]}
component_version = dict([version.split('=') for version in component_version])
Copy link
Member Author

@jiasli jiasli May 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constructor of dict takes iterables of 2-element iterables.

https://docs.python.org/3/library/stdtypes.html#dict


# Validate whether HTTP credentials were provided
if 'gateway' in cluster_configurations:
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/azure/cli/command_modules/iot/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ def _build_identity(system=False, identities=None):
return ArmIdentity(type=identity_type)
if system:
identity_type = IdentityType.system_assigned.value
user_identities = [i for i in identities] if identities else None
user_identities = list(identities) if identities else None
if user_identities and identity_type == IdentityType.system_assigned.value:
identity_type = IdentityType.system_assigned_user_assigned.value
elif user_identities:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def _multi_transformers(output, **command_args):
def keep_max_results(output, **command_args):
maxresults = command_args.get('maxresults', None)
if maxresults:
return [_ for _ in output][:maxresults]
return list(output)[:maxresults]
return output


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ def _object_id_args_helper(cli_ctx, object_id, spn, upn):

def _permissions_distinct(permissions):
if permissions:
return [_ for _ in {p for p in permissions}]
return list(set(permissions))
return permissions


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def load_arguments(self, _):
nargs='+',
help='Space-separated list of transforms to apply when matching.')
if WebApplicationFirewallMatchVariable:
waf_custom_rule_match_variables = [x for x in WebApplicationFirewallMatchVariable]
waf_custom_rule_match_variables = list(WebApplicationFirewallMatchVariable)
help_string = 'Space-separated list of variables to use when matching. ' \
'Variable values: {}'.format(', '.join(waf_custom_rule_match_variables))
c.argument('match_variables', nargs='+', help=help_string, validator=validate_match_variables)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ def process_blob_upload_batch_parameters(cmd, namespace):

# 3. collect the files to be uploaded
namespace.source = os.path.realpath(namespace.source)
namespace.source_files = [c for c in glob_files_locally(namespace.source, namespace.pattern)]
namespace.source_files = list(glob_files_locally(namespace.source, namespace.pattern))

# 4. determine blob type
if namespace.blob_type is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ def process_blob_upload_batch_parameters(cmd, namespace):

# 3. collect the files to be uploaded
namespace.source = os.path.realpath(namespace.source)
namespace.source_files = [c for c in glob_files_locally(namespace.source, namespace.pattern)]
namespace.source_files = list(glob_files_locally(namespace.source, namespace.pattern))

# 4. determine blob type
if namespace.blob_type is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def storage_file_upload_batch(cmd, client, destination, source, destination_path

from azure.cli.command_modules.storage.util import glob_files_locally, normalize_blob_file_path

source_files = [c for c in glob_files_locally(source, pattern)]
source_files = list(glob_files_locally(source, pattern))
logger = get_logger(__name__)
settings_class = cmd.get_models('file.models#ContentSettings')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def storage_file_upload_batch(cmd, client, destination, source, destination_path

from azure.cli.command_modules.storage.util import glob_files_locally, normalize_blob_file_path

source_files = [c for c in glob_files_locally(source, pattern)]
source_files = list(glob_files_locally(source, pattern))
logger = get_logger(__name__)
settings_class = cmd.get_models('file.models#ContentSettings')

Expand Down
4 changes: 2 additions & 2 deletions src/azure-cli/azure/cli/command_modules/vm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3428,7 +3428,7 @@ def create_image_version(cmd, resource_group_name, gallery_name, gallery_image_n
if data_snapshot_luns and len(data_snapshots) != len(data_snapshot_luns):
raise CLIError('usage error: Length of --data-snapshots and --data-snapshot-luns should be equal.')
if not data_snapshot_luns:
data_snapshot_luns = [i for i in range(len(data_snapshots))]
data_snapshot_luns = list(range(len(data_snapshots)))
data_disk_images = []
for i, s in enumerate(data_snapshots):
data_disk_images.append(GalleryDataDiskImage(source=GalleryArtifactVersionSource(id=s),
Expand Down Expand Up @@ -3456,7 +3456,7 @@ def create_image_version(cmd, resource_group_name, gallery_name, gallery_image_n
# Generate LUNs
if data_vhds_luns is None:
# 0, 1, 2, ...
data_vhds_luns = [i for i in range(len(data_vhds_uris))]
data_vhds_luns = list(range(len(data_vhds_uris)))
# Check length
len_data_vhds_uris = len(data_vhds_uris)
len_data_vhds_luns = len(data_vhds_luns)
Expand Down