Skip to content

Commit

Permalink
Merge pull request #12920 from bernt-matthias/topic/lint-select-fix
Browse files Browse the repository at this point in the history
[21.09] fix linter for select inputs
  • Loading branch information
jdavcs committed Nov 19, 2021
2 parents 1b9fd2e + efac31d commit 29f46af
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
10 changes: 6 additions & 4 deletions lib/galaxy/tool_util/linters/inputs.py
Expand Up @@ -139,15 +139,17 @@ def lint_inputs(tool_xml, lint_ctx):
if len({option.attrib.get("value") for option in select_options}) != len(select_options):
lint_ctx.error(f"Select parameter [{param_name}] has multiple options with the same value")

multiple = string_as_bool(param_attrib.get("multiple", "false"))
optional = string_as_bool(param_attrib.get("optional", multiple))
if param_attrib.get("display") == "checkboxes":
if not string_as_bool(param_attrib.get("multiple", "false")):
if not multiple:
lint_ctx.error(f'Select [{param_name}] `display="checkboxes"` is incompatible with `multiple="false"`, remove the `display` attribute')
if not string_as_bool(param_attrib.get("optional", "false")):
if not optional:
lint_ctx.error(f'Select [{param_name}] `display="checkboxes"` is incompatible with `optional="false"`, remove the `display` attribute')
if param_attrib.get("display") == "radio":
if string_as_bool(param_attrib.get("multiple", "false")):
if multiple:
lint_ctx.error(f'Select [{param_name}] display="radio" is incompatible with multiple="true"')
if string_as_bool(param_attrib.get("optional", "false")):
if optional:
lint_ctx.error(f'Select [{param_name}] display="radio" is incompatible with optional="true"')
# TODO: Validate type, much more...

Expand Down
15 changes: 9 additions & 6 deletions test/unit/tool_util/test_tool_linters.py
Expand Up @@ -69,15 +69,18 @@
"""

RADIO_SELECT_INCOMPATIBILITIES = """
<tool name="BWA Mapper" id="bwa" version="1.0.1" is_multi_byte="true" display_interface="true" require_login="true" hidden="true">
<description>The BWA Mapper</description>
<version_command interpreter="python">bwa.py --version</version_command>
<tool>
<inputs>
<param name="radio_select" type="select" display="radio" optional="true" multiple="true">
<option value="1">1</option>
<option value="2">2</option>
</param>
<param name="radio_checkboxes" type="select" display="checkboxes" optional="false" multiple="false">
<param name="checkboxes_select" type="select" display="checkboxes" optional="false" multiple="false">
<option value="1">1</option>
<option value="2">2</option>
</param>
<!-- this must not raise any warning/error since multiple=true implies true as default for optional -->
<param name="checkboxes_select_correct" type="select" display="checkboxes" multiple="true">
<option value="1">1</option>
<option value="2">2</option>
</param>
Expand Down Expand Up @@ -285,8 +288,8 @@
lambda x:
'Select [radio_select] display="radio" is incompatible with optional="true"' in x.error_messages
and 'Select [radio_select] display="radio" is incompatible with multiple="true"' in x.error_messages
and 'Select [radio_checkboxes] `display="checkboxes"` is incompatible with `optional="false"`, remove the `display` attribute' in x.error_messages
and 'Select [radio_checkboxes] `display="checkboxes"` is incompatible with `multiple="false"`, remove the `display` attribute' in x.error_messages
and 'Select [checkboxes_select] `display="checkboxes"` is incompatible with `optional="false"`, remove the `display` attribute' in x.error_messages
and 'Select [checkboxes_select] `display="checkboxes"` is incompatible with `multiple="false"`, remove the `display` attribute' in x.error_messages
and len(x.warn_messages) == 0 and len(x.error_messages) == 4
),
(
Expand Down

0 comments on commit 29f46af

Please sign in to comment.