Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type comparisons #1382

Merged
merged 2 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion planemo/autoupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion planemo/galaxy/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions planemo/workflow_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.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):
return True
elif type(value) == str:
elif isinstance(value, str):
if re.match(r"\$\{.+?\}", value):
return True
return False
Expand Down Expand Up @@ -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")
Expand Down
Loading