Fix pylint issues
This commit is contained in:
Родитель
dc09d44bae
Коммит
0a846e38e4
|
@ -0,0 +1,43 @@
|
|||
[MASTER]
|
||||
reports=no
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
# For all codes, run 'pylint --list-msgs' or go to 'https://pylint.readthedocs.io/en/latest/reference_guide/features.html'
|
||||
# locally-disabled: Warning locally suppressed using disable-msg
|
||||
# cyclic-import: because of https://github.com/PyCQA/pylint/issues/850
|
||||
# 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=missing-docstring
|
||||
|
||||
[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
|
||||
|
||||
[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)
|
|
@ -1,3 +1,4 @@
|
|||
PyYAML==3.12
|
||||
requests==2.18.4
|
||||
tabulate==0.8.2
|
||||
pylint==1.8.1
|
||||
|
|
|
@ -2,4 +2,3 @@
|
|||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
# --------------------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -4,13 +4,9 @@
|
|||
# --------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
from a01.cli import setup_commands
|
||||
from a01.common import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
from a01.cli import setup_commands
|
||||
|
||||
__import__('a01.runs')
|
||||
__import__('a01.tasks')
|
||||
parser = setup_commands()
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import argparse
|
||||
import inspect
|
||||
from typing import Callable, Collection, Set
|
||||
from typing import Callable, Collection
|
||||
|
||||
from a01.common import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
logger = get_logger(__name__) # pylint: disable=invalid-name
|
||||
|
||||
command_table = dict()
|
||||
COMMAND_TABLE = dict()
|
||||
|
||||
|
||||
def cmd(name: str, desc: str = None):
|
||||
|
@ -17,7 +17,7 @@ def cmd(name: str, desc: str = None):
|
|||
raise SyntaxError(f'Duplicate @cmd decorator on {func}')
|
||||
|
||||
command_definition = CommandDefinition(name, func, desc)
|
||||
command_table[name] = command_definition
|
||||
COMMAND_TABLE[name] = command_definition
|
||||
|
||||
argument_definitions = getattr(func, '__argument_definitions', None)
|
||||
if argument_definitions:
|
||||
|
@ -25,7 +25,7 @@ def cmd(name: str, desc: str = None):
|
|||
command_definition.add_argument(each)
|
||||
delattr(func, '__argument_definitions')
|
||||
|
||||
setattr(func, '__command_definition', command_table[name])
|
||||
setattr(func, '__command_definition', COMMAND_TABLE[name])
|
||||
|
||||
return func
|
||||
|
||||
|
@ -57,7 +57,7 @@ def setup_commands() -> argparse.ArgumentParser:
|
|||
parser.set_defaults(func=lambda _: parser.print_help())
|
||||
root = CommandNode(parser=parser)
|
||||
|
||||
for name, definition in command_table.items():
|
||||
for name, definition in COMMAND_TABLE.items():
|
||||
logger.info(f'add [{name}] to command tree')
|
||||
node = root
|
||||
for part in name.split(' '):
|
||||
|
@ -70,7 +70,7 @@ def setup_commands() -> argparse.ArgumentParser:
|
|||
return parser
|
||||
|
||||
|
||||
class ArgumentDefinition(object):
|
||||
class ArgumentDefinition(object): # pylint: disable=too-few-public-methods
|
||||
def __init__(self, dest: str, positional: bool = False, option: Collection[str] = None, **kwargs) -> None:
|
||||
self.dest = dest
|
||||
self.positional = positional
|
||||
|
@ -98,7 +98,7 @@ class ArgumentDefinition(object):
|
|||
kwargs['type'] = bool
|
||||
else:
|
||||
kwargs['action'] = 'store_false' if parameter_def.default else 'store_true'
|
||||
elif type(annotation) == list:
|
||||
elif type(annotation) == list: # pylint: disable=unidiomatic-typecheck
|
||||
kwargs['nargs'] = '+' if self.positional else '*'
|
||||
else:
|
||||
logger.warning(f'@arg: Unknown annotation type {annotation} on {self.dest}')
|
||||
|
@ -194,5 +194,4 @@ class CommandNode(object):
|
|||
def __repr__(self) -> str:
|
||||
if self.parent:
|
||||
return f'{self.parent.__repr__()} -> {self.name}'
|
||||
else:
|
||||
return 'root'
|
||||
return 'root'
|
||||
|
|
|
@ -19,7 +19,7 @@ from a01.common import get_store_uri, get_logger
|
|||
from a01.tasks import get_task
|
||||
from a01.cli import cmd, arg
|
||||
|
||||
logger = get_logger(__name__)
|
||||
logger = get_logger(__name__) # pylint: disable=invalid-name
|
||||
|
||||
|
||||
@cmd('get runs', desc='Retrieve the runs.')
|
||||
|
@ -74,7 +74,6 @@ def get_run(run_id: str, log: bool = False) -> None:
|
|||
print()
|
||||
print('Task details:')
|
||||
print()
|
||||
# TODO: refectory, this is a bad pattern
|
||||
get_task(argparse.Namespace(id=[f[0] for f in failure], log=True, run=id))
|
||||
|
||||
|
||||
|
@ -90,7 +89,8 @@ def get_run(run_id: str, log: bool = False) -> None:
|
|||
help='The kubernete secret represents the service principal for live test.')
|
||||
@arg('storage_secret', option=('--storage', '--log-storage-secret'),
|
||||
help='The kubernete secret represents the Azure Storage Account credential for logging')
|
||||
def schedule_run(image: str, path_prefix: str = None, from_failures: str = None, dry_run: bool = False,
|
||||
def schedule_run(image: str, # pylint: disable=too-many-arguments
|
||||
path_prefix: str = None, from_failures: str = None, dry_run: bool = False,
|
||||
live: bool = False, parallelism: int = 3, sp_secret: str = 'azurecli-live-sp',
|
||||
storage_secret: str = 'azurecli-test-storage') -> None:
|
||||
@functools.lru_cache(maxsize=1)
|
||||
|
@ -158,8 +158,8 @@ def schedule_run(image: str, path_prefix: str = None, from_failures: str = None,
|
|||
sys.exit(1)
|
||||
return run_id
|
||||
|
||||
def config_job(parallelism: int, image_name: str, run_id: str, live: bool, storage_secret: str,
|
||||
sp_secret: str) -> dict:
|
||||
def config_job(parallelism: int, # pylint: disable=too-many-arguments
|
||||
image_name: str, run_id: str, live: bool, storage_secret: str, sp_secret: str) -> dict:
|
||||
job = f'azurecli-test-{base64.b32encode(os.urandom(12)).decode("utf-8").lower()}'.rstrip('=')
|
||||
|
||||
environment_variables = [
|
||||
|
@ -217,8 +217,8 @@ def schedule_run(image: str, path_prefix: str = None, from_failures: str = None,
|
|||
|
||||
def post_job(config: dict) -> str:
|
||||
_, config_file = tempfile.mkstemp(text=True)
|
||||
with open(config_file, 'w') as f:
|
||||
yaml.dump(config, f, default_flow_style=False)
|
||||
with open(config_file, 'w') as config_file_handle:
|
||||
yaml.dump(config, config_file_handle, default_flow_style=False)
|
||||
logger.info(f'Temp config file saved at {config_file}')
|
||||
|
||||
try:
|
||||
|
|
|
@ -2,9 +2,7 @@ import requests
|
|||
import tabulate
|
||||
|
||||
import a01.cli
|
||||
from a01.common import get_logger, get_store_uri, LOG_FILE
|
||||
|
||||
logger = get_logger(__name__)
|
||||
from a01.common import get_store_uri, LOG_FILE
|
||||
|
||||
|
||||
@a01.cli.cmd(name='get task', desc='Retrieve tasks information.')
|
||||
|
|
Загрузка…
Ссылка в новой задаче