Skip to content

Commit

Permalink
fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ravgill committed Jul 20, 2022
1 parent 1206e69 commit 383c4a6
Show file tree
Hide file tree
Showing 12 changed files with 360 additions and 8,927 deletions.
2 changes: 1 addition & 1 deletion src/cosmosdb-preview/azext_cosmosdb_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@
examples:
- name: Retrieve container container_name's throughput for specific physical partitions
text: |-
az cosmosdb sql container retrieve-partition-throughput --account-name account_name --database-name db_name --name container_name --resource-group rg_name --physical-partition-ids 8 9"
az cosmosdb sql container retrieve-partition-throughput --account-name account_name --database-name db_name --name container_name --resource-group rg_name --physical-partition-ids 8 9
- name: Retrieve container container_name's throughput for all physical partitions
text: |-
az cosmosdb sql container retrieve-partition-throughput --account-name account_name --database-name db_name --name container_name --resource-group rg_name --all-partitions
Expand Down
2 changes: 1 addition & 1 deletion src/cosmosdb-preview/azext_cosmosdb_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def load_arguments(self, _):
c.argument('account_name', account_name_type, id_part=None, required=True, help='Name of the CosmosDB database account')
c.argument('database_name', database_name_type, required=True, help='Name of the CosmosDB database name')
c.argument('container_name', options_list=['--name', '-n'], required=True, help='Name of the CosmosDB collection')
c.argument('evenly_distribute', arg_type=get_three_state_flag(), help="switch to distribute throughput equally among all physical partitions")
c.argument('evenly_distribute', arg_type=get_three_state_flag(), help="switch to distribute throughput equally among all physical partitions")
c.argument('target_partition_info', nargs='+', action=CreateTargetPhysicalPartitionThroughputInfoAction, required=False, help="information about desired target physical partition throughput eg: 0=1200 1=1200")
c.argument('source_partition_info', nargs='+', action=CreateSourcePhysicalPartitionThroughputInfoAction, required=False, help="space separated source physical partition ids eg: 1 2")

Expand Down
5 changes: 4 additions & 1 deletion src/cosmosdb-preview/azext_cosmosdb_preview/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def __call__(self, parser, namespace, values, option_string=None):
else:
namespace.sql_container = sql_container


# pylint: disable=protected-access, too-few-public-methods
class CreateTargetPhysicalPartitionThroughputInfoAction(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
Expand All @@ -191,6 +192,7 @@ def __call__(self, parser, namespace, values, option_string=None):
namespace.target_partition_info.append(
PhysicalPartitionThroughputInfoResource(id=kvp[0], throughput=kvp[1]))


# pylint: disable=protected-access, too-few-public-methods
class CreateSourcePhysicalPartitionThroughputInfoAction(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
Expand All @@ -203,6 +205,7 @@ def __call__(self, parser, namespace, values, option_string=None):
namespace.source_partition_info.append(
PhysicalPartitionThroughputInfoResource(id=item, throughput=0))


# pylint: disable=protected-access, too-few-public-methods
class CreatePhysicalPartitionIdListAction(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
Expand All @@ -213,4 +216,4 @@ def __call__(self, parser, namespace, values, option_string=None):
raise CLIError('usage error: --physical-partition-ids [PhysicalPartitionId1 PhysicalPartitionId2 ...]')
for item in values:
namespace.physical_partition_ids.append(
PhysicalPartitionId(id=item))
PhysicalPartitionId(id=item))
14 changes: 8 additions & 6 deletions src/cosmosdb-preview/azext_cosmosdb_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# --------------------------------------------------------------------------------------------
# pylint: disable=line-too-long, too-many-statements, consider-using-f-string, broad-except, no-member, raise-missing-from

import json
from knack.util import CLIError
from knack.log import get_logger
from azext_cosmosdb_preview.vendored_sdks.azure_mgmt_cosmosdb.models import (
Expand Down Expand Up @@ -32,8 +31,7 @@
PhysicalPartitionId,
RedistributeThroughputParameters,
RedistributeThroughputPropertiesResource,
ThroughputPolicyType,
PhysicalPartitionThroughputInfoResource
ThroughputPolicyType
)

from azext_cosmosdb_preview._client_factory import (
Expand Down Expand Up @@ -1206,6 +1204,7 @@ def cli_begin_list_mongo_db_collection_partition_merge(client,
return async_partition_merge_result.result()


# pylint: disable=dangerous-default-value
def cli_begin_retrieve_sql_container_partition_throughput(client,
resource_group_name,
account_name,
Expand All @@ -1221,7 +1220,7 @@ def cli_begin_retrieve_sql_container_partition_throughput(client,
if ex.error.code == "NotFound":
raise CLIError("(NotFound) Container with name '{}' in database '{} could not be found.".format(container_name, database_name))

if len(physical_partition_ids) is 0 and all_partitions is False:
if len(physical_partition_ids) == 0 and all_partitions is False:
raise CLIError(
'Either of --physical-partition-ids/--all-partitions needs to be specified.')

Expand Down Expand Up @@ -1249,6 +1248,7 @@ def cli_begin_retrieve_sql_container_partition_throughput(client,
return async_partition_retrieve_throughput_result.result()


# pylint: disable=dangerous-default-value
def cli_begin_redistribute_sql_container_partition_throughput(client,
resource_group_name,
account_name,
Expand All @@ -1270,7 +1270,7 @@ def cli_begin_redistribute_sql_container_partition_throughput(client,
throughput_policy=ThroughputPolicyType.EQUAL,
target_physical_partition_throughput_info=[],
source_physical_partition_throughput_info=[])
else:
else:
redistribute_throughput_properties_resource = RedistributeThroughputPropertiesResource(
throughput_policy=ThroughputPolicyType.CUSTOM,
target_physical_partition_throughput_info=target_partition_info,
Expand All @@ -1290,6 +1290,7 @@ def cli_begin_redistribute_sql_container_partition_throughput(client,
return async_partition_redistribute_throughput_result.result()


# pylint: disable=dangerous-default-value
def cli_begin_retrieve_mongo_container_partition_throughput(client,
resource_group_name,
account_name,
Expand All @@ -1305,7 +1306,7 @@ def cli_begin_retrieve_mongo_container_partition_throughput(client,
if ex.error.code == "NotFound":
raise CLIError("(NotFound) Container with name '{}' in database '{} could not be found.".format(collection_name, database_name))

if len(physical_partition_ids) is 0 and all_partitions is False:
if len(physical_partition_ids) == 0 and all_partitions is False:
raise CLIError(
'Either of --physical-partition-ids/--all-partitions needs to be specified.')

Expand Down Expand Up @@ -1333,6 +1334,7 @@ def cli_begin_retrieve_mongo_container_partition_throughput(client,
return async_partition_retrieve_throughput_result.result()


# pylint: disable=dangerous-default-value
def cli_begin_redistribute_mongo_container_partition_throughput(client,
resource_group_name,
account_name,
Expand Down
Loading

0 comments on commit 383c4a6

Please sign in to comment.