Skip to content

Commit

Permalink
Change Pylint rules project-wise (Azure#3254)
Browse files Browse the repository at this point in the history
* Change Pylint rules project-wise

1. Disable too-many-arguments pylint error. Due to the nature of the
project many methods' arguments set directly reflects the command
options. As a result, there is no way to reduce the arguments set size.
The too-many-arguments disable statement is widely used to the extend
that essentially the rule doesn't matter anymore. I'll disable the rule
globally.

2. Extend the max length to 120 from 100, which is the default pylint
value. The 120 characters lenght is the default github review page's
line limitation.

* Update flake 8 rule
  • Loading branch information
troydai authored May 8, 2017
1 parent efe177d commit f8d4093
Show file tree
Hide file tree
Showing 44 changed files with 97 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[flake8]
max-line-length = 100
max-line-length = 120
max-complexity = 10
ignore =
E126,
Expand Down
9 changes: 8 additions & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@
# I0011 Warning locally suppressed using disable-msg
# W0511 fixme
# R0401 Cyclic import (because of https://github.com/PyCQA/pylint/issues/850)
disable=C0111,C0103,I0011,W0511,R0401
# R0913 Too many arguments - Due to the nature of the CLI many commands have large arguments set which reflect in large arguments set in corresponding methods.
disable=C0111,C0103,I0011,W0511,R0401,R0913

[FORMAT]
max-line-length=120

[VARIABLES]
# Tells whether we should check for unused import in __init__ files.
init-import=yes

[DESIGN]
# Maximum number of locals for function / method body
max-locals=25
# Maximum number of branch for function / method body
max-branches=20

[SIMILARITIES]
min-similarity-lines=10

1 change: 0 additions & 1 deletion scripts/automation/tests/nose_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from __future__ import print_function

# pylint: disable=too-many-arguments
def get_nose_runner(report_folder, parallel=True, process_timeout=600, process_restart=True,
xunit_report=False, exclude_integration=True):
"""Create a nose execution method"""
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def _load_from_data(self, data):

class HelpParameter(HelpObject): # pylint: disable=too-few-public-methods, too-many-instance-attributes

def __init__(self, param_name, description, required, choices=None, # pylint: disable=too-many-arguments
def __init__(self, param_name, description, required, choices=None,
default=None, group_name=None):
super(HelpParameter, self).__init__()
self.name = param_name
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def __init__(self, storage=None, auth_ctx_factory=None, use_global_creds_cache=T
self._management_resource_uri = CLOUD.endpoints.management
self._ad_resource_uri = CLOUD.endpoints.active_directory_resource_id

def find_subscriptions_on_login(self, # pylint: disable=too-many-arguments
def find_subscriptions_on_login(self,
interactive,
username,
password,
Expand Down
5 changes: 2 additions & 3 deletions src/azure-cli-core/azure/cli/core/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CloudSuffixNotSetException(CLIError):

class CloudEndpoints(object): # pylint: disable=too-few-public-methods,too-many-instance-attributes

def __init__(self, # pylint: disable=too-many-arguments
def __init__(self,
management=None,
resource_manager=None,
sql_management=None,
Expand Down Expand Up @@ -89,7 +89,7 @@ def __getattribute__(self, name):

class CloudSuffixes(object): # pylint: disable=too-few-public-methods

def __init__(self, # pylint: disable=too-many-arguments
def __init__(self,
storage_endpoint=None,
keyvault_dns=None,
sql_server_hostname=None,
Expand All @@ -113,7 +113,6 @@ def __getattribute__(self, name):
class Cloud(object): # pylint: disable=too-few-public-methods
""" Represents an Azure Cloud instance """

# pylint: disable=too-many-arguments
def __init__(self,
name,
endpoints=None,
Expand Down
1 change: 0 additions & 1 deletion src/azure-cli-core/azure/cli/core/commands/arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ def _user_confirmed(confirmation, command_args):
return False


# pylint: disable=too-many-arguments
def cli_generic_update_command(module_name, name, getter_op, setter_op, factory=None,
setter_arg_name='parameters', table_transformer=None,
child_collection_prop_name=None, child_collection_key='name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _get_mgmt_service_client(client_type, subscription_bound=True, subscription_
return (client, subscription_id)


def get_data_service_client(service_type, account_name, account_key, connection_string=None, # pylint: disable=too-many-arguments
def get_data_service_client(service_type, account_name, account_key, connection_string=None,
sas_token=None, endpoint_suffix=None):
logger.debug('Getting data service client service_type=%s', service_type.__name__)
try:
Expand Down
6 changes: 3 additions & 3 deletions src/azure-cli-core/azure/cli/core/commands/template_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
make_camel_case)


def register_folded_cli_argument(scope, base_name, resource_type, parent_name=None, # pylint: disable=too-many-arguments
def register_folded_cli_argument(scope, base_name, resource_type, parent_name=None,
parent_option_flag=None, parent_type=None, type_field=None,
existing_id_flag_value='existingId', new_flag_value='new',
none_flag_value='none', default_value_flag='new',
Expand Down Expand Up @@ -64,7 +64,7 @@ def wrapped(namespace):
register_cli_argument(scope, type_field_name, help=argparse.SUPPRESS, default=None)


def _name_id_fold(base_name, resource_type, type_field, # pylint: disable=too-many-arguments
def _name_id_fold(base_name, resource_type, type_field,
existing_id_flag_value, new_flag_value, none_flag_value,
parent_name=None, parent_option_flag=None, parent_type=None, base_required=True):
def handle_folding(namespace):
Expand Down Expand Up @@ -188,7 +188,7 @@ def _validate_name_or_id(
return (resource_id_parts, value_supplied_was_id)


def get_folded_parameter_validator( # pylint: disable=too-many-arguments
def get_folded_parameter_validator(
property_name, property_type, property_option,
parent_name=None, parent_type=None, parent_option=None,
allow_none=False, allow_new=False, default_none=False):
Expand Down
2 changes: 0 additions & 2 deletions src/azure-cli-core/azure/cli/core/sdk/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def group(self, group_name):


class CommandGroup(object):
# pylint: disable=too-many-arguments
def __init__(self, scope, group_name, client_factory, service_adapter=None, custom_path=None):
self._scope = scope
self._group_name = group_name
Expand Down Expand Up @@ -70,7 +69,6 @@ def custom_command(self, name, custom_func_name, confirmation=None):
client_factory=self._client_factory,
confirmation=confirmation)

# pylint: disable=too-many-arguments
def generic_update_command(self, name, getter_op, setter_op, custom_func_name=None,
setter_arg_name='parameters'):
if custom_func_name:
Expand Down
6 changes: 3 additions & 3 deletions src/azure-cli-testsdk/azure/cli/testsdk/preparers.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def process_response(self, response):
# Resource Group Preparer and its shorthand decorator

class ResourceGroupPreparer(AbstractPreparer, SingleValueReplacer):
def __init__(self, name_prefix='clitest.rg', # pylint: disable=too-many-arguments
def __init__(self, name_prefix='clitest.rg',
parameter_name='resource_group',
parameter_name_for_location='resource_group_location', location='westus',
dev_setting_name='AZURE_CLI_TEST_DEV_RESOURCE_GROUP_NAME',
Expand Down Expand Up @@ -141,7 +141,7 @@ def remove_resource(self, name, **kwargs):
# Storage Account Preparer and its shorthand decorator

class StorageAccountPreparer(AbstractPreparer, SingleValueReplacer):
def __init__(self, # pylint: disable=too-many-arguments
def __init__(self,
name_prefix='clitest', sku='Standard_LRS', location='westus',
parameter_name='storage_account', resource_group_parameter_name='resource_group',
skip_delete=True, dev_setting_name='AZURE_CLI_TEST_DEV_STORAGE_ACCOUNT_NAME'):
Expand Down Expand Up @@ -185,7 +185,7 @@ def _get_resource_group(self, **kwargs):
# Role based access control service principal preparer

class RoleBasedServicePrincipalPreparer(AbstractPreparer, SingleValueReplacer):
def __init__(self, name_prefix='http://clitest', # pylint: disable=too-many-arguments
def __init__(self, name_prefix='http://clitest',
skip_assignment=True, parameter_name='sp_name', parameter_password='sp_password',
dev_setting_sp_name='AZURE_CLI_TEST_DEV_SP_NAME',
dev_setting_sp_password='AZURE_CLI_TEST_DEV_SP_PASSWORD'):
Expand Down
2 changes: 0 additions & 2 deletions src/azure-cli-testsdk/azure/cli/testsdk/vcr_test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ class VCRTestBase(unittest.TestCase): # pylint: disable=too-many-instance-attri
'x-ms-served-by',
]

# pylint: disable=too-many-arguments
def __init__(self, test_file, test_name, run_live=False, debug=False, debug_vcr=False,
skip_setup=False, skip_teardown=False):
super(VCRTestBase, self).__init__(test_name)
Expand Down Expand Up @@ -485,7 +484,6 @@ def execute(self):


class ResourceGroupVCRTestBase(VCRTestBase):
# pylint: disable=too-many-arguments

def __init__(self, test_file, test_name, resource_group='vcr_resource_group', run_live=False,
debug=False, debug_vcr=False, skip_setup=False, skip_teardown=False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def get_access_key_by_storage_account_name(storage_account_name, resource_group_
0].value # pylint: disable=no-member


def arm_deploy_template_new_storage(resource_group_name, # pylint: disable=too-many-arguments
def arm_deploy_template_new_storage(resource_group_name,
registry_name,
location,
sku,
Expand Down Expand Up @@ -127,7 +127,7 @@ def arm_deploy_template_new_storage(resource_group_name, # pylint: disable=too-
get_arm_service_client().deployments, resource_group_name, deployment_name, properties)


def arm_deploy_template_existing_storage(resource_group_name, # pylint: disable=too-many-arguments
def arm_deploy_template_existing_storage(resource_group_name,
registry_name,
location,
sku,
Expand Down Expand Up @@ -183,7 +183,7 @@ def _arm_deploy_template(deployments_client,
return deployments_client.create_or_update(resource_group_name, deployment_name, properties)


def _parameters(registry_name, # pylint: disable=too-many-arguments
def _parameters(registry_name,
location,
sku,
admin_user_enabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def acr_list(resource_group_name=None):
return client.list()


def acr_create(registry_name, # pylint: disable=too-many-arguments
def acr_create(registry_name,
resource_group_name,
sku,
location=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _load_key(key_filename):
return pkey


def SecureCopy(user, host, src, dest, # pylint: disable=too-many-arguments
def SecureCopy(user, host, src, dest,
key_filename=None,
allow_agent=True):
ssh = paramiko.SSHClient()
Expand Down Expand Up @@ -71,7 +71,7 @@ def __del__(self):
if self.tunnel_server is not None:
self.tunnel_server.close_tunnel()

def connect(self, host, username, port=2200, # pylint: disable=too-many-arguments
def connect(self, host, username, port=2200,
key_filename=None):
"""
Creates a connection to the remote server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ def _resolve_service_principal(client, identifier):
raise CLIError("service principal '{}' doesn't exist".format(identifier))


def create_application(client, display_name, homepage, identifier_uris, # pylint: disable=too-many-arguments
def create_application(client, display_name, homepage, identifier_uris,
available_to_other_tenants=False, password=None, reply_urls=None,
key_value=None, key_type=None, key_usage=None, start_date=None,
end_date=None):
Expand All @@ -883,7 +883,7 @@ def create_application(client, display_name, homepage, identifier_uris, # pylin
return client.create(app_create_param)


def _build_application_creds(password=None, key_value=None, key_type=None, # pylint: disable=too-many-arguments
def _build_application_creds(password=None, key_value=None, key_type=None,
key_usage=None, start_date=None, end_date=None):
if password and key_value:
raise CLIError('specify either --password or --key-value, but not both.')
Expand Down Expand Up @@ -940,7 +940,7 @@ def create_role_assignment(role, assignee, resource_group_name=None, scope=None)
return _create_role_assignment(role, assignee, resource_group_name, scope)


def _create_role_assignment(role, assignee, resource_group_name=None, scope=None, # pylint: disable=too-many-arguments
def _create_role_assignment(role, assignee, resource_group_name=None, scope=None,
resolve_assignee=True):
factory = _auth_client_factory(scope)
assignments_client = factory.role_assignments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ._validators import validate_existing_function_app, validate_existing_web_app


def _generic_site_operation(resource_group_name, name, operation_name, slot=None, # pylint: disable=too-many-arguments
def _generic_site_operation(resource_group_name, name, operation_name, slot=None,
extra_parameter=None, client=None):
client = client or web_client_factory()
m = getattr(client.web_apps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class VstsContinuousDeliveryProvider(object):
def __init__(self):
self._progress_last_message = ''

def setup_continuous_delivery(self, # pylint:disable=too-many-arguments
def setup_continuous_delivery(self,
resource_group_name, name, repo_url, branch, git_token,
slot, cd_app_type, cd_account, cd_create_account, location):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def deserialize_json(self, client, kwargs, json_obj):
if kwargs[self._request_param['name']] is None:
raise ValueError(message.format(self._request_param['model']))

def queue_argument(self, name=None, path=None, root=None, # pylint:disable=too-many-arguments
def queue_argument(self, name=None, path=None, root=None,
options=None, type=None, # pylint: disable=redefined-builtin
dependencies=None):
"""Add pending command line argument
Expand Down Expand Up @@ -697,7 +697,7 @@ def _process_options(self):
options['options_list'] = [arg_name(param)]
yield (param, CliCommandArgument(param, **options))

def _resolve_conflict(self, # pylint:disable=too-many-arguments
def _resolve_conflict(self,
arg, param, path, options, typestr, dependencies, conflicting):
"""Resolve conflicting command line arguments.
:param str arg: Name of the command line argument.
Expand Down Expand Up @@ -900,7 +900,7 @@ def validate_client_parameters(namespace):
namespace.account_key = None


def cli_batch_data_plane_command(name, # pylint:disable=too-many-arguments
def cli_batch_data_plane_command(name,
operation, client_factory, transform=None, flatten=FLATTEN,
ignore=None, validator=None, silent=None):
""" Registers an Azure CLI Batch Data Plane command. These commands must respond to a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def list_accounts(client, resource_group_name=None):


@transfer_doc(AutoStorageBaseProperties)
def create_account(client, # pylint:disable=too-many-arguments
def create_account(client,
resource_group_name, account_name, location, tags=None, storage_account=None,
keyvault=None, keyvault_url=None):
properties = AutoStorageBaseProperties(storage_account_id=storage_account) \
Expand All @@ -64,7 +64,7 @@ def create_account(client, # pylint:disable=too-many-arguments


@transfer_doc(AutoStorageBaseProperties)
def update_account(client, resource_group_name, account_name, # pylint:disable=too-many-arguments
def update_account(client, resource_group_name, account_name,
tags=None, storage_account=None):
properties = AutoStorageBaseProperties(storage_account_id=storage_account) \
if storage_account else None
Expand Down Expand Up @@ -99,7 +99,7 @@ def login_account(client, resource_group_name, account_name, shared_key_auth=Fal


@transfer_doc(UpdateApplicationParameters)
def update_application(client, # pylint:disable=too-many-arguments
def update_application(client,
resource_group_name, account_name, application_id, allow_updates=None,
display_name=None, default_version=None):
parameters = UpdateApplicationParameters(allow_updates=allow_updates,
Expand Down Expand Up @@ -137,7 +137,7 @@ def _upload_package_blob(package_file, url):


@transfer_doc(ApplicationPackageOperations.create)
def create_application_package(client, # pylint:disable=too-many-arguments
def create_application_package(client,
resource_group_name, account_name, application_id, version,
package_file):
# create application if not exist
Expand Down Expand Up @@ -207,7 +207,7 @@ def action():


@transfer_doc(PoolResizeParameter)
def resize_pool(client, pool_id, target_dedicated=None, # pylint:disable=too-many-arguments
def resize_pool(client, pool_id, target_dedicated=None,
resize_timeout=None, node_deallocation_option=None,
if_match=None, if_none_match=None, if_modified_since=None,
if_unmodified_since=None, abort=False):
Expand All @@ -232,7 +232,7 @@ def action():


@transfer_doc(PoolUpdatePropertiesParameter, StartTask)
def update_pool(client, # pylint:disable=too-many-arguments
def update_pool(client,
pool_id, json_file=None, start_task_command_line=None, certificate_references=None,
application_package_references=None, metadata=None,
start_task_environment_settings=None, start_task_wait_for_success=None,
Expand Down Expand Up @@ -297,7 +297,7 @@ def action():


@transfer_doc(TaskAddParameter, TaskConstraints)
def create_task(client, # pylint:disable=too-many-arguments
def create_task(client,
job_id, json_file=None, task_id=None, command_line=None, resource_files=None,
environment_settings=None, affinity_info=None, max_wall_clock_time=None,
retention_time=None, max_task_retry_count=None,
Expand Down
Loading

0 comments on commit f8d4093

Please sign in to comment.