From 9cae33ffa8bd7cdb700ede687d0ec178a6937926 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Tue, 26 Nov 2024 17:14:35 +0100 Subject: [PATCH 1/2] only match filters that are descendants or data/collection otherwise action filters are also checked which results in an error since there is not text content. --- lib/galaxy/tool_util/linters/output.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/tool_util/linters/output.py b/lib/galaxy/tool_util/linters/output.py index e9ab7c4aaf4e..e42c797dca0b 100644 --- a/lib/galaxy/tool_util/linters/output.py +++ b/lib/galaxy/tool_util/linters/output.py @@ -83,7 +83,7 @@ def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"): tool_xml = getattr(tool_source, "xml_tree", None) if not tool_xml: return - for filter in tool_xml.findall("./outputs//filter"): + for filter in tool_xml.findall("./outputs/*/filter"): try: ast.parse(filter.text, mode="eval") except Exception as e: From a587336eddf9c4fc19a349adf393a4747537c4b2 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Tue, 26 Nov 2024 17:18:44 +0100 Subject: [PATCH 2/2] strip text otherwise the parser gives an indentation error also: we strip the text alo in the application --- lib/galaxy/tool_util/linters/output.py | 2 +- test/unit/tool_util/test_tool_linters.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/tool_util/linters/output.py b/lib/galaxy/tool_util/linters/output.py index e42c797dca0b..b1d48fd2a60d 100644 --- a/lib/galaxy/tool_util/linters/output.py +++ b/lib/galaxy/tool_util/linters/output.py @@ -85,7 +85,7 @@ def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"): return for filter in tool_xml.findall("./outputs/*/filter"): try: - ast.parse(filter.text, mode="eval") + ast.parse(filter.text.strip(), mode="eval") except Exception as e: lint_ctx.warn( f"Filter '{filter.text}' is no valid expression: {str(e)}", diff --git a/test/unit/tool_util/test_tool_linters.py b/test/unit/tool_util/test_tool_linters.py index ea7f4cd8d5d5..867e85dc2ba3 100644 --- a/test/unit/tool_util/test_tool_linters.py +++ b/test/unit/tool_util/test_tool_linters.py @@ -656,7 +656,7 @@ an invalid condition - an and condition + an and condition another invalid condition