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 used-before-assignment #30348

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -48,7 +48,6 @@ disable=
redundant-u-string-prefix,
raising-bad-type,
unused-private-member,
used-before-assignment,
# These rules were added in Pylint >= 2.12, disable them to avoid making retroactive change
missing-timeout,
superfluous-parens,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ def create_data_collection_endpoint(cmd, subscription, resource_group, region, e
def validate_data_collection_settings(dataCollectionSettings):
if 'interval' in dataCollectionSettings.keys():
intervalValue = dataCollectionSettings["interval"]
if (bool(re.match(r'^[0-9]+[m]$', intervalValue))) is False:
if (bool(re.match(r'^[0-9]+[m]$', intervalValue))) is False: # pylint: disable=used-before-assignment
Copy link
Member

Choose a reason for hiding this comment

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

@ganga1980 could you please help fix these issues?

raise InvalidArgumentValueError('interval format must be in <number>m')
intervalValue = int(intervalValue.rstrip("m"))
if intervalValue <= 0 or intervalValue > 30:
Expand Down Expand Up @@ -844,7 +844,7 @@ def add_monitoring_role_assignment(result, cluster_resource_id, cmd):
cmd,
"Monitoring Metrics Publisher",
service_principal_msi_id,
is_service_principal,
is_service_principal, # pylint: disable=used-before-assignment
scope=cluster_resource_id,
):
logger.warning(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def put_rules(cmd, default_rule_group_id, default_rule_group_name, mac_region, c
except CLIError as e:
error = e
else:
raise error
raise error # pylint: disable=used-before-assignment


# pylint: disable=line-too-long
Expand Down
4 changes: 2 additions & 2 deletions src/azure-cli/azure/cli/command_modules/resource/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ def _prepare_deployment_properties_unmodified(cmd, deployment_scope, template_fi
template_obj['resources'] = template_obj.get('resources', [])

if _is_bicepparam_file_provided(parameters):
parameters = json.loads(bicepparam_json_content).get('parameters', {})
parameters = json.loads(bicepparam_json_content).get('parameters', {}) # pylint: disable=used-before-assignment
else:
parameters = _process_parameters(template_obj, parameters) or {}
parameters = _get_missing_parameters(parameters, template_obj, _prompt_for_parameters, no_prompt)
Expand Down Expand Up @@ -1381,7 +1381,7 @@ def _prepare_stacks_templates_and_parameters(cmd, rcf, deployment_scope, deploym
template_obj['resources'] = template_obj.get('resources', [])

if _is_bicepparam_file_provided(parameters):
parameters = json.loads(bicepparam_json_content).get('parameters', {})
parameters = json.loads(bicepparam_json_content).get('parameters', {}) # pylint: disable=used-before-assignment
else:
parameters = _process_parameters(template_obj, parameters) or {}
parameters = _get_missing_parameters(parameters, template_obj, _prompt_for_parameters, False)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ def validator(cmd, namespace):
for attr in ['content_type', 'content_disposition', 'content_encoding', 'content_language',
'content_md5', 'cache_control']:
if getattr(new_props, attr) is None:
setattr(new_props, attr, getattr(props, attr))
setattr(new_props, attr, getattr(props, attr)) # pylint: disable=used-before-assignment
else:
if guess_from_file:
new_props = guess_content_type(ns[guess_from_file], new_props, settings_class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def validator(cmd, namespace):
for attr in ['content_type', 'content_disposition', 'content_encoding', 'content_language',
'content_md5', 'cache_control']:
if getattr(new_props, attr) is None:
setattr(new_props, attr, getattr(props, attr))
setattr(new_props, attr, getattr(props, attr)) # pylint: disable=used-before-assignment
else:
if guess_from_file:
new_props = guess_content_type(ns[guess_from_file], new_props, settings_class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def process_image_template_create_namespace(cmd, namespace): # pylint: disable=
for script in scripts:
if script["type"] is None:
try:
script["type"] = ScriptType.SHELL if likely_linux else ScriptType.POWERSHELL
script["type"] = ScriptType.SHELL if likely_linux else ScriptType.POWERSHELL # pylint: disable=used-before-assignment
logger.info("For script %s, likely linux is %s.", script["script"], likely_linux)
except NameError:
raise CLIError("Unable to infer the type of script {}.".format(script["script"]))
Expand Down
Loading