From f322c97829a297e39348a0b5470df06530e8d89f Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Fri, 15 Dec 2023 14:32:35 +0100 Subject: [PATCH] planemo lint: add --skip_file new option allowing to specify one or more files listing linters to skip --- planemo/commands/cmd_lint.py | 2 +- planemo/commands/cmd_shed_lint.py | 2 +- planemo/lint.py | 10 +++++++++- planemo/options.py | 18 ++++++++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/planemo/commands/cmd_lint.py b/planemo/commands/cmd_lint.py index 23dcf4e06..2c22b5710 100644 --- a/planemo/commands/cmd_lint.py +++ b/planemo/commands/cmd_lint.py @@ -14,7 +14,7 @@ @options.report_level_option() @options.report_xunit() @options.fail_level_option() -@options.skip_option() +@options.skip_options() @options.lint_xsd_option() @options.recursive_option() @click.option( diff --git a/planemo/commands/cmd_shed_lint.py b/planemo/commands/cmd_shed_lint.py index beb413580..2571ac417 100644 --- a/planemo/commands/cmd_shed_lint.py +++ b/planemo/commands/cmd_shed_lint.py @@ -13,7 +13,7 @@ @options.shed_realization_options() @options.report_level_option() @options.fail_level_option() -@options.skip_option() +@options.skip_options() @options.click.option( "--tools", is_flag=True, default=False, help=("Lint tools discovered in the process of linting repositories.") ) diff --git a/planemo/lint.py b/planemo/lint.py index 25a0a9c7f..a8df3504a 100644 --- a/planemo/lint.py +++ b/planemo/lint.py @@ -20,8 +20,16 @@ def build_lint_args(ctx, **kwds): skip = ctx.global_config.get("lint_skip", "") if isinstance(skip, list): skip = ",".join(skip) - skip_types = [s.strip() for s in skip.split(",")] + + for skip_file in kwds.get("skip_file", []): + with open(skip_file) as f: + for line in f.readlines(): + line = line.strip() + if not line or line.startswith("#"): + continue + skip_types.append(line) + lint_args = dict( level=report_level, fail_level=fail_level, diff --git a/planemo/options.py b/planemo/options.py index b64d9c4e3..7050aed8a 100644 --- a/planemo/options.py +++ b/planemo/options.py @@ -1384,6 +1384,13 @@ def report_xunit(): ) +def skip_options(): + return _compose( + skip_option(), + skip_file_option(), + ) + + def skip_option(): return planemo_option( "-s", @@ -1397,6 +1404,17 @@ def skip_option(): ) +def skip_file_option(): + return planemo_option( + "--skip_file", + type=click.Path(exists=True, file_okay=True, dir_okay=False, resolve_path=True), + multiple=True, + help=( + "File containing a list of lint tests to skip" + ), + ) + + def fail_level_option(): return planemo_option("--fail_level", type=click.Choice(["warn", "error"]), default="warn")