From b3a12b90afde1a2dada88585bbfd467655097b9f Mon Sep 17 00:00:00 2001 From: John Chilton Date: Sun, 11 Aug 2024 10:14:15 -0400 Subject: [PATCH] mypy fixes... --- lib/galaxy/tool_util/parameters/case.py | 4 ++-- lib/galaxy/tool_util/parameters/factory.py | 4 ++-- .../tool_util/parameters/scripts/validate_test_cases.py | 4 ++-- lib/galaxy/tool_util/verify/parse.py | 2 +- test/unit/tool_util/test_parameter_test_cases.py | 3 ++- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/galaxy/tool_util/parameters/case.py b/lib/galaxy/tool_util/parameters/case.py index 5c79bbbb7974..987196520f60 100644 --- a/lib/galaxy/tool_util/parameters/case.py +++ b/lib/galaxy/tool_util/parameters/case.py @@ -74,7 +74,7 @@ def to_dict(self): } -def legacy_from_string(parameter: ToolParameterT, value: str, warnings: List[str], profile: str) -> Any: +def legacy_from_string(parameter: ToolParameterT, value: Optional[Any], warnings: List[str], profile: str) -> Any: """Convert string values in XML test cases into typed variants. This should only be used when parsing XML test cases into a TestCaseToolState object. @@ -131,7 +131,7 @@ def test_case_state( warnings: List[str] = [] inputs: ToolSourceTestInputs = test_dict["inputs"] unhandled_inputs = [] - state = {} + state: Dict[str, Any] = {} handled_inputs = _merge_level_into_state(tool_parameter_bundle, inputs, state, profile, warnings, None) diff --git a/lib/galaxy/tool_util/parameters/factory.py b/lib/galaxy/tool_util/parameters/factory.py index f2145ef2e571..c7237ea76cb4 100644 --- a/lib/galaxy/tool_util/parameters/factory.py +++ b/lib/galaxy/tool_util/parameters/factory.py @@ -211,7 +211,7 @@ def _from_input_source_galaxy(input_source: InputSource) -> ToolParameterT: Union[BooleanParameterModel, SelectParameterModel], _from_input_source_galaxy(test_param_input_source) ) whens = [] - default_value = cond_test_parameter_default_value(test_parameter) + default_test_value = cond_test_parameter_default_value(test_parameter) for value, case_inputs_sources in input_source.parse_when_input_sources(): if isinstance(test_parameter, BooleanParameterModel): # TODO: investigate truevalue/falsevalue when... @@ -221,7 +221,7 @@ def _from_input_source_galaxy(input_source: InputSource) -> ToolParameterT: tool_parameter_models = input_models_for_page(case_inputs_sources) is_default_when = False - if typed_value == default_value: + if typed_value == default_test_value: is_default_when = True whens.append( ConditionalWhen(discriminator=value, parameters=tool_parameter_models, is_default_when=is_default_when) diff --git a/lib/galaxy/tool_util/parameters/scripts/validate_test_cases.py b/lib/galaxy/tool_util/parameters/scripts/validate_test_cases.py index ef2e614f977e..8c920a225cc9 100644 --- a/lib/galaxy/tool_util/parameters/scripts/validate_test_cases.py +++ b/lib/galaxy/tool_util/parameters/scripts/validate_test_cases.py @@ -51,7 +51,7 @@ def arg_parser() -> argparse.ArgumentParser: @dataclass class ToolTestValidationResults: tool_id: str - tool_version: str + tool_version: Optional[str] tool_profile: str tool_path: str results: List[TestCaseStateValidationResult] @@ -103,7 +103,7 @@ def validate_tool(tool_path, latest) -> ToolTestValidationResults: load_error = e results = [] return ToolTestValidationResults( - tool_source.parse_id(), + tool_id, tool_source.parse_version(), tool_source.parse_profile(), tool_path, diff --git a/lib/galaxy/tool_util/verify/parse.py b/lib/galaxy/tool_util/verify/parse.py index fd766360fe47..be17d12366e1 100644 --- a/lib/galaxy/tool_util/verify/parse.py +++ b/lib/galaxy/tool_util/verify/parse.py @@ -156,7 +156,7 @@ def _description_from_tool_source( return ToolTestDescription.from_tool_source_dict(processed_test_dict) -def _tool_id_and_version(tool_source: ToolSource, tool_guid: Optional[str]) -> Tuple[str, Optional[str]]: +def _tool_id_and_version(tool_source: ToolSource, tool_guid: Optional[str]) -> Tuple[str, str]: tool_id = tool_guid or tool_source.parse_id() assert tool_id tool_version = parse_tool_version_with_defaults(tool_id, tool_source) diff --git a/test/unit/tool_util/test_parameter_test_cases.py b/test/unit/tool_util/test_parameter_test_cases.py index 640b20fc7dd0..142bc4354d1f 100644 --- a/test/unit/tool_util/test_parameter_test_cases.py +++ b/test/unit/tool_util/test_parameter_test_cases.py @@ -6,6 +6,7 @@ from galaxy.tool_util.parameters.case import ( test_case_state as case_state, validate_test_cases_for_tool_source, + TestCaseStateValidationResult, ) from galaxy.tool_util.parser.factory import get_tool_source from galaxy.tool_util.parser.interface import ToolSourceTest @@ -119,7 +120,7 @@ def _validate_path(tool_path: str): assert tool_state.state_representation == "test_case_xml" -def validate_test_cases_for(tool_name: str, **kwd) -> List[List[str]]: +def validate_test_cases_for(tool_name: str, **kwd) -> List[TestCaseStateValidationResult]: test_tool_directory = functional_test_tool_directory() tool_path = os.path.join(test_tool_directory, f"{tool_name}.xml") tool_source = get_tool_source(tool_path)