Skip to content

Commit e590bc4

Browse files
fix datatypes linter
better consideration of auto and inputs
1 parent 1452581 commit e590bc4

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

lib/galaxy/tool_util/linters/datatypes.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
Union,
77
)
88

9+
from packaging.version import Version
10+
911
# from galaxy import config
1012
from galaxy.tool_util.lint import Linter
1113
from galaxy.util import (
@@ -68,6 +70,7 @@ def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"):
6870
tool_xml = getattr(tool_source, "xml_tree", None)
6971
if not tool_xml:
7072
return
73+
profile = tool_source.parse_profile()
7174
# get Galaxy built-in dataypes
7275
datatypes = _parse_datatypes(DATATYPES_CONF)
7376
# add custom tool data types
@@ -84,15 +87,19 @@ def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"):
8487
formats = elem.get(attrib, "").split(",")
8588
# Certain elements (e.g. `data`) can only have one format. This
8689
# is checked separately by linting against the XSD.
87-
if "auto" in formats:
88-
if elem.tag == "param":
90+
if elem.tag == "param":
91+
if any(format in ["auto", "input"] for format in formats):
8992
lint_ctx.error(
90-
"Format [auto] can not be used for tool or tool test inputs",
93+
"Invalid format (auto or input) in tool or tool test inputs",
9194
linter=cls.name(),
9295
node=elem,
9396
)
94-
continue
97+
continue
9598
for format in formats:
99+
if Version(str(profile)) <= Version("16.04") and format == "input":
100+
continue
101+
if format == "auto":
102+
continue
96103
if format not in datatypes:
97104
lint_ctx.error(
98105
f"Unknown datatype [{format}] used in {elem.tag} element",

lib/galaxy/tool_util/linters/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"):
250250
name = name.split("|")[-1]
251251
xpaths = [f"@name='{name}'", f"@argument='{name}'", f"@argument='-{name}'", f"@argument='--{name}'"]
252252
if "_" in name:
253-
xpaths += [f"@argument='-{name.replace('_', '-')}'", f"@argument='--{name.replace('_', '-')}'"]
253+
xpaths += [f"@argument='{name.replace('_', '-')}'", f"@argument='-{name.replace('_', '-')}'", f"@argument='--{name.replace('_', '-')}'"]
254254
found = False
255255
for xp in xpaths:
256256
inxpath = f".//inputs//param[{xp}]"

test/unit/tool_util/test_tool_linters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2205,7 +2205,7 @@ def test_valid_datatypes(lint_ctx):
22052205
assert "Unknown datatype [collection_format] used in collection" in lint_ctx.error_messages
22062206
assert "Unknown datatype [invalid] used in param" in lint_ctx.error_messages
22072207
assert "Unknown datatype [invalid] used in discover_datasets" in lint_ctx.error_messages
2208-
assert "Format [auto] can not be used for tool or tool test inputs" in lint_ctx.error_messages # 2x
2208+
assert "Invalid format (auto or input) in tool or tool test inputs" in lint_ctx.error_messages # 2x
22092209
assert len(lint_ctx.error_messages) == 8
22102210

22112211

0 commit comments

Comments
 (0)