Skip to content

Commit

Permalink
typing fixes for from_json in basic.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton authored and nsoranzo committed Jul 31, 2024
1 parent a7a93b7 commit 53752cd
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lib/galaxy/tools/parameters/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def __init__(self, tool, input_source):
if self.min is not None or self.max is not None:
self.validators.append(validation.InRangeValidator(None, self.min, self.max))

def from_json(self, value, trans, other_values=None):
def from_json(self, value, trans=None, other_values=None):
other_values = other_values or {}
try:
return int(value)
Expand Down Expand Up @@ -536,7 +536,7 @@ def __init__(self, tool, input_source):
if self.min is not None or self.max is not None:
self.validators.append(validation.InRangeValidator(None, self.min, self.max))

def from_json(self, value, trans, other_values=None):
def from_json(self, value, trans=None, other_values=None):
other_values = other_values or {}
try:
return float(value)
Expand Down Expand Up @@ -992,7 +992,10 @@ def get_legal_names(self, trans, other_values):
"""
return {n: v for n, v, _ in self.get_options(trans, other_values)}

def from_json(self, value, trans, other_values=None, require_legal_value=True):
def from_json(self, value, trans=None, other_values=None):
return self._select_from_json(value, trans, other_values=other_values, require_legal_value=True)

def _select_from_json(self, value, trans, other_values=None, require_legal_value=True):
other_values = other_values or {}
try:
legal_values = self.get_legal_values(trans, other_values, value)
Expand Down Expand Up @@ -1268,7 +1271,7 @@ def __init__(self, tool, input_source):
self.default_value = input_source.get("value", None)
self.is_dynamic = True

def from_json(self, value, trans, other_values=None):
def from_json(self, value, trans=None, other_values=None):
other_values = other_values or {}
if self.multiple:
tag_list = []
Expand All @@ -1290,7 +1293,7 @@ def from_json(self, value, trans, other_values=None):
value = None
# We skip requiring legal values -- this is similar to optional, but allows only subset of datasets to be positive
# TODO: May not actually be required for (nested) collection input ?
return super().from_json(value, trans, other_values, require_legal_value=False)
return super()._select_from_json(value, trans, other_values, require_legal_value=False)

def get_tag_list(self, other_values):
"""
Expand Down Expand Up @@ -1395,7 +1398,7 @@ def to_json(self, value, app, use_security):
return value.strip()
return value

def from_json(self, value, trans, other_values=None):
def from_json(self, value, trans=None, other_values=None):
"""
Label convention prepends column number with a 'c', but tool uses the integer. This
removes the 'c' when entered into a workflow.
Expand Down Expand Up @@ -1710,7 +1713,7 @@ def recurse_options(legal_values, options):
recurse_options(legal_values, self.get_options(trans=trans, other_values=other_values))
return legal_values

def from_json(self, value, trans, other_values=None):
def from_json(self, value, trans=None, other_values=None):
other_values = other_values or {}
legal_values = self.get_legal_values(trans, other_values, value)
if not legal_values and trans.workflow_building_mode:
Expand Down Expand Up @@ -2111,7 +2114,7 @@ def __init__(self, tool, input_source, trans=None):
)
self.conversions.append((name, conv_extension, [conv_type]))

def from_json(self, value, trans, other_values=None):
def from_json(self, value, trans=None, other_values=None):
session = trans.sa_session

other_values = other_values or {}
Expand Down Expand Up @@ -2468,7 +2471,7 @@ def match_multirun_collections(self, trans, history, dataset_collection_matcher)
if match:
yield history_dataset_collection, match.implicit_conversion

def from_json(self, value, trans, other_values=None):
def from_json(self, value, trans=None, other_values=None):
session = trans.sa_session

other_values = other_values or {}
Expand Down

0 comments on commit 53752cd

Please sign in to comment.