Skip to content

Commit 0a7645e

Browse files
committed
{Misc} Replace dict with a literal. set([]) with set()
This is more Pythonic. Signed-off-by: Mads Jensen <[email protected]>
1 parent 8de4e13 commit 0a7645e

File tree

24 files changed

+77
-77
lines changed

24 files changed

+77
-77
lines changed

scripts/temp_help/help_convert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def _get_new_yaml_dict(help_dict):
189189
if "parameters" in help_dict:
190190
parameters = []
191191
for param in help_dict["parameters"]:
192-
new_param = dict()
192+
new_param = {}
193193
if "name" in param:
194194
options = param["name"].split()
195195
new_param["name"] = max(options, key=lambda x: len(x))
@@ -205,7 +205,7 @@ def _get_new_yaml_dict(help_dict):
205205
if "examples" in help_dict:
206206
elem_examples = []
207207
for ex in help_dict["examples"]:
208-
new_ex = dict()
208+
new_ex = {}
209209
if "name" in ex:
210210
new_ex["summary"] = ex["name"]
211211
if "text" in ex:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ def get_parameter_kwargs(args):
462462
:type: dict
463463
"""
464464

465-
parameter_kwargs = dict()
465+
parameter_kwargs = {}
466466
for index, parameter in enumerate(args):
467467
if parameter.startswith('-'):
468468

@@ -501,7 +501,7 @@ def get_user_param_value(target_param):
501501
:return: The replaced value for target_param
502502
:type: str
503503
"""
504-
standard_source_kwargs = dict()
504+
standard_source_kwargs = {}
505505

506506
for param, val in source_kwargs.items():
507507
if param in param_mappings:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def expand(self, dest, model_type, group_name=None, patches=None):
420420
return
421421

422422
if not patches:
423-
patches = dict()
423+
patches = {}
424424

425425
# fetch the documentation for model parameters first. for models, which are the classes
426426
# derive from msrest.serialization.Model and used in the SDK API to carry parameters, the

src/azure-cli-telemetry/azure/cli/telemetry/components/telemetry_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CliTelemetryClient:
2323
def __init__(self, batch=100, sender=None):
2424
from azure.cli.telemetry.components.telemetry_logging import get_logger
2525

26-
self._clients = dict()
26+
self._clients = {}
2727
self._counter = 0
2828
self._batch = batch
2929
self._sender = sender or _NoRetrySender

src/azure-cli/azure/cli/command_modules/acs/base_decorator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def __init__(
156156
self.raw_param = raw_parameters
157157
self.models = models
158158
self.decorator_mode = decorator_mode
159-
self.intermediates = dict()
159+
self.intermediates = {}
160160

161161
def get_intermediate(self, variable_name: str, default_value: Any = None) -> Any:
162162
"""Get the value of an intermediate by its name.

src/azure-cli/azure/cli/command_modules/apim/tests/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
logger.addHandler(logging.StreamHandler())
2424
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
2525
exceptions = []
26-
test_map = dict()
26+
test_map = {}
2727
SUCCESSED = "successed"
2828
FAILED = "failed"
2929

@@ -56,7 +56,7 @@ def wrapper(*args, **kwargs):
5656
func_to_call = get_func_to_call()
5757
logger.info("running %s()...", func.__name__)
5858
try:
59-
test_map[func.__name__] = dict()
59+
test_map[func.__name__] = {}
6060
test_map[func.__name__]["result"] = SUCCESSED
6161
test_map[func.__name__]["error_message"] = ""
6262
test_map[func.__name__]["error_stack"] = ""

src/azure-cli/azure/cli/command_modules/appservice/custom.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3868,7 +3868,7 @@ def __init__(self,
38683868
linux=False,
38693869
is_auto_update=None):
38703870
self.display_name = display_name
3871-
self.configs = configs if configs is not None else dict()
3871+
self.configs = configs if configs is not None else {}
38723872
self.github_actions_properties = github_actions_properties
38733873
self.linux = linux
38743874
self.is_auto_update = is_auto_update
@@ -4223,7 +4223,7 @@ def _format_version_name(cls, name):
42234223
def _format_version_names(self, runtime_to_version):
42244224
formatted_runtime_to_version = {}
42254225
for runtime, versions in runtime_to_version.items():
4226-
formatted_runtime_to_version[runtime] = formatted_runtime_to_version.get(runtime, dict())
4226+
formatted_runtime_to_version[runtime] = formatted_runtime_to_version.get(runtime, {})
42274227
for version_name, version_info in versions.items():
42284228
formatted_name = self._format_version_name(version_name)
42294229
if formatted_name in formatted_runtime_to_version[runtime]:
@@ -4266,7 +4266,7 @@ def _parse_raw_stacks(self, stacks):
42664266
'github_actions_properties': self.GithubActionsProperties(**github_actions_properties)
42674267
}
42684268

4269-
runtime_to_version[runtime_name] = runtime_to_version.get(runtime_name, dict())
4269+
runtime_to_version[runtime_name] = runtime_to_version.get(runtime_name, {})
42704270
runtime_to_version[runtime_name][runtime_version] = runtime_version_properties
42714271

42724272
runtime_to_version = self._format_version_names(runtime_to_version)
@@ -4335,8 +4335,8 @@ def __init__(self, name=None, version=None, is_preview=False, supported_func_ver
43354335
self.is_preview = is_preview
43364336
self.supported_func_versions = [] if not supported_func_versions else supported_func_versions
43374337
self.linux = linux
4338-
self.app_settings_dict = dict() if not app_settings_dict else app_settings_dict
4339-
self.site_config_dict = dict() if not site_config_dict else site_config_dict
4338+
self.app_settings_dict = {} if not app_settings_dict else app_settings_dict
4339+
self.site_config_dict = {} if not site_config_dict else site_config_dict
43404340
self.app_insights = app_insights
43414341
self.default = default
43424342
self.github_actions_properties = github_actions_properties
@@ -4458,7 +4458,7 @@ def _format_version_name(cls, name):
44584458
def _format_version_names(self, runtime_to_version):
44594459
formatted_runtime_to_version = {}
44604460
for runtime, versions in runtime_to_version.items():
4461-
formatted_runtime_to_version[runtime] = formatted_runtime_to_version.get(runtime, dict())
4461+
formatted_runtime_to_version[runtime] = formatted_runtime_to_version.get(runtime, {})
44624462
for version_name, version_info in versions.items():
44634463
formatted_name = self._format_version_name(version_name)
44644464
if formatted_name in formatted_runtime_to_version[runtime]:
@@ -4495,12 +4495,12 @@ def _parse_minor_version(self, runtime_settings, major_version_name, minor_versi
44954495
self.KEYS.GIT_HUB_ACTION_SETTINGS: runtime_settings.git_hub_action_settings
44964496
}
44974497

4498-
runtime_to_version[runtime_name] = runtime_to_version.get(runtime_name, dict())
4498+
runtime_to_version[runtime_name] = runtime_to_version.get(runtime_name, {})
44994499
runtime_to_version[runtime_name][minor_version_name] = runtime_version_properties
45004500

45014501
# obtain end of life date for all runtime versions
45024502
if runtime_settings.end_of_life_date is not None:
4503-
runtime_to_version_eol[runtime_name] = runtime_to_version_eol.get(runtime_name, dict())
4503+
runtime_to_version_eol[runtime_name] = runtime_to_version_eol.get(runtime_name, {})
45044504
runtime_to_version_eol[runtime_name][minor_version_name] = runtime_settings.end_of_life_date
45054505

45064506
def _create_runtime_from_properties(self, runtime_name, version_name, version_properties, linux):
@@ -4980,7 +4980,7 @@ def create_functionapp(cmd, resource_group_name, name, storage_account, plan=Non
49804980

49814981
site_config_dict = matched_runtime.site_config_dict if not flexconsumption_location \
49824982
else SiteConfigPropertiesDictionary()
4983-
app_settings_dict = matched_runtime.app_settings_dict if not flexconsumption_location else dict()
4983+
app_settings_dict = matched_runtime.app_settings_dict if not flexconsumption_location else {}
49844984

49854985
con_string = _validate_and_get_connection_string(cmd.cli_ctx, resource_group_name, storage_account)
49864986

src/azure-cli/azure/cli/command_modules/backup/custom.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def assign_identity(client, resource_group_name, vault_name, system_assigned=Non
455455

456456
if user_assigned is not None:
457457
userid = UserIdentity()
458-
user_assigned_identity = dict()
458+
user_assigned_identity = {}
459459
for userMSI in user_assigned:
460460
user_assigned_identity[userMSI] = userid
461461
if system_assigned is not None or curr_identity_type in ["systemassigned", "systemassigned, userassigned"]:
@@ -498,7 +498,7 @@ def remove_identity(client, resource_group_name, vault_name, system_assigned=Non
498498
userid = None
499499
remove_count_of_userMSI = 0
500500
totaluserMSI = 0
501-
user_assigned_identity = dict()
501+
user_assigned_identity = {}
502502
for element in curr_identity_details.user_assigned_identities.keys():
503503
if element in user_assigned:
504504
remove_count_of_userMSI += 1

src/azure-cli/azure/cli/command_modules/billing/tests/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
logger.addHandler(logging.StreamHandler())
2424
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
2525
exceptions = []
26-
test_map = dict()
26+
test_map = {}
2727
SUCCESSED = "successed"
2828
FAILED = "failed"
2929

@@ -57,7 +57,7 @@ def wrapper(*args, **kwargs):
5757
func_to_call = get_func_to_call()
5858
logger.info("running %s()...", func.__name__)
5959
try:
60-
test_map[func.__name__] = dict()
60+
test_map[func.__name__] = {}
6161
test_map[func.__name__]["result"] = SUCCESSED
6262
test_map[func.__name__]["error_message"] = ""
6363
test_map[func.__name__]["error_stack"] = ""

src/azure-cli/azure/cli/command_modules/container/_format.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def _get_images(container_group):
1010
"""Get all images of a container group. """
1111
containers = container_group.get('containers')
1212
if containers is not None and containers:
13-
images = set([])
13+
images = set()
1414
for container in containers:
1515
images.add(container['image'])
1616
return ','.join(images)

0 commit comments

Comments
 (0)