Skip to content

Commit 15296fd

Browse files
authored
{Misc.} Improve code style and prepare for pylint 2.17 (#26685)
1 parent 7d59f5e commit 15296fd

File tree

44 files changed

+97
-112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+97
-112
lines changed

pylintrc

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ disable=
4747
redundant-u-string-prefix,
4848
raising-bad-type,
4949
unused-private-member,
50-
used-before-assignment
50+
used-before-assignment,
51+
# These rules were added in Pylint >= 2.12, disable them to avoid making retroactive change
52+
missing-timeout,
53+
superfluous-parens,
54+
implicit-str-concat,
55+
unnecessary-dunder-call,
5156

5257
[FORMAT]
5358
max-line-length=120
@@ -61,24 +66,8 @@ init-import=yes
6166
max-locals=25
6267
# Maximum number of branch for function / method body
6368
max-branches=20
69+
# Temporally disable this check as inline disable is not working, see https://github.com/pylint-dev/pylint/issues/8806
70+
max-statements=500
6471

6572
[SIMILARITIES]
6673
min-similarity-lines=10
67-
68-
[BASIC]
69-
# Naming hints based on PEP 8 (https://www.python.org/dev/peps/pep-0008/#naming-conventions).
70-
# Consider these guidelines and not hard rules. Read PEP 8 for more details.
71-
72-
# The invalid-name checker must be **enabled** for these hints to be used.
73-
include-naming-hint=yes
74-
75-
module-name-hint=lowercase (keep short; underscores are discouraged)
76-
const-name-hint=UPPER_CASE_WITH_UNDERSCORES
77-
class-name-hint=CapitalizedWords
78-
class-attribute-name-hint=lower_case_with_underscores
79-
attr-name-hint=lower_case_with_underscores
80-
method-name-hint=lower_case_with_underscores
81-
function-name-hint=lower_case_with_underscores
82-
argument-name-hint=lower_case_with_underscores
83-
variable-name-hint=lower_case_with_underscores
84-
inlinevar-name-hint=lower_case_with_underscores (short is OK)

src/azure-cli-core/azure/cli/core/aaz/_help.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def show(self):
4444
key = self.keys[idx]
4545
if isinstance(schema, AAZObjectArg):
4646
try:
47-
schema = schema[key]
47+
schema = schema[key] # pylint: disable=unsubscriptable-object
4848
except AAZUndefinedValueError:
4949
# show the help of current schema
5050
break

src/azure-cli-core/azure/cli/core/commands/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ def _run_jobs_serially(self, jobs, ids):
724724
expanded_arg, cmd_copy = job
725725
try:
726726
results.append(self._run_job(expanded_arg, cmd_copy))
727-
except(Exception, SystemExit) as ex: # pylint: disable=broad-except
727+
except (Exception, SystemExit) as ex: # pylint: disable=broad-except
728728
exceptions.append((ex, id_arg))
729729
return results, exceptions
730730

src/azure-cli-core/azure/cli/core/extension/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import traceback
99
import json
1010
import re
11-
from distutils.sysconfig import get_python_lib
11+
from distutils.sysconfig import get_python_lib # pylint: disable=deprecated-module
1212

1313
import pkginfo
1414
from knack.config import CLIConfig

src/azure-cli/azure/cli/command_modules/acr/_docker_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ def request_data_from_registry(http_method,
644644
raise RegistryException(
645645
parse_error_message('Failed to request data due to a conflict.', response),
646646
response.status_code)
647-
raise Exception(parse_error_message('Could not {} the requested data.'.format(http_method), response))
647+
raise Exception(parse_error_message('Could not {} the requested data.'.format(http_method), response)) # pylint: disable=broad-exception-raised
648648
except CLIError:
649649
raise
650650
except Exception as e: # pylint: disable=broad-except

src/azure-cli/azure/cli/command_modules/acs/_format.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def _func_set_preview_array(self, versions):
174174
for i, _ in enumerate(versions):
175175
versions[i] = self._func_set_preview(versions[i])
176176
return versions
177-
except(TypeError, ValueError):
177+
except (TypeError, ValueError):
178178
return versions
179179

180180
@functions.signature({'types': ['string']})
@@ -184,7 +184,7 @@ def _func_set_preview(self, version): # pylint: disable=no-self-use
184184
if preview_versions.get(version, False):
185185
return version + '(preview)'
186186
return version
187-
except(TypeError, ValueError):
187+
except (TypeError, ValueError):
188188
return version
189189

190190
return CustomFunctions()

src/azure-cli/azure/cli/command_modules/acs/_loadbalancer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Licensed under the MIT License. See License.txt in the project root for license information.
44
# --------------------------------------------------------------------------------------------
55

6-
from distutils.version import StrictVersion
6+
from distutils.version import StrictVersion # pylint: disable=deprecated-module
77
from types import SimpleNamespace
88

99
from knack.log import get_logger

src/azure-cli/azure/cli/command_modules/acs/_roleassignments.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,11 @@ def ensure_aks_acr_role_assignment(cmd, assignee, registry_id, detach=False, is_
309309
if not delete_role_assignments(
310310
cmd.cli_ctx, "acrpull", assignee, scope=registry_id, is_service_principal=is_service_principal
311311
):
312-
raise AzCLIError("Could not delete role assignments for ACR. " "Are you an Owner on this subscription?")
312+
raise AzCLIError("Could not delete role assignments for ACR. Are you an Owner on this subscription?")
313313
return
314314

315315
if not add_role_assignment(cmd, "acrpull", assignee, scope=registry_id, is_service_principal=is_service_principal):
316-
raise AzCLIError("Could not create a role assignment for ACR. " "Are you an Owner on this subscription?")
316+
raise AzCLIError("Could not create a role assignment for ACR. Are you an Owner on this subscription?")
317317
return
318318

319319

src/azure-cli/azure/cli/command_modules/acs/base_decorator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def items(self):
122122
return self.__store.items()
123123

124124
def __format_count(self):
125-
untouched_keys = [x for x in self.__store.keys() if x not in self.__count.keys()]
125+
untouched_keys = [x for x in self.__store if x not in self.__count]
126126
for k in untouched_keys:
127127
self.__count[k] = 0
128128

src/azure-cli/azure/cli/command_modules/acs/custom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import uuid
2323
import webbrowser
2424
import zipfile
25-
from distutils.version import StrictVersion
25+
from distutils.version import StrictVersion # pylint: disable=deprecated-module
2626
from urllib.error import URLError
2727
from urllib.request import urlopen
2828

0 commit comments

Comments
 (0)