Unverified Commit c142228e authored by Marius van den Beek's avatar Marius van den Beek Committed by GitHub
Browse files

Merge pull request #19757 from bernt-matthias/fix-dataypes-linter-auto

[24.2] Fix dataypes linter: allow auto for output tags
parents a209a8b9 188a922e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -78,6 +78,16 @@ class ValidDatatypes(Linter):
        for attrib in ["format", "ftype", "ext"]:
            for elem in tool_xml.findall(f".//*[@{attrib}]"):
                formats = elem.get(attrib, "").split(",")
                # Certain elements (e.g. `data`) can only have one format. This
                # is checked separately by linting against the XSD.
                if "auto" in formats:
                    if elem.tag == "param":
                        lint_ctx.error(
                            "Format [auto] can not be used for tool or tool test inputs",
                            linter=cls.name(),
                            node=elem,
                        )
                    continue
                for format in formats:
                    if format not in datatypes:
                        lint_ctx.error(
+5 −1
Original line number Diff line number Diff line
@@ -2029,8 +2029,10 @@ VALID_DATATYPES = """
        <param name="adata" type="data" format="txt"/>
        <param name="bdata" type="data" format="invalid,fasta,custom"/>
        <param name="fdata" type="data" format="fasta.gz"/>
        <param name="auto_input" type="data" format="auto"/>
    </inputs>
    <outputs>
        <data name="autoformat" format="auto"/>
        <data name="name" format="another_invalid">
            <change_format>
                <when input="input_text" value="foo" format="just_another_invalid"/>
@@ -2045,6 +2047,7 @@ VALID_DATATYPES = """
        <test>
            <param name="adata" ftype="txt"/>
            <param name="bdata" ftype="invalid"/>
            <param name="auto_test_input" ftype="auto"/>
        </test>
    </tests>
</tool>
@@ -2082,7 +2085,8 @@ def test_valid_datatypes(lint_ctx):
    assert "Unknown datatype [collection_format] used in collection" in lint_ctx.error_messages
    assert "Unknown datatype [invalid] used in param" in lint_ctx.error_messages
    assert "Unknown datatype [invalid] used in discover_datasets" in lint_ctx.error_messages
    assert len(lint_ctx.error_messages) == 6
    assert "Format [auto] can not be used for tool or tool test inputs" in lint_ctx.error_messages  # 2x
    assert len(lint_ctx.error_messages) == 8


DATA_MANAGER = """<tool id="test_dm" name="test dm" version="1" tool_type="manage_data">