From 75f862be45bb58edadd17431659f40eb770debf2 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Fri, 4 Aug 2023 16:13:29 +0200 Subject: [PATCH 1/2] fix type comparisons linter complained about this over here https://github.com/galaxyproject/planemo/pull/1381 --- planemo/autoupdate.py | 2 +- planemo/galaxy/workflows.py | 2 +- planemo/workflow_lint.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/planemo/autoupdate.py b/planemo/autoupdate.py index 36ae888ac..c837f7719 100644 --- a/planemo/autoupdate.py +++ b/planemo/autoupdate.py @@ -319,7 +319,7 @@ def check_tool_step(step, ts): # return a dict with current and newest tool ver return {} outdated_tool_dict = {} - steps = wf_dict["steps"].values() if type(wf_dict["steps"]) == dict else wf_dict["steps"] + steps = wf_dict["steps"].values() if isinstance(wf_dict["steps"], dict) else wf_dict["steps"] for step in steps: if step.get("type", "tool") == "tool" and not step.get("run", {}).get("class") == "GalaxyWorkflow": outdated_tool_dict.update(check_tool_step(step, ts)) diff --git a/planemo/galaxy/workflows.py b/planemo/galaxy/workflows.py index fa968ffcc..90d55ab4c 100644 --- a/planemo/galaxy/workflows.py +++ b/planemo/galaxy/workflows.py @@ -300,7 +300,7 @@ def rewrite_job_file(input_file, output_file, job): with open(input_file) as f: job_contents = yaml.safe_load(f) for job_input, job_input_name in job_contents.items(): - if type(job[job_input]) == dict: # dataset or collection + if isinstance(job[job_input], dict): # dataset or collection job_contents[job_input] = {"class": job_input_name["class"], "galaxy_id": job[job_input]["id"]} # else: presumably a parameter, no need to modify with open(output_file, "w") as f: diff --git a/planemo/workflow_lint.py b/planemo/workflow_lint.py index d314c0676..15ab22d26 100644 --- a/planemo/workflow_lint.py +++ b/planemo/workflow_lint.py @@ -191,12 +191,12 @@ def _lint_best_practices(path: str, lint_context: WorkflowLintContext) -> None: """ def check_json_for_untyped_params(j): - values = j if type(j) == list else j.values() + values = j if isinstance(j, list) else j.values() for value in values: if type(value) in [list, dict, OrderedDict]: if check_json_for_untyped_params(value): return True - elif type(value) == str: + elif isinstance(value, str): if re.match(r"\$\{.+?\}", value): return True return False @@ -345,7 +345,7 @@ def _tst_input_valid( input_def: Dict[str, Any], lint_context: WorkflowLintContext, ) -> bool: - if type(input_def) == dict: # else assume it is a parameter + if isinstance(input_def, dict): # else assume it is a parameter clazz = input_def.get("class") if clazz == "File": input_path = input_def.get("path") From 41065f653b5c101178246bc97beed27916ad3761 Mon Sep 17 00:00:00 2001 From: M Bernt Date: Mon, 7 Aug 2023 15:51:24 +0200 Subject: [PATCH 2/2] check for dict --- planemo/workflow_lint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/planemo/workflow_lint.py b/planemo/workflow_lint.py index 15ab22d26..e3704b849 100644 --- a/planemo/workflow_lint.py +++ b/planemo/workflow_lint.py @@ -191,7 +191,7 @@ def _lint_best_practices(path: str, lint_context: WorkflowLintContext) -> None: """ def check_json_for_untyped_params(j): - values = j if isinstance(j, list) else j.values() + values = j.values() if isinstance(j, dict) else j for value in values: if type(value) in [list, dict, OrderedDict]: if check_json_for_untyped_params(value):