diff options
author | say <say@yandex-team.com> | 2023-03-07 18:48:42 +0300 |
---|---|---|
committer | say <say@yandex-team.com> | 2023-03-07 18:48:42 +0300 |
commit | 78605f0e58d4d527c9164ff4cb352708b42e1e78 (patch) | |
tree | 761805b4e7452cf63c64c273bf8c63b8b1455281 | |
parent | 5d02847e8749429797930fa6cae8e06d2d48ea11 (diff) | |
download | ydb-78605f0e58d4d527c9164ff4cb352708b42e1e78.tar.gz |
Prepare custom_lint for flake8:
- add lint_name, global_resource and extra_param options
- add option to split lint tests in chunks (FILE_PROCESSING_TIME)
- rename '--configs' option to '--config' to be consistent with other
option names
-rw-r--r-- | library/python/testing/custom_linter_util/linter_params.py | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/library/python/testing/custom_linter_util/linter_params.py b/library/python/testing/custom_linter_util/linter_params.py index b82e04455b..522e6da9ed 100644 --- a/library/python/testing/custom_linter_util/linter_params.py +++ b/library/python/testing/custom_linter_util/linter_params.py @@ -9,8 +9,11 @@ class LinterArgs: source_root: str project_path: str output_path: str + lint_name: str depends: dict[str, str] + global_resources: dict[str, str] configs: list[str] + extra_params: dict[str, str] report_file: str files: list[str] @@ -21,8 +24,11 @@ def get_params(raw_args: Optional[list[str]] = None) -> LinterArgs: parser.add_argument("--source-root") parser.add_argument("--project-path") parser.add_argument("--output-path") + parser.add_argument("--lint-name", default="") parser.add_argument("--depends", action="append") - parser.add_argument("--configs", action="append") + parser.add_argument("--global-resource", action="append", dest="global_resources") + parser.add_argument("--config", action="append", dest="configs") + parser.add_argument("--extra-param", action="append", dest="extra_params") parser.add_argument("--report-file", default="-") parser.add_argument("files", nargs="*") args = parser.parse_args(raw_args) @@ -33,20 +39,22 @@ def get_params(raw_args: Optional[list[str]] = None) -> LinterArgs: source_root = params["source_root"] project_path = params["project_path"] output_path = params["output_path"] + lint_name = params.get("lint_name", "") depends = params.get("depends", {}) + global_resources = params.get("global_resources", {}) configs = params.get("configs", []) + extra_params = params.get("extra_params", {}) report_file = params["report_file"] files = params["files"] else: source_root = args.source_root project_path = args.project_path output_path = args.output_path - depends = {} - if args.depends: - for dep in args.depends: - rel_path, abs_path = dep.split(":", 1) - depends[rel_path] = abs_path + lint_name = args.lint_name + depends = _parse_kv_arg(args.depends, ":") + global_resources = _parse_kv_arg(args.global_resources, ":") configs = args.configs if args.configs else [] + extra_params = _parse_kv_arg(args.extra_params, "=") report_file = args.report_file files = args.files @@ -54,8 +62,20 @@ def get_params(raw_args: Optional[list[str]] = None) -> LinterArgs: source_root=source_root, project_path=project_path, output_path=output_path, + lint_name=lint_name, depends=depends, + global_resources=global_resources, configs=configs, + extra_params=extra_params, report_file=report_file, files=files, ) + + +def _parse_kv_arg(arg, sep): + result = {} + if arg: + for item in arg: + var, val = item.split(sep, 1) + result[var] = val + return result |