diff --git a/contrib/galaxy_config_merger.py b/contrib/galaxy_config_merger.py index b5a24c60d5c..887e43434f4 100644 --- a/contrib/galaxy_config_merger.py +++ b/contrib/galaxy_config_merger.py @@ -69,7 +69,7 @@ def main(): config_sample.set(section, name, value) else: if not config_sample.get(section, name) == value: - logging.info("- diff - section [{}] option '{}' has different value ('{}':'{}'). It will be modified.".format(section, name, config_sample.get(section, name), value)) + logging.info(f"- diff - section [{section}] option '{name}' has different value ('{config_sample.get(section, name)}':'{value}'). It will be modified.") config_sample.set(section, name, value) logging.info("---------- DIFFERENCE ANALYSIS END ----------") diff --git a/lib/galaxy/config/__init__.py b/lib/galaxy/config/__init__.py index 385c0a107d1..bedc317eca1 100644 --- a/lib/galaxy/config/__init__.py +++ b/lib/galaxy/config/__init__.py @@ -975,7 +975,7 @@ class GalaxyAppConfiguration(BaseAppConfiguration, CommonConfigurationMixin): log.warning("Sanitize log file explicitly specified as '%s' but does not exist, continuing with no tools allowlisted.", self.sanitize_allowlist_file) else: with open(self.sanitize_allowlist_file) as f: - self.sanitize_allowlist = sorted([line.strip() for line in f.readlines() if not line.startswith('#')]) + self.sanitize_allowlist = sorted(line.strip() for line in f.readlines() if not line.startswith('#')) def ensure_tempdir(self): self._ensure_directory(self.new_file_path) diff --git a/lib/galaxy/containers/docker_model.py b/lib/galaxy/containers/docker_model.py index 7d368688f0f..2d409e258db 100644 --- a/lib/galaxy/containers/docker_model.py +++ b/lib/galaxy/containers/docker_model.py @@ -44,7 +44,7 @@ class DockerAttributeContainer: return not self.__eq__(other) def __hash__(self): - return hash(tuple(sorted([repr(x) for x in self._members]))) + return hash(tuple(sorted(repr(x) for x in self._members))) def __str__(self): return ', '.join(str(x) for x in self._members) or 'None' diff --git a/lib/galaxy/datatypes/binary.py b/lib/galaxy/datatypes/binary.py index 2655d4f9f09..1a49200fff9 100644 --- a/lib/galaxy/datatypes/binary.py +++ b/lib/galaxy/datatypes/binary.py @@ -1600,7 +1600,7 @@ class H5MLM(H5): repr_ = self.get_repr(dataset.file_name) - return "
{}{}".format(repr_, rval)
+ return f"{repr_}{rval}"
class HexrdMaterials(H5):
diff --git a/lib/galaxy/datatypes/images.py b/lib/galaxy/datatypes/images.py
index f42b41107fe..d77d3484ab9 100644
--- a/lib/galaxy/datatypes/images.py
+++ b/lib/galaxy/datatypes/images.py
@@ -359,7 +359,7 @@ class Gmaj(data.Data):
"nobutton": "false",
"urlpause": "100",
"debug": "false",
- "posturl": "history_add_to?%s" % "&".join("{}={}".format(x[0], quote_plus(str(x[1]))) for x in [('copy_access_from', dataset.id), ('history_id', dataset.history_id), ('ext', 'maf'), ('name', f'GMAJ Output on data {dataset.hid}'), ('info', 'Added by GMAJ'), ('dbkey', dataset.dbkey)])
+ "posturl": "history_add_to?%s" % "&".join(f"{x[0]}={quote_plus(str(x[1]))}" for x in [('copy_access_from', dataset.id), ('history_id', dataset.history_id), ('ext', 'maf'), ('name', f'GMAJ Output on data {dataset.hid}'), ('info', 'Added by GMAJ'), ('dbkey', dataset.dbkey)])
}
class_name = "edu.psu.bx.gmaj.MajApplet.class"
archive = "/static/gmaj/gmaj.jar"
diff --git a/lib/galaxy/datatypes/tabular.py b/lib/galaxy/datatypes/tabular.py
index 4820f7b2d16..a14a69ab3b1 100644
--- a/lib/galaxy/datatypes/tabular.py
+++ b/lib/galaxy/datatypes/tabular.py
@@ -103,7 +103,7 @@ class TabularData(data.Text):
else:
trans.response.set_content_type("text/html")
return trans.stream_template_mako("/dataset/large_file.mako",
- truncated_data=open(dataset.file_name, mode='r').read(max_peek_size),
+ truncated_data=open(dataset.file_name).read(max_peek_size),
data=dataset)
else:
column_names = 'null'
diff --git a/lib/galaxy/files/__init__.py b/lib/galaxy/files/__init__.py
index 5b8555ccdf9..71a1cbc2b04 100644
--- a/lib/galaxy/files/__init__.py
+++ b/lib/galaxy/files/__init__.py
@@ -250,13 +250,13 @@ class ProvidesUserFileSourcesUserContext:
def role_names(self) -> Set[str]:
"""The set of role names of this user."""
user = self.trans.user
- return set(ura.role.name for ura in user.roles) if user else set()
+ return {ura.role.name for ura in user.roles} if user else set()
@property
def group_names(self) -> Set[str]:
"""The set of group names to which this user belongs."""
user = self.trans.user
- return set(ugr.group.name for ugr in user.groups) if user else set()
+ return {ugr.group.name for ugr in user.groups} if user else set()
@property
def is_admin(self):
diff --git a/lib/galaxy/jobs/__init__.py b/lib/galaxy/jobs/__init__.py
index bd55d32afbf..b41e2c8e9b1 100644
--- a/lib/galaxy/jobs/__init__.py
+++ b/lib/galaxy/jobs/__init__.py
@@ -539,12 +539,12 @@ class JobConfiguration(ConfiguresHandlers):
self.limits.__dict__[limit_type] = types.get(limit_type, str)(limit_value)
if self.limits.walltime is not None:
- h, m, s = [int(v) for v in self.limits.walltime.split(':')]
+ h, m, s = (int(v) for v in self.limits.walltime.split(':'))
self.limits.walltime_delta = datetime.timedelta(0, s, 0, 0, m, h)
if "raw" in self.limits.total_walltime:
- h, m, s = [int(v) for v in
- self.limits.total_walltime["raw"].split(':')]
+ h, m, s = (int(v) for v in
+ self.limits.total_walltime["raw"].split(':'))
self.limits.total_walltime["delta"] = datetime.timedelta(
0, s, 0, 0, m, h
)
diff --git a/lib/galaxy/jobs/runners/kubernetes.py b/lib/galaxy/jobs/runners/kubernetes.py
index 41e7a95f72c..84c66ae5a2d 100644
--- a/lib/galaxy/jobs/runners/kubernetes.py
+++ b/lib/galaxy/jobs/runners/kubernetes.py
@@ -110,7 +110,7 @@ class KubernetesJobRunner(AsynchronousJobRunner):
volume_claims = dict(volume.split(":") for volume in self.runner_params['k8s_persistent_volume_claims'].split(','))
else:
volume_claims = {}
- mountable_volumes = list(set([claim_name if "/" not in claim_name else claim_name.split("/")[0] for claim_name in volume_claims]))
+ mountable_volumes = list({claim_name if "/" not in claim_name else claim_name.split("/")[0] for claim_name in volume_claims})
mountable_volumes = [{'name': claim_name, 'persistentVolumeClaim': {'claimName': claim_name}} for claim_name in mountable_volumes]
self.runner_params['k8s_mountable_volumes'] = mountable_volumes
volume_mounts = [{'name': claim_name, 'mountPath': mount_path} for claim_name, mount_path in volume_claims.items()]
@@ -366,7 +366,7 @@ class KubernetesJobRunner(AsynchronousJobRunner):
}
},
"spec": {
- "ports": [{"name": "job-{}-{}".format(self.__force_label_conformity(ajs.job_wrapper.get_id_tag()), p),
+ "ports": [{"name": f"job-{self.__force_label_conformity(ajs.job_wrapper.get_id_tag())}-{p}",
"port": int(p),
"protocol": "TCP",
"targetPort": int(p)} for p in guest_ports],
@@ -426,7 +426,7 @@ class KubernetesJobRunner(AsynchronousJobRunner):
}
}
if self.runner_params.get("k8s_interactivetools_use_ssl"):
- domains = list(set([e["domain"] for e in entry_points]))
+ domains = list({e["domain"] for e in entry_points})
k8s_spec_template["spec"]["tls"] = [{"hosts": [domain],
"secretName": re.sub("[^a-z0-9-]", "-", domain)} for domain in domains]
if self.runner_params.get("k8s_interactivetools_ingress_annotations"):
@@ -809,7 +809,7 @@ class KubernetesJobRunner(AsynchronousJobRunner):
def __cleanup_k8s_guest_ports(self, job_wrapper, k8s_job):
k8s_job_prefix = self.__produce_k8s_job_prefix()
- k8s_job_name = "{}-{}".format(k8s_job_prefix, self.__force_label_conformity(job_wrapper.get_id_tag()))
+ k8s_job_name = f"{k8s_job_prefix}-{self.__force_label_conformity(job_wrapper.get_id_tag())}"
log.debug(f'Deleting service/ingress for job with ID {job_wrapper.get_id_tag()}')
job_failed = (k8s_job.obj['status']['failed'] > 0
if 'failed' in k8s_job.obj['status'] else False)
diff --git a/lib/galaxy/jobs/runners/pbs.py b/lib/galaxy/jobs/runners/pbs.py
index 29ab409dfdd..c5ba9b5d92c 100644
--- a/lib/galaxy/jobs/runners/pbs.py
+++ b/lib/galaxy/jobs/runners/pbs.py
@@ -385,7 +385,7 @@ class PBSJobRunner(AsynchronousJobRunner):
pbs_job_state.job_wrapper.change_state(model.Job.states.RUNNING)
if status.job_state == "R" and status.get('resources_used', False):
# resources_used may not be in the status for new jobs
- h, m, s = [int(i) for i in status.resources_used.walltime.split(':')]
+ h, m, s = (int(i) for i in status.resources_used.walltime.split(':'))
runtime = timedelta(0, s, 0, 0, m, h)
if pbs_job_state.check_limits(runtime=runtime):
self.work_queue.put((self.fail_job, pbs_job_state))
diff --git a/lib/galaxy/jobs/runners/pulsar.py b/lib/galaxy/jobs/runners/pulsar.py
index fec848e57b2..e16798b35f0 100644
--- a/lib/galaxy/jobs/runners/pulsar.py
+++ b/lib/galaxy/jobs/runners/pulsar.py
@@ -376,7 +376,7 @@ class PulsarJobRunner(AsynchronousJobRunner):
remote_pulsar_app_config = dest_params.get("pulsar_app_config", {}).copy()
if "pulsar_app_config_path" in dest_params:
pulsar_app_config_path = dest_params["pulsar_app_config_path"]
- with open(pulsar_app_config_path, "r") as fh:
+ with open(pulsar_app_config_path) as fh:
remote_pulsar_app_config.update(yaml.safe_load(fh))
job_directory_files = []
config_files = job_wrapper.extra_filenames
diff --git a/lib/galaxy/managers/collections.py b/lib/galaxy/managers/collections.py
index 48949e50952..38055ea3a56 100644
--- a/lib/galaxy/managers/collections.py
+++ b/lib/galaxy/managers/collections.py
@@ -305,7 +305,7 @@ class DatasetCollectionManager:
try:
self.hda_manager.error_unless_owner(dataset, user=trans.get_user(), current_history=trans.history)
except HistoryDatasetAssociationNoHistoryException:
- log.info("Cannot delete HistoryDatasetAssociation {}, HistoryDatasetAssociation has no associated History, cannot verify owner".format(dataset.id))
+ log.info(f"Cannot delete HistoryDatasetAssociation {dataset.id}, HistoryDatasetAssociation has no associated History, cannot verify owner")
continue
if not dataset.deleted:
dataset.deleted = True
diff --git a/lib/galaxy/managers/collections_util.py b/lib/galaxy/managers/collections_util.py
index fe4f9fcd7b4..afa2e991e4b 100644
--- a/lib/galaxy/managers/collections_util.py
+++ b/lib/galaxy/managers/collections_util.py
@@ -262,7 +262,7 @@ def gen_rank_fuzzy_counts(collection_type, fuzzy_count=None):
return [None for rt in rank_collection_types]
else:
# This is a list...
- paired_count = sum([1 if rt == "paired" else 0 for rt in rank_collection_types])
+ paired_count = sum(1 if rt == "paired" else 0 for rt in rank_collection_types)
list_count = len(rank_collection_types) - paired_count
paired_fuzzy_count_mult = 1 if paired_count == 0 else 2 << (paired_count - 1)
list_fuzzy_count_mult = math.floor((fuzzy_count * 1.0) / paired_fuzzy_count_mult)
diff --git a/lib/galaxy/managers/genomes.py b/lib/galaxy/managers/genomes.py
index f0970982756..d55280051a5 100644
--- a/lib/galaxy/managers/genomes.py
+++ b/lib/galaxy/managers/genomes.py
@@ -57,7 +57,7 @@ class GenomesManager:
ext = index_extensions[index_type]
index_filename = self._get_index_filename(id, tbl_entries, ext, index_type)
try:
- with open(index_filename, mode='r') as f:
+ with open(index_filename) as f:
return f.read()
except OSError:
raise ReferenceDataError(f'Failed to load index file for {id}')
diff --git a/lib/galaxy/managers/remote_files.py b/lib/galaxy/managers/remote_files.py
index a1e561fa8ff..2e9bfbd96db 100644
--- a/lib/galaxy/managers/remote_files.py
+++ b/lib/galaxy/managers/remote_files.py
@@ -1,4 +1,3 @@
-
import hashlib
import logging
from operator import itemgetter
diff --git a/lib/galaxy/managers/tool_data.py b/lib/galaxy/managers/tool_data.py
index 6b516e670da..c03d3bdc39f 100644
--- a/lib/galaxy/managers/tool_data.py
+++ b/lib/galaxy/managers/tool_data.py
@@ -1,4 +1,3 @@
-
from pathlib import Path
from typing import (
Dict,
diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py
index a3a02d60730..5668888c80d 100644
--- a/lib/galaxy/model/__init__.py
+++ b/lib/galaxy/model/__init__.py
@@ -2488,7 +2488,7 @@ class History(Base, HasTags, Dictifiable, UsesAnnotations, HasName, Serializable
if optimize:
self.__add_datasets_optimized(datasets, genome_build=genome_build)
if quota and self.user:
- disk_usage = sum([d.get_total_size() for d in datasets if is_hda(d)])
+ disk_usage = sum(d.get_total_size() for d in datasets if is_hda(d))
self.user.adjust_total_disk_usage(disk_usage)
sa_session.add_all(datasets)
if flush:
@@ -3305,7 +3305,7 @@ class Dataset(StorableObject, Serializable, _HasTable):
if rel_path is not None:
if self.object_store.exists(self, extra_dir=rel_path, dir_only=True):
for root, _, files in os.walk(self.extra_files_path):
- self.total_size += sum([os.path.getsize(os.path.join(root, file)) for file in files if os.path.exists(os.path.join(root, file))])
+ self.total_size += sum(os.path.getsize(os.path.join(root, file)) for file in files if os.path.exists(os.path.join(root, file)))
return self.total_size
def has_data(self):
diff --git a/lib/galaxy/model/dataset_collections/structure.py b/lib/galaxy/model/dataset_collections/structure.py
index ad2c7dee30f..9814a3580c2 100644
--- a/lib/galaxy/model/dataset_collections/structure.py
+++ b/lib/galaxy/model/dataset_collections/structure.py
@@ -119,7 +119,7 @@ class Tree(BaseTree):
return True
def __len__(self):
- return sum([len(c[1]) for c in self.children])
+ return sum(len(c[1]) for c in self.children)
def multiply(self, other_structure):
if other_structure.is_leaf:
diff --git a/lib/galaxy/model/migrate/versions/0173_add_job_id_to_dataset.py b/lib/galaxy/model/migrate/versions/0173_add_job_id_to_dataset.py
index 50d0958be99..288e0e156c5 100644
--- a/lib/galaxy/model/migrate/versions/0173_add_job_id_to_dataset.py
+++ b/lib/galaxy/model/migrate/versions/0173_add_job_id_to_dataset.py
@@ -1,7 +1,6 @@
"""
Migration script for adding job_id column to dataset table.
"""
-from __future__ import print_function
import logging
diff --git a/lib/galaxy/selenium/context.py b/lib/galaxy/selenium/context.py
index 4983f66aa94..e19e945e934 100644
--- a/lib/galaxy/selenium/context.py
+++ b/lib/galaxy/selenium/context.py
@@ -64,7 +64,7 @@ class GalaxySeleniumContextImpl(GalaxySeleniumContext):
def init(config=None, clazz=GalaxySeleniumContextImpl) -> GalaxySeleniumContext:
if os.path.exists("galaxy_selenium_context.yml"):
- with open("galaxy_selenium_context.yml", "r") as f:
+ with open("galaxy_selenium_context.yml") as f:
as_dict = yaml.safe_load(f)
context = clazz(as_dict)
else:
diff --git a/lib/galaxy/tool_util/biotools/source.py b/lib/galaxy/tool_util/biotools/source.py
index 84e89d0dc87..af49b52c2c4 100644
--- a/lib/galaxy/tool_util/biotools/source.py
+++ b/lib/galaxy/tool_util/biotools/source.py
@@ -26,7 +26,7 @@ class GitContentBiotoolsMetadataSource(BiotoolsMetadataSource):
path = os.path.join(self._content_directory, "data", biotools_reference, f"{biotools_reference}.biotools.json")
if not os.path.exists(path):
return None
- with open(path, "r") as f:
+ with open(path) as f:
content_json = json.load(f)
return BiotoolsEntry.from_json(content_json)
diff --git a/lib/galaxy/tool_util/deps/container_resolvers/mulled.py b/lib/galaxy/tool_util/deps/container_resolvers/mulled.py
index 9bd139ff7c0..bbae6793514 100644
--- a/lib/galaxy/tool_util/deps/container_resolvers/mulled.py
+++ b/lib/galaxy/tool_util/deps/container_resolvers/mulled.py
@@ -88,7 +88,7 @@ class CacheDirectory(metaclass=ABCMeta):
contents = os.listdir(self.path)
sorted_images = version_sorted(contents)
raw_images = map(lambda name: identifier_to_cached_target(name, self.hash_func), sorted_images)
- return list([i for i in raw_images if i is not None])
+ return list(i for i in raw_images if i is not None)
@abstractmethod
def list_cached_mulled_images_from_path(self):
diff --git a/lib/galaxy/tool_util/deps/mulled/mulled_search.py b/lib/galaxy/tool_util/deps/mulled/mulled_search.py
index 4fa927f018c..822d939edfa 100755
--- a/lib/galaxy/tool_util/deps/mulled/mulled_search.py
+++ b/lib/galaxy/tool_util/deps/mulled/mulled_search.py
@@ -217,12 +217,12 @@ def singularity_search(search_string):
def readable_output(json, organization='biocontainers', channel='bioconda'):
# if json is empty:
- if sum([len(json[destination][results]) for destination in json for results in json[destination]]) == 0:
+ if sum(len(json[destination][results]) for destination in json for results in json[destination]) == 0:
sys.stdout.write('No results found for that query.\n')
return
# return results for quay, conda and singularity together
- if sum([len(json[destination][results]) for destination in ['quay', 'conda', 'singularity', ] for results in json.get(destination, [])]) > 0:
+ if sum(len(json[destination][results]) for destination in ['quay', 'conda', 'singularity', ] for results in json.get(destination, [])) > 0:
sys.stdout.write("The query returned the following result(s).\n")
# put quay, conda etc results as lists in lines
lines = [['LOCATION', 'NAME', 'VERSION', 'COMMAND\n']]
@@ -262,7 +262,7 @@ def readable_output(json, organization='biocontainers', channel='bioconda'):
sys.stdout.write(
"".join((line[0].ljust(col_width0), line[1]))) # output
- if sum([len(json['github'][results]) for results in json.get('github', [])]) > 0:
+ if sum(len(json['github'][results]) for results in json.get('github', [])) > 0:
sys.stdout.write('\n' if 'lines' in locals() else '')
sys.stdout.write(
"Other result(s) on the bioconda-recipes GitHub repository:\n")
diff --git a/lib/galaxy/tool_util/deps/requirements.py b/lib/galaxy/tool_util/deps/requirements.py
index 44efafd7269..b5a8dd439a3 100644
--- a/lib/galaxy/tool_util/deps/requirements.py
+++ b/lib/galaxy/tool_util/deps/requirements.py
@@ -140,7 +140,7 @@ class ToolRequirements:
return len(self.tool_requirements)
def __hash__(self):
- return sum([r.__hash__() for r in self.tool_requirements])
+ return sum(r.__hash__() for r in self.tool_requirements)
def to_dict(self):
return [r.to_dict() for r in self.tool_requirements]
diff --git a/lib/galaxy/tool_util/edam_util.py b/lib/galaxy/tool_util/edam_util.py
index ee7c6e0fb4d..3b85bb45635 100644
--- a/lib/galaxy/tool_util/edam_util.py
+++ b/lib/galaxy/tool_util/edam_util.py
@@ -1,4 +1,3 @@
-import io
import os
from typing import Dict, Optional, TextIO
@@ -16,7 +15,7 @@ ROOT_TOPIC = 'topic_0003'
def load_edam_tree(path: Optional[str] = None):
if path is not None:
assert os.path.exists(path), f"Failed to load EDAM tabular data at [{path}] path does not exist."
- handle = io.open(path, "r")
+ handle = open(path)
else:
assert tabular_stream is not None, "Failed to load optional import from edam-onotology package, install using [pip install edam-ontology]."
handle = tabular_stream()
diff --git a/lib/galaxy/tool_util/linters/inputs.py b/lib/galaxy/tool_util/linters/inputs.py
index ea887af358b..c334e4b675c 100644
--- a/lib/galaxy/tool_util/linters/inputs.py
+++ b/lib/galaxy/tool_util/linters/inputs.py
@@ -1,4 +1,3 @@
-
"""This module contains a linting functions for tool inputs."""
from galaxy.util import string_as_bool
from ._util import is_datasource, is_valid_cheetah_placeholder
@@ -132,9 +131,9 @@ def lint_inputs(tool_xml, lint_ctx):
# lint statically defined options
if any(['value' not in option.attrib for option in select_options]):
lint_ctx.error(f"Select parameter [{param_name}] has option without value")
- if len(set([option.text.strip() for option in select_options if option.text is not None])) != len(select_options):
+ if len({option.text.strip() for option in select_options if option.text is not None}) != len(select_options):
lint_ctx.error(f"Select parameter [{param_name}] has multiple options with the same text content")
- if len(set([option.attrib.get("value") for option in select_options])) != len(select_options):
+ if len({option.attrib.get("value") for option in select_options}) != len(select_options):
lint_ctx.error(f"Select parameter [{param_name}] has multiple options with the same value")
if param_attrib.get("display") == "checkboxes":
diff --git a/lib/galaxy/tool_util/toolbox/views/edam.py b/lib/galaxy/tool_util/toolbox/views/edam.py
index 8d70b37f844..3f0739aa0ff 100644
--- a/lib/galaxy/tool_util/toolbox/views/edam.py
+++ b/lib/galaxy/tool_util/toolbox/views/edam.py
@@ -142,8 +142,7 @@ class EdamToolPanelView(ToolPanelView):
if self.include_topics:
edam.extend(tool.edam_topics)
if len(edam) > 0:
- for term in edam:
- yield term
+ yield from edam
else:
yield 'uncategorized'
diff --git a/lib/galaxy/util/pastescript/serve.py b/lib/galaxy/util/pastescript/serve.py
index 49b0ad8182e..56ebe6c090c 100644
--- a/lib/galaxy/util/pastescript/serve.py
+++ b/lib/galaxy/util/pastescript/serve.py
@@ -369,7 +369,7 @@ class NotFoundCommand(Command):
print('(try running python setup.py develop)')
return 2
print('Known commands:')
- longest = max([len(n) for n, c in commands])
+ longest = max(len(n) for n, c in commands)
for name, command in commands:
print(f' {self.pad(name, length=longest)} {command.load().summary}')
return 2
diff --git a/lib/galaxy/visualization/data_providers/genome.py b/lib/galaxy/visualization/data_providers/genome.py
index 48316860922..99e4d7f8df3 100644
--- a/lib/galaxy/visualization/data_providers/genome.py
+++ b/lib/galaxy/visualization/data_providers/genome.py
@@ -987,7 +987,7 @@ class BamDataProvider(GenomeDataProvider, FilterableMixin):
seq = read.seq
strand = decode_strand(read.flag, 0x0010)
if read.cigar is not None:
- read_len = sum([cig[1] for cig in read.cigar]) # Use cigar to determine length
+ read_len = sum(cig[1] for cig in read.cigar) # Use cigar to determine length
else:
read_len = len(seq) # If no cigar, just use sequence length
diff --git a/lib/galaxy/web/framework/middleware/error.py b/lib/galaxy/web/framework/middleware/error.py
index f50a0a2a158..9c9bdf9b39a 100644
--- a/lib/galaxy/web/framework/middleware/error.py
+++ b/lib/galaxy/web/framework/middleware/error.py
@@ -308,10 +308,11 @@ class Supplement:
wsgi_vars[name] = value
if self.environ['wsgi.version'] != (1, 0):
wsgi_vars['wsgi.version'] = self.environ['wsgi.version']
- proc_desc = tuple([int(bool(self.environ[key]))
- for key in ('wsgi.multiprocess',
- 'wsgi.multithread',
- 'wsgi.run_once')])
+ proc_desc = tuple(int(bool(self.environ[key])) for key in (
+ 'wsgi.multiprocess',
+ 'wsgi.multithread',
+ 'wsgi.run_once'
+ ))
wsgi_vars['wsgi process'] = self.process_combos[proc_desc]
wsgi_vars['application'] = self.middleware.application
if 'paste.config' in self.environ:
diff --git a/lib/galaxy/webapps/base/controller.py b/lib/galaxy/webapps/base/controller.py
index 84e03940199..e2e2f887b7d 100644
--- a/lib/galaxy/webapps/base/controller.py
+++ b/lib/galaxy/webapps/base/controller.py
@@ -1471,7 +1471,7 @@ class UsesExtendedMetadataMixin(SharableItemSecurityMixin):
else:
# BUG: Everything is cast to string, which can lead to false positives
# for cross type comparisions, ie "True" == True
- yield prefix, (f"{meta}").encode("utf8", errors='replace')
+ yield prefix, (f"{meta}").encode()
def sort_by_attr(seq, attr):
diff --git a/lib/galaxy/webapps/galaxy/api/library_contents.py b/lib/galaxy/webapps/galaxy/api/library_contents.py
index 131c10e0d63..c9af65e30eb 100644
--- a/lib/galaxy/webapps/galaxy/api/library_contents.py
+++ b/lib/galaxy/webapps/galaxy/api/library_contents.py
@@ -375,7 +375,7 @@ class LibraryContentsController(BaseGalaxyAPIController, UsesLibraryMixinItems,
else:
# BUG: Everything is cast to string, which can lead to false positives
# for cross type comparisions, ie "True" == True
- yield prefix, (f"{meta}").encode("utf8", errors='replace')
+ yield prefix, (f"{meta}").encode()
@expose_api
def update(self, trans, id, library_id, payload, **kwd):
diff --git a/lib/galaxy/webapps/galaxy/api/library_datasets.py b/lib/galaxy/webapps/galaxy/api/library_datasets.py
index 595eec05701..9da03f23366 100644
--- a/lib/galaxy/webapps/galaxy/api/library_datasets.py
+++ b/lib/galaxy/webapps/galaxy/api/library_datasets.py
@@ -456,7 +456,7 @@ class LibraryDatasetsController(BaseGalaxyAPIController, UsesVisualizationMixin,
path = os.path.join(full_dir, path)
if unsafe_walk(path, allowlist=[full_dir] + trans.app.config.user_library_import_symlink_allowlist, username=username):
# the path is a dir and contains files that symlink outside the user dir
- error = 'User attempted to import a path that resolves to a path outside of their import dir: %s -> %s' % (
+ error = 'User attempted to import a path that resolves to a path outside of their import dir: {} -> {}'.format(
path, os.path.realpath(path)
)
if trans.app.config.user_library_import_check_permissions:
diff --git a/lib/galaxy/webapps/galaxy/services/base.py b/lib/galaxy/webapps/galaxy/services/base.py
index 56938e38054..0b2462bf3df 100644
--- a/lib/galaxy/webapps/galaxy/services/base.py
+++ b/lib/galaxy/webapps/galaxy/services/base.py
@@ -1,4 +1,3 @@
-
from typing import (
List,
Optional,
diff --git a/lib/galaxy/webapps/galaxy/services/history_contents.py b/lib/galaxy/webapps/galaxy/services/history_contents.py
index 625bf43831a..4936855722a 100644
--- a/lib/galaxy/webapps/galaxy/services/history_contents.py
+++ b/lib/galaxy/webapps/galaxy/services/history_contents.py
@@ -1,4 +1,3 @@
-
import datetime
import json
import logging
diff --git a/lib/galaxy/webapps/galaxy/services/library_folder_contents.py b/lib/galaxy/webapps/galaxy/services/library_folder_contents.py
index 0b8db1a26c2..dae6ef071cf 100644
--- a/lib/galaxy/webapps/galaxy/services/library_folder_contents.py
+++ b/lib/galaxy/webapps/galaxy/services/library_folder_contents.py
@@ -1,4 +1,3 @@
-
import logging
from galaxy import (
diff --git a/lib/galaxy/webapps/galaxy/services/pages.py b/lib/galaxy/webapps/galaxy/services/pages.py
index 0f3ddfc182f..2d43f552bc0 100644
--- a/lib/galaxy/webapps/galaxy/services/pages.py
+++ b/lib/galaxy/webapps/galaxy/services/pages.py
@@ -1,4 +1,3 @@
-
import logging
from galaxy import (
diff --git a/lib/galaxy/webapps/galaxy/services/quotas.py b/lib/galaxy/webapps/galaxy/services/quotas.py
index 50b7ac8e133..11530167e0e 100644
--- a/lib/galaxy/webapps/galaxy/services/quotas.py
+++ b/lib/galaxy/webapps/galaxy/services/quotas.py
@@ -1,4 +1,3 @@
-
import logging
from typing import (
Optional,
diff --git a/lib/galaxy/webapps/galaxy/services/visualizations.py b/lib/galaxy/webapps/galaxy/services/visualizations.py
index e0df5d69bff..cbebd307b98 100644
--- a/lib/galaxy/webapps/galaxy/services/visualizations.py
+++ b/lib/galaxy/webapps/galaxy/services/visualizations.py
@@ -1,4 +1,3 @@
-
import logging
from galaxy.managers.visualizations import (
diff --git a/lib/galaxy/webapps/reports/controllers/tools.py b/lib/galaxy/webapps/reports/controllers/tools.py
index 492dd9ce1a8..75ddc63673b 100644
--- a/lib/galaxy/webapps/reports/controllers/tools.py
+++ b/lib/galaxy/webapps/reports/controllers/tools.py
@@ -52,7 +52,7 @@ class Tools(BaseUIController):
return f"{returned}"
return returned
else:
- splited = tuple([float(_) for _ in str(date).split(':')])
+ splited = tuple(float(_) for _ in str(date).split(':'))
if splited[0]:
returned = '%d h. %d min.' % splited[:2]
if colored:
diff --git a/lib/galaxy_test/selenium/test_history_panel.py b/lib/galaxy_test/selenium/test_history_panel.py
index 9d533af926c..fbbb9a3b2ec 100644
--- a/lib/galaxy_test/selenium/test_history_panel.py
+++ b/lib/galaxy_test/selenium/test_history_panel.py
@@ -201,7 +201,7 @@ class HistoryPanelTestCase(SeleniumTestCase):
current_tags_size = len(close_tag_buttons)
- errmsg = "there are more tags than expected! current {}, expected {}".format(current_tags_size, expected_tags_size)
+ errmsg = f"there are more tags than expected! current {current_tags_size}, expected {expected_tags_size}"
assert expected_tags_size == current_tags_size, errmsg
for close_btn in reversed(close_tag_buttons):
diff --git a/lib/galaxy_test/selenium/test_published_histories_grid.py b/lib/galaxy_test/selenium/test_published_histories_grid.py
index b59d00f385e..fd1f91fb0ee 100644
--- a/lib/galaxy_test/selenium/test_published_histories_grid.py
+++ b/lib/galaxy_test/selenium/test_published_histories_grid.py
@@ -121,7 +121,7 @@ class HistoryGridTestCase(SharedStateSeleniumTestCase):
@retry_assertion_during_transitions
def assert_grid_histories_sorted_by_owner(self):
histories = self.get_histories()
- index_1, index_2, index_3 = [histories.index(n) for n in self.all_histories]
+ index_1, index_2, index_3 = (histories.index(n) for n in self.all_histories)
# 1 and 3 are owned by a owner whose username lexicographically
# precedes 2. So verify 1 and 3 come before 2.
assert index_1 < index_2
diff --git a/lib/tool_shed/metadata/repository_metadata_manager.py b/lib/tool_shed/metadata/repository_metadata_manager.py
index 935e38f2c2e..63b7aba18c6 100644
--- a/lib/tool_shed/metadata/repository_metadata_manager.py
+++ b/lib/tool_shed/metadata/repository_metadata_manager.py
@@ -162,14 +162,18 @@ class RepositoryMetadataManager(metadata_generator.MetadataGenerator):
def compare_data_manager(self, ancestor_metadata, current_metadata):
"""Determine if ancestor_metadata is the same as or a subset of current_metadata for data_managers."""
+
def __data_manager_dict_to_tuple_list(metadata_dict):
# we do not check tool_guid or tool conf file name
- return set(sorted([(name,
- tuple(sorted(value.get('data_tables', []))),
- value.get('guid'),
- value.get('version'),
- value.get('name'),
- value.get('id')) for name, value in metadata_dict.items()]))
+ return set(sorted((
+ name,
+ tuple(sorted(value.get('data_tables', []))),
+ value.get('guid'),
+ value.get('version'),
+ value.get('name'),
+ value.get('id')
+ ) for name, value in metadata_dict.items()))
+
# only compare valid entries, any invalid entries are ignored
ancestor_metadata = __data_manager_dict_to_tuple_list(ancestor_metadata.get('data_managers', {}))
current_metadata = __data_manager_dict_to_tuple_list(current_metadata.get('data_managers', {}))
diff --git a/scripts/api/common.py b/scripts/api/common.py
index 2d4ab86072c..c99cdf6f486 100644
--- a/scripts/api/common.py
+++ b/scripts/api/common.py
@@ -97,7 +97,7 @@ def display(api_key, url, return_formatted=True):
print(' name: %s' % i.pop('name'))
try:
for k, v in i.items():
- print(' %s: %s' % (k, v))
+ print(f' {k}: {v}')
except AttributeError:
for item in i:
print(item)
diff --git a/scripts/api/library_upload_dir.py b/scripts/api/library_upload_dir.py
index b7ce89cfda1..6862b57118b 100644
--- a/scripts/api/library_upload_dir.py
+++ b/scripts/api/library_upload_dir.py
@@ -131,7 +131,7 @@ class Uploader:
# So that we can check if it really needs to be uploaded.
already_uploaded = memo_key in self.memo_path.keys()
fid = self.memoized_path(basepath, base_folder=self.folder_id)
- print('[{}/{}] {}/{} uploaded={}'.format(idx + 1, len(all_files), fid, fname, already_uploaded))
+ print(f'[{idx + 1}/{len(all_files)}] {fid}/{fname} uploaded={already_uploaded}')
if not already_uploaded:
if self.non_local:
diff --git a/scripts/check_model.py b/scripts/check_model.py
index e4f093bdc7d..0a2e3cb3615 100644
--- a/scripts/check_model.py
+++ b/scripts/check_model.py
@@ -19,7 +19,7 @@ IndexTuple = namedtuple('IndexTuple', 'table column_names')
def tuple_from_index(index):
- columns = tuple([index.columns[key].name for key in index.columns.keys()])
+ columns = tuple(index.columns[key].name for key in index.columns.keys())
if len(columns) == 1:
columns = columns[0]
return IndexTuple(index.table.name, columns)
diff --git a/scripts/cleanup_datasets/pgcleanup.py b/scripts/cleanup_datasets/pgcleanup.py
index 01287432bf5..b20ca097a46 100755
--- a/scripts/cleanup_datasets/pgcleanup.py
+++ b/scripts/cleanup_datasets/pgcleanup.py
@@ -218,7 +218,7 @@ class Action:
for causal, s in zip(self.causals, results[primary]):
for r in sorted(s):
secondaries = ', '.join('%s: %s' % x for x in zip(causal[1:], r[1:]))
- self.log.info('{} {} caused {}'.format(causal[0], r[0], secondaries))
+ self.log.info(f'{causal[0]} {r[0]} caused {secondaries}')
def handle_results(self, cur):
results = {}
diff --git a/scripts/config_sample_to_kwalify.py b/scripts/config_sample_to_kwalify.py
index 2695555b1b7..5ab80170dbc 100644
--- a/scripts/config_sample_to_kwalify.py
+++ b/scripts/config_sample_to_kwalify.py
@@ -39,7 +39,7 @@ def _dump_option(option, current_section_desc):
print((" " * 6) + line)
if "=" not in option:
print(option)
- key, default = [s.strip() for s in option.split("=", 1)]
+ key, default = (s.strip() for s in option.split("=", 1))
key = key[1:] # strip #
if default.strip().lower() in ["true", "false"]:
default = default.lower()
diff --git a/scripts/docker_swarm_manager.py b/scripts/docker_swarm_manager.py
index ffd5392cfdb..1383cd75ab4 100644
--- a/scripts/docker_swarm_manager.py
+++ b/scripts/docker_swarm_manager.py
@@ -358,16 +358,16 @@ class SwarmState:
# there are no cpu constraints, so no calculation can be done
return 0, 0
for node in nodes:
- used += sum([t.cpus for t in node.non_terminal_tasks]) / self._cpus
+ used += sum(t.cpus for t in node.non_terminal_tasks) / self._cpus
total += node.cpus / self._cpus
# need at least this many slots
needed = used + self.get_limit(constraints, 'slots_min_spare')
if (len(services) > self._conf.service_wait_count_limit
and time.time() - self._waiting_since.get(constraints, time.time()) > self._conf.service_wait_time_limit):
# add slots for waiting services that have exceeded limits
- needed += sum([s.cpus for s in services]) / self._cpus
+ needed += sum(s.cpus for s in services) / self._cpus
# subtract slots for spawning nodes
- needed -= sum([n.get('slots', 0) for n in self._spawning_nodes.get(constraints, {})])
+ needed -= sum(n.get('slots', 0) for n in self._spawning_nodes.get(constraints, {}))
# ensure no less than slots_min_limit slots will exist (free or used)
needed = max(needed, self.get_limit(constraints, 'slots_min_limit'))
# ensure no more than slots_max_limit slots will exist
diff --git a/scripts/get_uwsgi_args.py b/scripts/get_uwsgi_args.py
index 8ab8a552997..80fe80319ba 100644
--- a/scripts/get_uwsgi_args.py
+++ b/scripts/get_uwsgi_args.py
@@ -86,7 +86,7 @@ def _get_uwsgi_args(cliargs, kwargs):
'pythonpath': 'lib',
'threads': '4',
'buffer-size': '16384', # https://github.com/galaxyproject/galaxy/issues/1530
- 'http': 'localhost:{port}'.format(port=DEFAULT_PORTS[cliargs.app]),
+ 'http': f'localhost:{DEFAULT_PORTS[cliargs.app]}',
'static-map': (f'/static={os.getcwd()}/static',
f'/favicon.ico={os.getcwd()}/static/favicon.ico'),
'die-on-term': True,
diff --git a/scripts/helper.py b/scripts/helper.py
index cc524d36340..97b3e394f1d 100644
--- a/scripts/helper.py
+++ b/scripts/helper.py
@@ -29,10 +29,10 @@ helper = idencoding.IdEncodingHelper(id_secret=app_properties.get('id_secret'))
model = galaxy.config.init_models_from_config(config)
if args.encode_id:
- print('Encoded "{}": {}'.format(args.encode_id, helper.encode_id(args.encode_id)))
+ print(f'Encoded "{args.encode_id}": {helper.encode_id(args.encode_id)}')
if args.decode_id:
- print('Decoded "{}": {}'.format(args.decode_id, helper.decode_id(args.decode_id)))
+ print(f'Decoded "{args.decode_id}": {helper.decode_id(args.decode_id)}')
if args.hda_id:
try:
diff --git a/scripts/microbes/harvest_bacteria.py b/scripts/microbes/harvest_bacteria.py
index b26d169a40e..f069e44f2d6 100644
--- a/scripts/microbes/harvest_bacteria.py
+++ b/scripts/microbes/harvest_bacteria.py
@@ -151,7 +151,7 @@ def process_FASTA(filename, org_num, refseq):
# Create Chrom Info File:
chrom_info_file = open(os.path.join(os.path.split(filename)[0], "%s.info" % refseq), 'wb+')
- chrom_info_file.write("chromosome={}\nname={}\nlength={}\norganism={}\n".format(refseq, chr_name, len(fasta), org_num))
+ chrom_info_file.write(f"chromosome={refseq}\nname={chr_name}\nlength={len(fasta)}\norganism={org_num}\n")
try:
chrom_info_file.write("gi=%s\n" % accesions['gi'])
except Exception:
diff --git a/scripts/microbes/util.py b/scripts/microbes/util.py
index b0e664f65e5..3a3715046c8 100644
--- a/scripts/microbes/util.py
+++ b/scripts/microbes/util.py
@@ -116,7 +116,7 @@ def get_bed_from_genbank(gb_file, chrom, feature_list):
if not name:
name = "unknown"
- features[feature_type].append("{}\t{}\t{}\t{}\t{}\t{}".format(chrom, feature.start, feature.end, name, 0, feature.strand)) # append new bed field here
+ features[feature_type].append(f"{chrom}\t{feature.start}\t{feature.end}\t{name}\t{0}\t{feature.strand}") # append new bed field here
return features
diff --git a/scripts/objectstore/copy_files_to_irods.py b/scripts/objectstore/copy_files_to_irods.py
index 50b393ebecb..bb1a5995ab0 100644
--- a/scripts/objectstore/copy_files_to_irods.py
+++ b/scripts/objectstore/copy_files_to_irods.py
@@ -79,16 +79,16 @@ def copy_files_to_irods(start_dataset_id, end_dataset_id, object_store_info_file
return
# read object_store_info file
- with open(object_store_info_file, mode="r") as osi:
+ with open(object_store_info_file) as osi:
object_store_info = json.load(osi)
osi_keys = tuple(object_store_info.keys())
# read irods_info_file
- with open(irods_info_file, mode="r") as ii:
+ with open(irods_info_file) as ii:
irods_info = json.load(ii)
# read db_connectin_info file
- with open(db_connection_info_file, mode="r") as dci:
+ with open(db_connection_info_file) as dci:
db_connection_info = json.load(dci)
try:
diff --git a/scripts/tests_markdown.py b/scripts/tests_markdown.py
index 33acd8fd858..e9b4d95f5af 100644
--- a/scripts/tests_markdown.py
+++ b/scripts/tests_markdown.py
@@ -127,7 +127,7 @@ def _merge_summarizes(raw_data_dicts):
def _prepare_raw_data(path):
- with open(path, "r") as f:
+ with open(path) as f:
inp_dict = json.load(f)
environment = dict(raw_data=inp_dict, label=os.path.basename(path))
__inject_summary(environment)
@@ -261,12 +261,12 @@ def __inject_api_timing_summary_test(test):
def __inject_statistics(from_dict):
raw_values = from_dict['raw']
from_dict['sum'] = sum(raw_values)
- from_dict['median'] = "{:.2f}".format(statistics.median(raw_values))
+ from_dict['median'] = f"{statistics.median(raw_values):.2f}"
if len(raw_values) > 1:
- from_dict['stdev'] = "{:.4f}".format(statistics.stdev(raw_values))
+ from_dict['stdev'] = f"{statistics.stdev(raw_values):.4f}"
else:
from_dict['stdev'] = "n/a"
- from_dict['mean'] = "{:.2f}".format(statistics.mean(raw_values))
+ from_dict['mean'] = f"{statistics.mean(raw_values):.2f}"
from_dict['count'] = len(raw_values)
return from_dict
diff --git a/scripts/tools/re_escape_output.py b/scripts/tools/re_escape_output.py
index 933cbd5caef..987ff6a7310 100644
--- a/scripts/tools/re_escape_output.py
+++ b/scripts/tools/re_escape_output.py
@@ -21,7 +21,7 @@ def __main__():
suffix = 're_match_multiline'
else:
suffix = 're_match'
- output = open("{}.{}".format(args[0], suffix), 'wb')
+ output = open(f"{args[0]}.{suffix}", 'wb')
if options.multiline:
lines = [re.escape(input.read())]
else:
diff --git a/test/functional/webhooks/phdcomics/__init__.py b/test/functional/webhooks/phdcomics/__init__.py
index f5053d882ae..a5979760d66 100644
--- a/test/functional/webhooks/phdcomics/__init__.py
+++ b/test/functional/webhooks/phdcomics/__init__.py
@@ -24,10 +24,10 @@ def main(trans, webhook, params):
content = urlopen(url).read()
soap = BeautifulSoup(content, 'html.parser')
pattern = r'(?:http://www\.phdcomics\.com/comics\.php\?f=)(\d+)'
- webhook.config['latest_id'] = max([
+ webhook.config['latest_id'] = max(
int(re.search(pattern, link.text).group(1))
for link in soap.find_all('link', text=re.compile(pattern))
- ])
+ )
random_id = random.randint(1, webhook.config['latest_id'])
url = 'http://www.phdcomics.com/comics/archive.php?comicid=%d' % \
diff --git a/test/integration/test_scripts.py b/test/integration/test_scripts.py
index 8c78da72f15..19c1ce239ca 100644
--- a/test/integration/test_scripts.py
+++ b/test/integration/test_scripts.py
@@ -178,7 +178,7 @@ class ScriptsIntegrationTestCase(integration_util.IntegrationTestCase):
return unicodify(subprocess.check_output(cmd, cwd=cwd, env=clean_env))
except Exception as e:
if isinstance(e, subprocess.CalledProcessError):
- raise Exception("{}\nOutput was:\n{}".format(unicodify(e), unicodify(e.output)))
+ raise Exception(f"{unicodify(e)}\nOutput was:\n{unicodify(e.output)}")
raise
def write_config_file(self):
diff --git a/test/integration/test_tool_data_delete.py b/test/integration/test_tool_data_delete.py
index cd36df938dc..fde8477a8e5 100644
--- a/test/integration/test_tool_data_delete.py
+++ b/test/integration/test_tool_data_delete.py
@@ -54,7 +54,7 @@ class AdminToolDataIntegrationTestCase(integration_util.IntegrationTestCase):
time.sleep(2)
show_response = self._get("tool_data/testbeta")
updated_fields = show_response.json()["fields"]
- self.assertEquals(len(updated_fields), original_count + 1)
+ self.assertEqual(len(updated_fields), original_count + 1)
new_field = updated_fields[-1]
url = self._api_url(f"tool_data/testbeta?key={self.galaxy_interactor.api_key}")
diff --git a/test/integration/test_workflow_scheduling_options.py b/test/integration/test_workflow_scheduling_options.py
index d8f24232413..9b4754f9b7a 100644
--- a/test/integration/test_workflow_scheduling_options.py
+++ b/test/integration/test_workflow_scheduling_options.py
@@ -124,5 +124,5 @@ input1:
name: fasta1
text_input: foo
""", history_id=history_id)
- invocation = self._get("/invocations/{}".format(invocation_response.invocation_id)).json()
+ invocation = self._get(f"/invocations/{invocation_response.invocation_id}").json()
assert 'wf_output_1' in invocation['output_collections']
diff --git a/test/unit/app/jobs/test_command_factory.py b/test/unit/app/jobs/test_command_factory.py
index 5f645cc9a1c..2cd051c7222 100644
--- a/test/unit/app/jobs/test_command_factory.py
+++ b/test/unit/app/jobs/test_command_factory.py
@@ -43,7 +43,7 @@ class TestCommandFactory(TestCase):
self.include_work_dir_outputs = False
dep_commands = [". /opt/galaxy/tools/bowtie/default/env.sh"]
self.job_wrapper.dependency_shell_commands = dep_commands
- self.__assert_command_is(_surround_command("{}; {}; return_code=$?".format(dep_commands[0], MOCK_COMMAND_LINE)))
+ self.__assert_command_is(_surround_command(f"{dep_commands[0]}; {MOCK_COMMAND_LINE}; return_code=$?"))
def test_shell_commands_external(self):
self.job_wrapper.commands_in_new_shell = True
@@ -55,7 +55,7 @@ class TestCommandFactory(TestCase):
self.job_wrapper.shell,
self.job_wrapper.working_directory,
)))
- self.__assert_tool_script_is("#!/bin/sh\n{}; {}".format(dep_commands[0], MOCK_COMMAND_LINE))
+ self.__assert_tool_script_is(f"#!/bin/sh\n{dep_commands[0]}; {MOCK_COMMAND_LINE}")
def test_remote_dependency_resolution(self):
self.include_work_dir_outputs = False
@@ -67,7 +67,7 @@ class TestCommandFactory(TestCase):
self.include_work_dir_outputs = False
dep_commands = [". /opt/galaxy/tools/bowtie/default/env.sh"]
self.job_wrapper.dependency_shell_commands = dep_commands
- self.__assert_command_is(_surround_command("{}; {}; return_code=$?".format(dep_commands[0], MOCK_COMMAND_LINE)),
+ self.__assert_command_is(_surround_command(f"{dep_commands[0]}; {MOCK_COMMAND_LINE}; return_code=$?"),
remote_command_params=dict(dependency_resolution="local"))
def test_task_prepare_inputs(self):
diff --git a/test/unit/app/jobs/test_job_configuration.py b/test/unit/app/jobs/test_job_configuration.py
index 24d9bab41fa..0e36c8c41c7 100644
--- a/test/unit/app/jobs/test_job_configuration.py
+++ b/test/unit/app/jobs/test_job_configuration.py
@@ -327,7 +327,7 @@ class AdvancedJobConfXmlParserTestCase(BaseJobConfXmlParserTestCase):
def test_destination_tags(self):
self._with_advanced_config()
- longjob_dests_ids = sorted([j.id for j in self.job_config.destinations["longjobs"]])
+ longjob_dests_ids = sorted(j.id for j in self.job_config.destinations["longjobs"])
assert len(longjob_dests_ids) == 2
assert longjob_dests_ids[0] == "pbs_longjobs"
assert longjob_dests_ids[1] == "remote_cluster"
diff --git a/test/unit/app/jobs/test_mapper.py b/test/unit/app/jobs/test_mapper.py
index be25c4ff077..05db11212fb 100644
--- a/test/unit/app/jobs/test_mapper.py
+++ b/test/unit/app/jobs/test_mapper.py
@@ -127,7 +127,7 @@ def __assert_mapper_errors_with_message(mapper, message):
except Exception as e:
exception = e
assert exception
- assert str(exception) == message, "{} != {}".format(str(exception), message)
+ assert str(exception) == message, f"{str(exception)} != {message}"
def __mapper(tool_job_destination=TOOL_JOB_DESTINATION):
diff --git a/test/unit/files/_util.py b/test/unit/files/_util.py
index 7d9eeef25af..eca9cf1fe70 100644
--- a/test/unit/files/_util.py
+++ b/test/unit/files/_util.py
@@ -67,7 +67,7 @@ def assert_realizes_as(file_sources, uri, expected, user_context=None):
file_source_path = file_sources.get_file_source_path(uri)
with tempfile.NamedTemporaryFile(mode='r') as temp:
file_source_path.file_source.realize_to(file_source_path.path, temp.name, user_context=user_context)
- with open(temp.name, "r") as f:
+ with open(temp.name) as f:
realized_contents = f.read()
if realized_contents != expected:
message = "Expected to realize contents at [{}] as [{}], instead found [{}]".format(
diff --git a/test/unit/files/test_posix.py b/test/unit/files/test_posix.py
index e8207a99a1d..dc0e75eef1c 100644
--- a/test/unit/files/test_posix.py
+++ b/test/unit/files/test_posix.py
@@ -257,7 +257,7 @@ def test_posix_user_access_requires_role():
user_context = user_context_fixture()
_assert_user_access_prohibited(file_sources, user_context)
- user_context = user_context_fixture(role_names=set([allowed_role_name]))
+ user_context = user_context_fixture(role_names={allowed_role_name})
_assert_user_access_granted(file_sources, user_context)
@@ -271,7 +271,7 @@ def test_posix_user_access_requires_group():
user_context = user_context_fixture()
_assert_user_access_prohibited(file_sources, user_context)
- user_context = user_context_fixture(group_names=set([allowed_group_name]))
+ user_context = user_context_fixture(group_names={allowed_group_name})
_assert_user_access_granted(file_sources, user_context)
@@ -298,13 +298,13 @@ def test_posix_user_access_requires_role_and_group():
}
file_sources = _configured_file_sources(writable=True, plugin_extra_config=plugin_extra_config)
- user_context = user_context_fixture(group_names=set([allowed_group_name]))
+ user_context = user_context_fixture(group_names={allowed_group_name})
_assert_user_access_prohibited(file_sources, user_context)
- user_context = user_context_fixture(role_names=set([allowed_role_name]))
+ user_context = user_context_fixture(role_names={allowed_role_name})
_assert_user_access_prohibited(file_sources, user_context)
- user_context = user_context_fixture(role_names=set([allowed_role_name]), group_names=set([allowed_group_name]))
+ user_context = user_context_fixture(role_names={allowed_role_name}, group_names={allowed_group_name})
_assert_user_access_granted(file_sources, user_context)
@@ -316,32 +316,32 @@ def test_posix_user_access_using_boolean_rules():
file_sources = _configured_file_sources(writable=True, plugin_extra_config=plugin_extra_config)
user_context = user_context_fixture(
- role_names=set([]),
- group_names=set([])
+ role_names=set(),
+ group_names=set()
)
_assert_user_access_prohibited(file_sources, user_context)
user_context = user_context_fixture(
- role_names=set(["role1"]),
- group_names=set(["group1", "group2"])
+ role_names={"role1"},
+ group_names={"group1", "group2"}
)
_assert_user_access_prohibited(file_sources, user_context)
user_context = user_context_fixture(
- role_names=set(["role1", "role3"]),
- group_names=set(["group1", "group2", "group3"])
+ role_names={"role1", "role3"},
+ group_names={"group1", "group2", "group3"}
)
_assert_user_access_prohibited(file_sources, user_context)
user_context = user_context_fixture(
- role_names=set(["role1", "role2"]),
- group_names=set(["group3", "group5"])
+ role_names={"role1", "role2"},
+ group_names={"group3", "group5"}
)
_assert_user_access_prohibited(file_sources, user_context)
user_context = user_context_fixture(
- role_names=set(["role1", "role3"]),
- group_names=set(["group1", "group2"])
+ role_names={"role1", "role3"},
+ group_names={"group1", "group2"}
)
_assert_user_access_granted(file_sources, user_context)
diff --git a/test/unit/objectstore/test_objectstore.py b/test/unit/objectstore/test_objectstore.py
index 05d296f490f..d5d926d3ee7 100644
--- a/test/unit/objectstore/test_objectstore.py
+++ b/test/unit/objectstore/test_objectstore.py
@@ -796,4 +796,4 @@ def _assert_has_keys(the_dict, keys):
def _assert_key_has_value(the_dict, key, value):
assert key in the_dict, f"dict [{key}] doesn't container expected key [{the_dict}]"
- assert the_dict[key] == value, "{} != {}".format(the_dict[key], value)
+ assert the_dict[key] == value, f"{the_dict[key]} != {value}"