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 consider-using-in #30349

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from
Draft

Conversation

jiasli
Copy link
Member

@jiasli jiasli commented Nov 14, 2024

Description
Finish the unfinished tasks of #20192

Fix consider-using-in: https://pylint.readthedocs.io/en/latest/user_guide/messages/refactor/consider-using-in.html

Auto-fixed with ruff:

ruff check --select PLR1714 --fix --unsafe-fixes

consider-using-in / R1714 is implemented as PLR1714 in ruff:

Copy link

azure-client-tools-bot-prd bot commented Nov 14, 2024

️✔️AzureCLI-FullTest
️✔️acr
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️acs
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.9
️✔️ams
️✔️latest
️✔️3.12
️✔️3.9
️✔️apim
️✔️latest
️✔️3.12
️✔️3.9
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.9
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️aro
️✔️latest
️✔️3.12
️✔️3.9
️✔️backup
️✔️latest
️✔️3.12
️✔️3.9
️✔️batch
️✔️latest
️✔️3.12
️✔️3.9
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.9
️✔️billing
️✔️latest
️✔️3.12
️✔️3.9
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.9
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.9
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.9
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.9
️✔️config
️✔️latest
️✔️3.12
️✔️3.9
️✔️configure
️✔️latest
️✔️3.12
️✔️3.9
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.9
️✔️container
️✔️latest
️✔️3.12
️✔️3.9
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.9
️✔️core
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.9
️✔️databoxedge
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️dls
️✔️latest
️✔️3.12
️✔️3.9
️✔️dms
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.9
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.9
️✔️find
️✔️latest
️✔️3.12
️✔️3.9
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.9
️✔️identity
️✔️latest
️✔️3.12
️✔️3.9
️✔️iot
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️keyvault
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️lab
️✔️latest
️✔️3.12
️✔️3.9
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️maps
️✔️latest
️✔️3.12
️✔️3.9
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.9
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.9
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.9
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.9
️✔️network
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.9
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.9
️✔️profile
️✔️latest
️✔️3.12
️✔️3.9
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.9
️✔️redis
️✔️latest
️✔️3.12
️✔️3.9
️✔️relay
️✔️latest
️✔️3.12
️✔️3.9
️✔️resource
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️role
️✔️latest
️✔️3.12
️✔️3.9
️✔️search
️✔️latest
️✔️3.12
️✔️3.9
️✔️security
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.9
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.9
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.9
️✔️sql
️✔️latest
️✔️3.12
️✔️3.9
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.9
️✔️storage
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.9
️✔️telemetry
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️util
️✔️latest
️✔️3.12
️✔️3.9
️✔️vm
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9

Copy link

azure-client-tools-bot-prd bot commented Nov 14, 2024

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@yonzhan
Copy link
Collaborator

yonzhan commented Nov 14, 2024

Thank you for your contribution! We will review the pull request and get back to you soon.

@jiasli
Copy link
Member Author

jiasli commented Nov 14, 2024

This is a big task:

2024-11-14T04:28:27.8833193Z ERROR: ************* Module azure.cli.command_modules.container.custom
2024-11-14T04:28:27.8834239Z src/azure-cli/azure/cli/command_modules/container/custom.py:550:11: R1714: Consider merging these comparisons with 'in' by using 'ex.error.code in ('NotFound', 'ResourceNotFound')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8835378Z src/azure-cli/azure/cli/command_modules/container/custom.py:583:15: R1714: Consider merging these comparisons with 'in' by using 'ex.error.code in ('NotFound', 'ResourceNotFound')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8836460Z src/azure-cli/azure/cli/command_modules/container/custom.py:1179:11: R1714: Consider merging these comparisons with 'in' by using 'container_group.instance_view.state in ('Succeeded', 'Failed')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8837216Z ************* Module azure.cli.command_modules.sql.custom
2024-11-14T04:28:27.8838111Z src/azure-cli/azure/cli/command_modules/sql/custom.py:445:9: R1714: Consider merging these comparisons with 'in' by using 'servicePrincipalType in (ServicePrincipalType.system_assigned.value, ServicePrincipalType.none.value)'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8839552Z ************* Module azure.cli.command_modules.eventhubs.action
2024-11-14T04:28:27.8840253Z src/azure-cli/azure/cli/command_modules/eventhubs/action.py:67:19: R1714: Consider merging these comparisons with 'in' by using 'v in ('true', 'True', 'TRUE')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8840974Z ************* Module azure.cli.command_modules.rdbms.flexible_server_custom_postgres
2024-11-14T04:28:27.8843794Z src/azure-cli/azure/cli/command_modules/rdbms/flexible_server_custom_postgres.py:1509:11: R1714: Consider merging these comparisons with 'in' by using 'zone not in (sourceServerZone, 'none')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8844803Z ************* Module azure.cli.command_modules.rdbms._params
2024-11-14T04:28:27.8846084Z src/azure-cli/azure/cli/command_modules/rdbms/_params.py:982:19: R1714: Consider merging these comparisons with 'in' by using 'scope in ('approve', 'reject')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8846804Z ************* Module azure.cli.command_modules.acs.maintenanceconfiguration
2024-11-14T04:28:27.8847610Z src/azure-cli/azure/cli/command_modules/acs/maintenanceconfiguration.py:51:7: R1714: Consider merging these comparisons with 'in' by using 'config_name in (CONST_AUTOUPGRADE_CONFIGURATION_NAME, CONST_NODEOSUPGRADE_CONFIGURATION_NAME)'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8848409Z ************* Module azure.cli.command_modules.acs._validators
2024-11-14T04:28:27.8849119Z src/azure-cli/azure/cli/command_modules/acs/_validators.py:315:11: R1714: Consider merging these comparisons with 'in' by using 'namespace.priority not in ('Spot', 'Regular')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8850060Z src/azure-cli/azure/cli/command_modules/acs/_validators.py:325:11: R1714: Consider merging these comparisons with 'in' by using 'namespace.eviction_policy not in ('Delete', 'Deallocate')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8850725Z ************* Module azure.cli.command_modules.acs.agentpool_decorator
2024-11-14T04:28:27.8851440Z src/azure-cli/azure/cli/command_modules/acs/agentpool_decorator.py:647:15: R1714: Consider merging these comparisons with 'in' by using 'raw_os_sku in (sku_2019, sku_2022)'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8852100Z ************* Module azure.cli.command_modules.acs.custom
2024-11-14T04:28:27.8852765Z src/azure-cli/azure/cli/command_modules/acs/custom.py:882:7: R1714: Consider merging these comparisons with 'in' by using 'kubernetes_version in (instance.kubernetes_version, '')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8853647Z src/azure-cli/azure/cli/command_modules/acs/custom.py:2508:7: R1714: Consider merging these comparisons with 'in' by using 'kubernetes_version in ('', instance.orchestrator_version)'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8854329Z ************* Module azure.cli.command_modules.synapse.manual.operations.spark
2024-11-14T04:28:27.8855185Z src/azure-cli/azure/cli/command_modules/synapse/manual/operations/spark.py:42:11: R1714: Consider merging these comparisons with 'in' by using 'language in (SparkBatchLanguage.SparkDotNet, SparkBatchLanguage.Spark)'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8855889Z ************* Module azure.cli.command_modules.resource.custom
2024-11-14T04:28:27.8856562Z src/azure-cli/azure/cli/command_modules/resource/custom.py:1575:7: R1714: Consider merging these comparisons with 'in' by using 'url.scheme in ('http', 'https', 'file')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8857354Z ************* Module azure.cli.command_modules.role.custom
2024-11-14T04:28:27.8859947Z src/azure-cli/azure/cli/command_modules/role/custom.py:1821:11: R1714: Consider merging these comparisons with 'in' by using 'user_input in (odata_type, odata_type.split('.')[-1])'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8860595Z ************* Module azure.cli.command_modules.servicebus.action
2024-11-14T04:28:27.8861091Z src/azure-cli/azure/cli/command_modules/servicebus/action.py:65:19: R1714: Consider merging these comparisons with 'in' by using 'v in ('true', 'True', 'TRUE')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8861577Z ************* Module azure.cli.command_modules.network.custom
2024-11-14T04:28:27.8862087Z src/azure-cli/azure/cli/command_modules/network/custom.py:2633:16: R1714: Consider merging these comparisons with 'in' by using 'record_type in ('a', 'aaaa', 'cname')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8862922Z src/azure-cli/azure/cli/command_modules/network/custom.py:2639:17: R1714: Consider merging these comparisons with 'in' by using 'record_type in ('aaaa', 'a')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8863418Z ************* Module azure.cli.command_modules.network.azure_stack.custom
2024-11-14T04:28:27.8863940Z src/azure-cli/azure/cli/command_modules/network/azure_stack/custom.py:234:16: R1714: Consider merging these comparisons with 'in' by using 'record_type in ('a', 'aaaa', 'cname')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8864622Z src/azure-cli/azure/cli/command_modules/network/azure_stack/custom.py:240:17: R1714: Consider merging these comparisons with 'in' by using 'record_type in ('aaaa', 'a')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8865127Z ************* Module azure.cli.command_modules.cosmosdb._validators
2024-11-14T04:28:27.8865659Z src/azure-cli/azure/cli/command_modules/cosmosdb/_validators.py:458:12: R1714: Consider merging these comparisons with 'in' by using 'encryptionType not in ('Deterministic', 'Randomized')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8866175Z ************* Module azure.cli.command_modules.cosmosdb.custom
2024-11-14T04:28:27.8866775Z src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py:1575:27: R1714: Consider merging these comparisons with 'in' by using 'existing.identity.type in (ResourceIdentityType.system_assigned, ResourceIdentityType.system_assigned_user_assigned)'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8867537Z src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py:2769:16: R1714: Consider merging these comparisons with 'in' by using 'resource.operation_type in ('Create', 'Recreate')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8868231Z src/azure-cli/azure/cli/command_modules/cosmosdb/custom.py:2796:16: R1714: Consider merging these comparisons with 'in' by using 'resource.operation_type in ('Create', 'Recreate')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8868803Z ************* Module azure.cli.command_modules.cdn.custom.custom_afdx
2024-11-14T04:28:27.8869364Z src/azure-cli/azure/cli/command_modules/cdn/custom/custom_afdx.py:152:11: R1714: Consider merging these comparisons with 'in' by using 'args.identity_type in ('UserAssigned', 'SystemAssigned, UserAssigned')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8870111Z src/azure-cli/azure/cli/command_modules/cdn/custom/custom_afdx.py:203:15: R1714: Consider merging these comparisons with 'in' by using 'args.identity_type in ('UserAssigned', 'SystemAssigned, UserAssigned')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8870773Z ************* Module azure.cli.command_modules.cdn.custom.custom_cdn
2024-11-14T04:28:27.8871323Z src/azure-cli/azure/cli/command_modules/cdn/custom/custom_cdn.py:1138:11: R1714: Consider merging these comparisons with 'in' by using 'args.identity_type in ('UserAssigned', 'SystemAssigned, UserAssigned')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8871856Z ************* Module azure.cli.command_modules.appservice._validators
2024-11-14T04:28:27.8872378Z src/azure-cli/azure/cli/command_modules/appservice/_validators.py:485:7: R1714: Consider merging these comparisons with 'in' by using 'ase.internal_load_balancing_mode not in (0, 'None')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8872856Z ************* Module azure.cli.command_modules.appservice.custom
2024-11-14T04:28:27.8873350Z src/azure-cli/azure/cli/command_modules/appservice/custom.py:1326:39: R1714: Consider merging these comparisons with 'in' by using 'webapp.identity.type in (IdentityType.system_assigned, IdentityType.none)'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8874182Z src/azure-cli/azure/cli/command_modules/appservice/custom.py:7122:7: R1714: Consider merging these comparisons with 'in' by using 'response.status_code in (202, 200)'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8874857Z src/azure-cli/azure/cli/command_modules/appservice/custom.py:7293:49: R1714: Consider merging these comparisons with 'in' by using 'hostname_binding.host_name_type in ('Verified', 'Managed')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8875393Z ************* Module azure.cli.command_modules.appservice.static_sites
2024-11-14T04:28:27.8875939Z src/azure-cli/azure/cli/command_modules/appservice/static_sites.py:245:43: R1714: Consider merging these comparisons with 'in' by using 'staticsite.identity.type in (IdentityType.system_assigned, IdentityType.none)'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8876495Z ************* Module azure.cli.command_modules.acr._agentpool_polling
2024-11-14T04:28:27.8877015Z src/azure-cli/azure/cli/command_modules/acr/_agentpool_polling.py:87:11: R1714: Consider merging these comparisons with 'in' by using 'response.http_response.status_code in (200, 404)'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8877517Z ************* Module azure.cli.command_modules.acr._docker_utils
2024-11-14T04:28:27.8877975Z src/azure-cli/azure/cli/command_modules/acr/_docker_utils.py:628:15: R1714: Consider merging these comparisons with 'in' by using 'response.status_code in (201, 202)'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8878458Z ************* Module azure.cli.command_modules.acr.artifact_streaming
2024-11-14T04:28:27.8879004Z src/azure-cli/azure/cli/command_modules/acr/artifact_streaming.py:171:10: R1714: Consider merging these comparisons with 'in' by using 'status in (ArtifactStreamingStatus.Running.value, ArtifactStreamingStatus.NotStarted.value)'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8879572Z ************* Module azure.cli.command_modules.storage.util
2024-11-14T04:28:27.8880030Z src/azure-cli/azure/cli/command_modules/storage/util.py:291:11: R1714: Consider merging these comparisons with 'in' by using 'ch in ('*', '?', '[')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8880520Z ************* Module azure.cli.command_modules.storage.storage_url_helpers
2024-11-14T04:28:27.8881261Z src/azure-cli/azure/cli/command_modules/storage/storage_url_helpers.py:28:24: R1714: Consider merging these comparisons with 'in' by using 'url.scheme in ('http', 'https')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8881771Z ************* Module azure.cli.command_modules.storage.operations.table
2024-11-14T04:28:27.8882418Z src/azure-cli/azure/cli/command_modules/storage/operations/table.py:78:7: R1714: Consider merging these comparisons with 'in' by using 'if_exists in ('merge', 'replace')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8888234Z ************* Module azure.cli.command_modules.vm.custom
2024-11-14T04:28:27.8888702Z src/azure-cli/azure/cli/command_modules/vm/custom.py:5272:11: R1714: Consider merging these comparisons with 'in' by using 'resource.name in ('MicrosoftMonitoringAgent', 'OmsAgentForLinux')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8889171Z ************* Module azure.cli.command_modules.redis.custom
2024-11-14T04:28:27.8889715Z src/azure-cli/azure/cli/command_modules/redis/custom.py:255:8: R1714: Consider merging these comparisons with 'in' by using 'identity.type in (ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED.value, ManagedServiceIdentityType.SYSTEM_ASSIGNED.value)'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8890474Z ************* Module azure.cli.core.aaz._operation
2024-11-14T04:28:27.8890933Z src/azure-cli-core/azure/cli/core/aaz/_operation.py:58:11: R1714: Consider merging these comparisons with 'in' by using 'value in (AAZUndefined, None)'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8891523Z src/azure-cli-core/azure/cli/core/aaz/_operation.py:207:11: R1714: Consider merging these comparisons with 'in' by using 'data in (AAZUndefined, None)'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8891964Z ************* Module azure.cli.core.extension.operations
2024-11-14T04:28:27.8892463Z src/azure-cli-core/azure/cli/core/extension/operations.py:89:14: R1714: Consider merging these comparisons with 'in' by using 'url_parse_result.scheme in ('http', 'https')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8893162Z src/azure-cli-core/azure/cli/core/extension/operations.py:103:14: R1714: Consider merging these comparisons with 'in' by using 'url_parse_result.scheme in ('http', 'https')'. Use a set instead if elements are hashable. (consider-using-in)
2024-11-14T04:28:27.8893864Z src/azure-cli-core/azure/cli/core/extension/operations.py:113:7: R1714: Consider merging these comparisons with 'in' by using 'extension_name in ('rdbms-connect', 'serviceconnector-passwordless')'. Use a set instead if elements are hashable. (consider-using-in)

@jiasli jiasli marked this pull request as draft November 14, 2024 06:04
@jiasli jiasli mentioned this pull request Nov 14, 2024
12 tasks
@jiasli
Copy link
Member Author

jiasli commented Nov 15, 2024

ruff cannot detect this line:

return odata_type == user_input or odata_type.split('.')[-1] == user_input

@@ -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:
Copy link
Member Author

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"):
Copy link
Member Author

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

Comment on lines +361 to +362
if not (ns.public_access in ('Disabled', 'Enabled') or
val in ('all', 'none') or (len(val.split('-')) == 1 and _validate_ip(val)) or
Copy link
Member Author

@jiasli jiasli Nov 15, 2024

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))):
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants