Skip to content

Commit

Permalink
Fix new E721 errors from ruff 0.0.290
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Sep 20, 2023
1 parent 9a0fc5f commit d258e57
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions lib/galaxy/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ def resolve(key):
for key in self.schema.paths_to_resolve:
value = getattr(self, key)
# Check if value is a list or should be listified; if so, listify and resolve each item separately.
if type(value) is list or (self.listify_options and key in self.listify_options):
if isinstance(value, list) or (self.listify_options and key in self.listify_options):
saved_values = listify(getattr(self, key), do_strip=True) # listify and save original value
setattr(self, key, "_") # replace value with temporary placeholder
resolve(key) # resolve temporary value (`_` becomes `parent-path/_`)
Expand Down Expand Up @@ -546,7 +546,7 @@ def get_path(current_path, initial_path):
return current_path

current_value = getattr(self, key) # resolved path or list of resolved paths
if type(current_value) is list:
if isinstance(current_value, list):
initial_paths = listify(self._raw_config[key], do_strip=True) # initial unresolved paths
updated_paths = []
# check and, if needed, update each path in the list
Expand Down
8 changes: 4 additions & 4 deletions lib/galaxy/jobs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,24 +903,24 @@ def get_job_runner_plugins(self, handler_id):
return rval

def is_id(self, collection):
"""Given a collection of handlers or destinations, indicate whether the collection represents a tag or a real ID
"""Given a collection of handlers or destinations, indicate whether the collection represents a real ID
:param collection: A representation of a destination or handler
:type collection: tuple or list
:returns: bool
"""
return type(collection) == tuple
return isinstance(collection, tuple)

def is_tag(self, collection):
"""Given a collection of handlers or destinations, indicate whether the collection represents a tag or a real ID
"""Given a collection of handlers or destinations, indicate whether the collection represents a tag
:param collection: A representation of a destination or handler
:type collection: tuple or list
:returns: bool
"""
return type(collection) == list
return isinstance(collection, list)

def convert_legacy_destinations(self, job_runners):
"""Converts legacy (from a URL) destinations to contain the appropriate runner params defined in the URL.
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/selenium/navigates_galaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,7 @@ def assert_success_message(self, contains=None):

def assert_message(self, element, contains=None):
if contains is not None:
if type(element) == list:
if isinstance(element, list):
assert any(
contains in el.text for el in element
), f"{contains} was not found in {[el.text for el in element]}"
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tools/actions/upload_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def persist_uploads(params, trans):
local_filename = util.mkstemp_ln(f.file.name, "upload_file_data_")
f.file.close()
upload_dataset["file_data"] = dict(filename=f.filename, local_filename=local_filename)
elif type(f) == dict and "local_filename" not in f:
elif isinstance(f, dict) and "local_filename" not in f:
raise Exception("Uploaded file was encoded in a way not understood by Galaxy.")
if (
"url_paste" in upload_dataset
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tools/parameters/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ def from_json(self, value, trans=None, other_values=None):
if isinstance(value, FilesPayload):
# multi-part upload handled and persisted in service layer
return value.dict()
if type(value) == dict:
elif isinstance(value, dict):
if "session_id" in value:
# handle api upload
session_id = value["session_id"]
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/galaxy/api/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def set_workflow_menu(self, trans: GalaxyWebTransaction, payload=None, **kwd):
workflow_ids = payload.get("workflow_ids")
if workflow_ids is None:
workflow_ids = []
elif type(workflow_ids) != list:
elif not isinstance(workflow_ids, list):
workflow_ids = [workflow_ids]
workflow_ids_decoded = []
# Decode the encoded workflow ids
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/workflow/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _resource_parameters_by_group(trans, **kwds):
for group_name, group_def in by_group.get("groups", {}).items():
if group_name == default_group or group_name in user_groups:
for tag in group_def:
if type(tag) is dict:
if isinstance(tag, dict):
if tag.get("name") not in user_permissions:
user_permissions[tag.get("name")] = {}
for option in tag.get("options"):
Expand Down Expand Up @@ -131,7 +131,7 @@ def validate_by_group_workflow_parameters_mapper(by_group, workflow_resource_par
)
for group in by_group["groups"]:
for attrib in by_group["groups"][group]:
if type(attrib) is dict:
if isinstance(attrib, dict):
if "name" not in attrib:
raise Exception(
"'workflow_resource_params_mapper' YAML file is malformed, "
Expand Down
2 changes: 1 addition & 1 deletion lib/tool_shed/webapp/api/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ def create_changeset_revision(self, trans, id, payload, **kwd):
local_filename = util.mkstemp_ln(file_data.file.name, "upload_file_data_")
file_data.file.close()
file_data = dict(filename=file_data.filename, local_filename=local_filename)
elif type(file_data) == dict and "local_filename" not in file_data:
elif isinstance(file_data, dict) and "local_filename" not in file_data:
raise Exception("Uploaded file was encoded in a way not understood.")

commit_message = kwd.get("commit_message", "Uploaded")
Expand Down
8 changes: 4 additions & 4 deletions scripts/api/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def display(api_key, url, return_formatted=True):
sys.exit(1)
if not return_formatted:
return r
elif type(r) == list:
elif isinstance(r, list):
# Response is a collection as defined in the REST style.
print("Collection Members")
print("------------------")
Expand All @@ -103,7 +103,7 @@ def display(api_key, url, return_formatted=True):
print(item)
print("")
print("%d element(s) in collection" % len(r))
elif type(r) == dict:
elif isinstance(r, dict):
# Response is an element as defined in the REST style.
print("Member Information")
print("------------------")
Expand Down Expand Up @@ -133,11 +133,11 @@ def submit(api_key, url, data, return_formatted=True):
return r
print("Response")
print("--------")
if type(r) == list:
if isinstance(r, list):
# Currently the only implemented responses are lists of dicts, because
# submission creates some number of collection elements.
for i in r:
if type(i) == dict:
if isinstance(i, dict):
if "url" in i:
print(i.pop("url"))
else:
Expand Down
2 changes: 1 addition & 1 deletion tools/data_source/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def __read_paramfile(path):
with open(path) as fh:
obj = load(fh)
# If there's a single dataset in an old-style paramfile it'll still parse, but it'll be a dict
assert type(obj) == list
assert isinstance(obj, list)
return obj


Expand Down
2 changes: 1 addition & 1 deletion tools/stats/gsummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def main():
stop_err("Computation resulted in the following error: %s" % str(s))
summary = summary.as_py(BASIC_CONVERSION)
outfile.write("#%s\n" % headings_str)
if type(summary) is dict:
if isinstance(summary, dict):
# using rpy
outfile.write("%s\n" % "\t".join("%g" % summary[k] for k in headings))
else:
Expand Down

0 comments on commit d258e57

Please sign in to comment.