-
Notifications
You must be signed in to change notification settings - Fork 3k
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 consider-using-in #30349
base: dev
Are you sure you want to change the base?
Conversation
️✔️AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
This is a big task:
|
|
@@ -51,7 +51,7 @@ def validate_import_key(key): | |||
if not isinstance(key, str): | |||
logger.warning("Ignoring invalid key '%s'. Key must be a string.", key) | |||
return False | |||
if key == '.' or key == '..' or '%' in key: | |||
if key in (".", "..") or "%" in key: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why ruff
changes '
to "
.
@@ -482,7 +482,7 @@ def _validate_ase_is_v3(ase): | |||
|
|||
|
|||
def _validate_ase_not_ilb(ase): | |||
if (ase.internal_load_balancing_mode != 0) and (ase.internal_load_balancing_mode != "None"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
()
are unnecessary as !=
has higher precedence: https://docs.python.org/3/reference/expressions.html#operator-precedence
if not (ns.public_access in ('Disabled', 'Enabled') or | ||
val in ('all', 'none') or (len(val.split('-')) == 1 and _validate_ip(val)) or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The outer ()
of (len(val.split('-')) == 1 and _validate_ip(val))
are unnecessary. ruff
automatically fixes it:
if not (ns.public_access in ('Disabled', 'Enabled') or val in ('all', 'none') or len(val.split('-')) == 1 and _validate_ip(val) or len(val.split('-')) == 2 and _validate_ip(val)):
but I am not going to fix it here.
@@ -442,8 +442,7 @@ def _get_service_principal_object_from_type(servicePrincipalType): | |||
servicePrincipalResult = None | |||
|
|||
if (servicePrincipalType is not None and | |||
(servicePrincipalType == ServicePrincipalType.system_assigned.value or | |||
servicePrincipalType == ServicePrincipalType.none.value)): | |||
(servicePrincipalType in (ServicePrincipalType.system_assigned.value, ServicePrincipalType.none.value))): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks flake8:
Running flake8 on modules...
ERROR: /mnt/vss/_work/1/s/src/azure-cli/azure/cli/command_modules/sql/custom.py:445:9: E129 visually indented line with same indent as next logical line
/mnt/vss/_work/1/s/src/azure-cli/azure/cli/command_modules/sql/custom.py:445:9: E129 visually indented line with same indent as next logical line
2 E129 visually indented line with same indent as next logical line
See https://stackoverflow.com/questions/44638211/pep8-contradiction-between-e129-and-e127-e128
Description
Finish the unfinished tasks of #20192
Fix
consider-using-in
: https://pylint.readthedocs.io/en/latest/user_guide/messages/refactor/consider-using-in.htmlAuto-fixed with
ruff
:consider-using-in
/R1714
is implemented asPLR1714
inruff
: