mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #9156 from mvdbeek/restore_optional_param_none
[19.05] Cast to None for optional params if not comparing strings
This commit is contained in:
@@ -83,8 +83,11 @@ class InputValueWrapper(ToolParameterValueWrapper):
|
||||
if self.input.type == 'boolean' and isinstance(other, string_types):
|
||||
return str(self)
|
||||
# For backward compatibility, allow `$wrapper != ""` for optional non-text param
|
||||
if self.input.optional and self.value is None and self.input.type != 'boolean':
|
||||
return str(self)
|
||||
if self.input.optional and self.value is None:
|
||||
if isinstance(other, string_types):
|
||||
return str(self)
|
||||
else:
|
||||
return None
|
||||
cast = {
|
||||
'text': str,
|
||||
'integer': int,
|
||||
|
||||
@@ -161,6 +161,7 @@ def test_input_value_wrapper_comparison_optional(tool):
|
||||
wrapper = valuewrapper(tool, None, 'integer', optional=True)
|
||||
assert wrapper != 1
|
||||
assert str(wrapper) == ""
|
||||
assert wrapper == None # noqa: E711
|
||||
wrapper = valuewrapper(tool, None, "boolean")
|
||||
assert bool(wrapper) is False, wrapper
|
||||
assert str(wrapper) == 'falsevalue'
|
||||
|
||||
Reference in New Issue
Block a user