diff --git a/.pylintrc b/.pylintrc index 51f762763..7cbbb02c7 100644 --- a/.pylintrc +++ b/.pylintrc @@ -10,7 +10,10 @@ disable= too-few-public-methods, too-many-arguments, consider-using-f-string, - unspecified-encoding + unspecified-encoding, + # These rules were added in Pylint >= 2.12, disable them to avoid making retroactive change + broad-exception-raised, + missing-timeout [TYPECHECK] # For Azure CLI extensions, we ignore some import errors as they'll be available in the environment of the CLI diff --git a/azdev/config/cli.flake8 b/azdev/config/cli.flake8 index bbcee659e..6073cde0b 100644 --- a/azdev/config/cli.flake8 +++ b/azdev/config/cli.flake8 @@ -2,13 +2,20 @@ max-line-length = 120 max-complexity = 10 ignore = - E501, # line too long, it is covered by pylint - E722, # bare except, bad practice, to be removed in the future - F401, # imported but unused, too many violations, to be removed in the future - F811, # redefinition of unused, to be removed in the future - C901 # code flow is too complex, too many violations, to be removed in the future - W503 # line break before binary operator - W504 # line break after binary operator effect on readability is subjective + # line too long, it is covered by pylint + E501, + # bare except, bad practice, to be removed in the future + E722, + # imported but unused, too many violations, to be removed in the future + F401, + # redefinition of unused, to be removed in the future + F811, + # code flow is too complex, too many violations, to be removed in the future + C901, + # line break before binary operator + W503, + # line break after binary operator effect on readability is subjective + W504 exclude = azure_cli_bdist_wheel.py build diff --git a/azdev/config/cli_pylintrc b/azdev/config/cli_pylintrc index 79248057b..2554cb0f5 100644 --- a/azdev/config/cli_pylintrc +++ b/azdev/config/cli_pylintrc @@ -25,7 +25,10 @@ disable= useless-import-alias, useless-suppression, import-outside-toplevel, - wrong-import-order + wrong-import-order, + # These rules were added in Pylint >= 2.12, disable them to avoid making retroactive change + broad-exception-raised, + missing-timeout [FORMAT] max-line-length=120 @@ -42,21 +45,3 @@ max-branches=20 [SIMILARITIES] min-similarity-lines=10 - -[BASIC] -# Naming hints based on PEP 8 (https://www.python.org/dev/peps/pep-0008/#naming-conventions). -# Consider these guidelines and not hard rules. Read PEP 8 for more details. - -# The invalid-name checker must be **enabled** for these hints to be used. -include-naming-hint=yes - -module-name-hint=lowercase (keep short; underscores are discouraged) -const-name-hint=UPPER_CASE_WITH_UNDERSCORES -class-name-hint=CapitalizedWords -class-attribute-name-hint=lower_case_with_underscores -attr-name-hint=lower_case_with_underscores -method-name-hint=lower_case_with_underscores -function-name-hint=lower_case_with_underscores -argument-name-hint=lower_case_with_underscores -variable-name-hint=lower_case_with_underscores -inlinevar-name-hint=lower_case_with_underscores (short is OK) diff --git a/azdev/config/ext.flake8 b/azdev/config/ext.flake8 index 99f863854..947c734f4 100644 --- a/azdev/config/ext.flake8 +++ b/azdev/config/ext.flake8 @@ -2,13 +2,20 @@ max-line-length = 120 max-complexity = 10 ignore = - E501, # line too long, it is covered by pylint - E722, # bare except, bad practice, to be removed in the future - F401, # imported but unused, too many violations, to be removed in the future - F811, # redefinition of unused, to be removed in the future - C901 # code flow is too complex, too many violations, to be removed in the future - W503 # line break before binary operator - W504 # line break after binary operator effect on readability is subjective + # line too long, it is covered by pylint + E501, + # bare except, bad practice, to be removed in the future + E722, + # imported but unused, too many violations, to be removed in the future + F401, + # redefinition of unused, to be removed in the future + F811, + # code flow is too complex, too many violations, to be removed in the future + C901, + # line break before binary operator + W503, + # line break after binary operator effect on readability is subjective + W504 exclude = */vendored_sdks docs diff --git a/azdev/config/ext_pylintrc b/azdev/config/ext_pylintrc index eae463151..f0a07eb14 100644 --- a/azdev/config/ext_pylintrc +++ b/azdev/config/ext_pylintrc @@ -16,7 +16,10 @@ disable= too-many-arguments, invalid-name, duplicate-code, - import-outside-toplevel + import-outside-toplevel, + # These rules were added in Pylint >= 2.12, disable them to avoid making retroactive change + broad-exception-raised, + missing-timeout [TYPECHECK] # For Azure CLI extensions, we ignore some import errors as they'll be available in the environment of the CLI @@ -37,21 +40,3 @@ max-branches=20 [SIMILARITIES] min-similarity-lines=10 - -[BASIC] -# Naming hints based on PEP 8 (https://www.python.org/dev/peps/pep-0008/#naming-conventions). -# Consider these guidelines and not hard rules. Read PEP 8 for more details. - -# The invalid-name checker must be **enabled** for these hints to be used. -include-naming-hint=yes - -module-name-hint=lowercase (keep short; underscores are discouraged) -const-name-hint=UPPER_CASE_WITH_UNDERSCORES -class-name-hint=CapitalizedWords -class-attribute-name-hint=lower_case_with_underscores -attr-name-hint=lower_case_with_underscores -method-name-hint=lower_case_with_underscores -function-name-hint=lower_case_with_underscores -argument-name-hint=lower_case_with_underscores -variable-name-hint=lower_case_with_underscores -inlinevar-name-hint=lower_case_with_underscores (short is OK) diff --git a/azdev/operations/extensions/util.py b/azdev/operations/extensions/util.py index b0b916564..88c0fffbe 100644 --- a/azdev/operations/extensions/util.py +++ b/azdev/operations/extensions/util.py @@ -69,7 +69,7 @@ def get_whl_from_url(url, filename, tmp_dir, whl_cache=None): if url in whl_cache: return whl_cache[url] import requests - r = requests.get(url, stream=True) + r = requests.get(url, stream=True, timeout=10) try: assert r.status_code == 200, "Request to {} failed with {}".format(url, r.status_code) except AssertionError: diff --git a/azdev/operations/help/refdoc/common/directives.py b/azdev/operations/help/refdoc/common/directives.py index 92d4e2fc6..d07bad095 100644 --- a/azdev/operations/help/refdoc/common/directives.py +++ b/azdev/operations/help/refdoc/common/directives.py @@ -37,13 +37,13 @@ def handle_signature(self, sig, signode): signode += addnodes.desc_addname(sig, sig) return sig - def needs_arglist(self): # pylint: disable=no-self-use + def needs_arglist(self): return False def add_target_and_index(self, name, sig, signode): signode['ids'].append(name) - def get_index_text(self, modname, name): # pylint: disable=unused-argument, no-self-use + def get_index_text(self, modname, name): # pylint: disable=unused-argument return name @@ -53,7 +53,7 @@ class CliGroupDirective(CliBaseDirective): Field('docsource', label='Doc Source', has_arg=False, names=('docsource', 'documentsource')), Field('deprecated', label='Deprecated', has_arg=False, - names=('deprecated')) + names=('deprecated',)) ]) @@ -63,7 +63,7 @@ class CliCommandDirective(CliBaseDirective): Field('docsource', label='Doc Source', has_arg=False, names=('docsource', 'documentsource')), Field('deprecated', label='Deprecated', has_arg=False, - names=('deprecated')) + names=('deprecated',)) ]) @@ -71,15 +71,15 @@ class CliArgumentDirective(CliBaseDirective): doc_field_types = copy.copy(_CLI_FIELD_TYPES) doc_field_types.extend([ Field('required', label='Required', has_arg=False, - names=('required')), + names=('required',)), Field('values', label='Allowed values', has_arg=False, names=('values', 'choices', 'options')), Field('default', label='Default value', has_arg=False, - names=('default')), + names=('default',)), Field('source', label='Values from', has_arg=False, names=('source', 'sources')), Field('deprecated', label='Deprecated', has_arg=False, - names=('deprecated')) + names=('deprecated',)) ]) diff --git a/azdev/operations/performance.py b/azdev/operations/performance.py index c705e822d..eb6377dd8 100644 --- a/azdev/operations/performance.py +++ b/azdev/operations/performance.py @@ -237,7 +237,7 @@ def _benchmark_cmd_staticstic(time_series: list): avg_time = sum(time_series) / size std_deviation = sqrt( - sum([(t - avg_time) * (t - avg_time) for t in time_series]) / size + sum((t - avg_time) * (t - avg_time) for t in time_series) / size ) return { diff --git a/azdev/operations/pypi.py b/azdev/operations/pypi.py index 55009f47f..bf5b7053f 100644 --- a/azdev/operations/pypi.py +++ b/azdev/operations/pypi.py @@ -8,7 +8,7 @@ import re import sys -from distutils.version import LooseVersion # pylint:disable=import-error,no-name-in-module +from distutils.version import LooseVersion # pylint:disable=import-error,no-name-in-module,deprecated-module from docutils import core, io from knack.log import get_logger diff --git a/azdev/operations/tests/test_benchmark.py b/azdev/operations/tests/test_benchmark.py index 327aabdf5..7f63e6556 100644 --- a/azdev/operations/tests/test_benchmark.py +++ b/azdev/operations/tests/test_benchmark.py @@ -25,7 +25,7 @@ def test_statistic_ok(self): max_num = round(rands[-1], 4) min_num = round(rands[0], 4) avg_num = round(sum(rands) / len(rands), 4) - std_num = round(sqrt(sum([(t - avg_num) ** 2 for t in rands]) / len(rands)), 4) + std_num = round(sqrt(sum((t - avg_num) ** 2 for t in rands) / len(rands)), 4) stats = _benchmark_cmd_staticstic(rands) diff --git a/setup.py b/setup.py index 7c65c6023..6a00e387d 100644 --- a/setup.py +++ b/setup.py @@ -72,7 +72,7 @@ 'gitpython', 'jinja2', 'knack', - 'pylint==2.11.1', + 'pylint>=2.12,<3', 'pytest-xdist', # depends on pytest-forked 'pytest-forked', 'pytest>=5.0.0',