diff --git a/contrib/galaxy_config_merger.py b/contrib/galaxy_config_merger.py index cedacbb44ef..880bfe3bff6 100644 --- a/contrib/galaxy_config_merger.py +++ b/contrib/galaxy_config_merger.py @@ -26,7 +26,7 @@ def main(): parser.add_option( "-o", "--output", dest="output", action="store", help="path to the new merged galaxy.ini.new file" ) - (options, args) = parser.parse_args() + options, args = parser.parse_args() for option in ["sample", "config"]: if getattr(options, option) is None: diff --git a/doc/parse_gx_xsd.py b/doc/parse_gx_xsd.py index e143c649fd5..70704a43111 100644 --- a/doc/parse_gx_xsd.py +++ b/doc/parse_gx_xsd.py @@ -106,11 +106,9 @@ def _build_tag(tag, hide_attributes): tag_help.write(text) if best_practices := _get_bp_link(annotation_el): tag_help.write("\n\n### Best Practices\n") - tag_help.write( - f""" + tag_help.write(f""" Find the Intergalactic Utilities Commission suggested best practices for this -element [here]({best_practices}).""" - ) +element [here]({best_practices}).""") tag_help.write(_build_attributes_table(tag, attributes, hide_attributes)) return tag_help.getvalue() diff --git a/lib/galaxy/actions/library.py b/lib/galaxy/actions/library.py index 75ae2aa088d..4f5f902d8b6 100644 --- a/lib/galaxy/actions/library.py +++ b/lib/galaxy/actions/library.py @@ -209,7 +209,7 @@ class LibraryActions: def _get_path_paste_uploaded_datasets(self, trans, params, library_bunch, response_code, message): preserve_dirs = util.string_as_bool(params.get("preserve_dirs", False)) uploaded_datasets = [] - (files_and_folders, _response_code, _message) = self._get_path_files_and_folders(params, preserve_dirs) + files_and_folders, _response_code, _message = self._get_path_files_and_folders(params, preserve_dirs) if _response_code: return (uploaded_datasets, _response_code, _message) for path, name, folder in files_and_folders: diff --git a/lib/galaxy/auth/providers/pam_auth.py b/lib/galaxy/auth/providers/pam_auth.py index 349d291d36d..ec9acce01e0 100644 --- a/lib/galaxy/auth/providers/pam_auth.py +++ b/lib/galaxy/auth/providers/pam_auth.py @@ -71,7 +71,7 @@ class PAM(AuthProvider): # we will be given the "public name" as username if string_as_bool(options.get("login-use-email", False)) and email is not None: if "@" in email: - (email_user, email_domain) = email.split("@") + email_user, email_domain = email.split("@") pam_username = email_user if email_domain == options.get("maildomain", None): auto_register_email = email diff --git a/lib/galaxy/celery/base_task.py b/lib/galaxy/celery/base_task.py index 31d35a7e8e1..62db58124b3 100644 --- a/lib/galaxy/celery/base_task.py +++ b/lib/galaxy/celery/base_task.py @@ -94,7 +94,7 @@ class GalaxyTaskBeforeStartUserRateLimitPostgres(GalaxyTaskBeforeStartUserRateLi if not result: sched_time = now + datetime.timedelta(seconds=task_interval_secs) upsert_stmt = ( - ps_insert(CeleryUserRateLimit) # type:ignore[attr-defined] + ps_insert(CeleryUserRateLimit) # type: ignore[attr-defined] .values(user_id=user_id, last_scheduled_time=now) .returning(CeleryUserRateLimit.last_scheduled_time) .on_conflict_do_update(index_elements=["user_id"], set_=dict(last_scheduled_time=sched_time)) diff --git a/lib/galaxy/datatypes/binary.py b/lib/galaxy/datatypes/binary.py index ed343110dce..416fcc85568 100644 --- a/lib/galaxy/datatypes/binary.py +++ b/lib/galaxy/datatypes/binary.py @@ -2913,7 +2913,7 @@ class BlibSQlite(SQlite): conn = sqlite.connect(dataset.get_file_name()) c = conn.cursor() tables_query = "SELECT majorVersion,minorVersion FROM LibInfo" - (majorVersion, minorVersion) = c.execute(tables_query).fetchall()[0] + majorVersion, minorVersion = c.execute(tables_query).fetchall()[0] dataset.metadata.blib_version = f"{majorVersion}.{minorVersion}" except Exception as e: log.warning("%s, set_meta Exception: %s", self, e) diff --git a/lib/galaxy/datatypes/blast.py b/lib/galaxy/datatypes/blast.py index fbcf447f559..2336e3fdf8f 100644 --- a/lib/galaxy/datatypes/blast.py +++ b/lib/galaxy/datatypes/blast.py @@ -30,6 +30,7 @@ Covers the ``blastxml`` format and the BLAST databases. """ + import logging import os from collections.abc import Callable diff --git a/lib/galaxy/datatypes/converters/fasta_to_len.py b/lib/galaxy/datatypes/converters/fasta_to_len.py index 489f242c6cc..f738f4d1e43 100644 --- a/lib/galaxy/datatypes/converters/fasta_to_len.py +++ b/lib/galaxy/datatypes/converters/fasta_to_len.py @@ -4,6 +4,7 @@ Input: fasta, int Output: tabular Return titles with lengths of corresponding seq """ + import sys diff --git a/lib/galaxy/datatypes/converters/fasta_to_tabular_converter.py b/lib/galaxy/datatypes/converters/fasta_to_tabular_converter.py index 45ba059dd35..1ad7d1ea747 100644 --- a/lib/galaxy/datatypes/converters/fasta_to_tabular_converter.py +++ b/lib/galaxy/datatypes/converters/fasta_to_tabular_converter.py @@ -10,6 +10,7 @@ Input: fasta Output: tabular """ + import os import sys diff --git a/lib/galaxy/datatypes/converters/fastqsolexa_to_fasta_converter.py b/lib/galaxy/datatypes/converters/fastqsolexa_to_fasta_converter.py index 2b69080a848..b3ea10bc9df 100644 --- a/lib/galaxy/datatypes/converters/fastqsolexa_to_fasta_converter.py +++ b/lib/galaxy/datatypes/converters/fastqsolexa_to_fasta_converter.py @@ -13,6 +13,7 @@ the order should be: Usage: %python fastqsolexa_to_fasta_converter.py """ + import sys diff --git a/lib/galaxy/datatypes/converters/fastqsolexa_to_qual_converter.py b/lib/galaxy/datatypes/converters/fastqsolexa_to_qual_converter.py index 0b6a79c2f3d..12b11ca9b12 100644 --- a/lib/galaxy/datatypes/converters/fastqsolexa_to_qual_converter.py +++ b/lib/galaxy/datatypes/converters/fastqsolexa_to_qual_converter.py @@ -13,6 +13,7 @@ the order should be: Usage: %python fastqsolexa_to_qual_converter.py """ + import sys diff --git a/lib/galaxy/datatypes/converters/interval_to_fli.py b/lib/galaxy/datatypes/converters/interval_to_fli.py index 78ba26256d3..f2b22ebf90f 100644 --- a/lib/galaxy/datatypes/converters/interval_to_fli.py +++ b/lib/galaxy/datatypes/converters/interval_to_fli.py @@ -32,7 +32,7 @@ def main(): # Process arguments. parser = optparse.OptionParser() parser.add_option("-F", "--format", dest="input_format") - (options, args) = parser.parse_args() + options, args = parser.parse_args() in_fname, out_fname = args input_format = options.input_format.lower() diff --git a/lib/galaxy/datatypes/converters/interval_to_interval_index_converter.py b/lib/galaxy/datatypes/converters/interval_to_interval_index_converter.py index bc96047f9d5..610b079a420 100644 --- a/lib/galaxy/datatypes/converters/interval_to_interval_index_converter.py +++ b/lib/galaxy/datatypes/converters/interval_to_interval_index_converter.py @@ -20,7 +20,7 @@ def main(): parser.add_option("-c", "--chr-col", type="int", dest="chrom_col", default=1) parser.add_option("-s", "--start-col", type="int", dest="start_col", default=2) parser.add_option("-e", "--end-col", type="int", dest="end_col", default=3) - (options, args) = parser.parse_args() + options, args = parser.parse_args() input_fname, output_fname = args # Make column indices 0-based. diff --git a/lib/galaxy/datatypes/converters/parquet_to_csv_converter.py b/lib/galaxy/datatypes/converters/parquet_to_csv_converter.py index 6646e7a9533..298abd1fb32 100644 --- a/lib/galaxy/datatypes/converters/parquet_to_csv_converter.py +++ b/lib/galaxy/datatypes/converters/parquet_to_csv_converter.py @@ -3,6 +3,7 @@ Input: parquet Output: csv """ + import os import sys diff --git a/lib/galaxy/datatypes/converters/pileup_to_interval_index_converter.py b/lib/galaxy/datatypes/converters/pileup_to_interval_index_converter.py index 5c991c88440..ce159562cd3 100644 --- a/lib/galaxy/datatypes/converters/pileup_to_interval_index_converter.py +++ b/lib/galaxy/datatypes/converters/pileup_to_interval_index_converter.py @@ -14,7 +14,7 @@ from bx.interval_index_file import Indexes def main(): # Read options, args. parser = optparse.OptionParser() - (options, args) = parser.parse_args() + options, args = parser.parse_args() input_fname, output_fname = args # Do conversion. diff --git a/lib/galaxy/datatypes/converters/ref_to_seq_taxonomy_converter.py b/lib/galaxy/datatypes/converters/ref_to_seq_taxonomy_converter.py index 097459048de..abf44d9423e 100644 --- a/lib/galaxy/datatypes/converters/ref_to_seq_taxonomy_converter.py +++ b/lib/galaxy/datatypes/converters/ref_to_seq_taxonomy_converter.py @@ -4,6 +4,7 @@ convert a ref.taxonomy file to a seq.taxonomy file Usage: %python ref_to_seq_taxonomy_converter.py """ + import re import sys diff --git a/lib/galaxy/datatypes/converters/vcf_to_interval_index_converter.py b/lib/galaxy/datatypes/converters/vcf_to_interval_index_converter.py index 873d4393091..7aa7449791f 100644 --- a/lib/galaxy/datatypes/converters/vcf_to_interval_index_converter.py +++ b/lib/galaxy/datatypes/converters/vcf_to_interval_index_converter.py @@ -12,7 +12,7 @@ from bx.interval_index_file import Indexes def main(): # Read options, args. parser = optparse.OptionParser() - (options, args) = parser.parse_args() + options, args = parser.parse_args() in_file, out_file = args # Do conversion. diff --git a/lib/galaxy/datatypes/dataproviders/__init__.py b/lib/galaxy/datatypes/dataproviders/__init__.py index b18734eda2c..3cf8f787608 100644 --- a/lib/galaxy/datatypes/dataproviders/__init__.py +++ b/lib/galaxy/datatypes/dataproviders/__init__.py @@ -15,6 +15,7 @@ can be piped from one to the other. keywords to the proper (often final) provider. These errors that result can be hard to diagnose. """ + from . import ( base, chunk, diff --git a/lib/galaxy/datatypes/dataproviders/line.py b/lib/galaxy/datatypes/dataproviders/line.py index ac2dc3a51f3..71cd2f37fbb 100644 --- a/lib/galaxy/datatypes/dataproviders/line.py +++ b/lib/galaxy/datatypes/dataproviders/line.py @@ -163,7 +163,7 @@ class BlockDataProvider(base.LimitedOffsetDataProvider): """ # composition - not inheritance # TODO: not a fan of this: - (filter_fn, limit, offset) = (kwargs.pop("filter_fn", None), kwargs.pop("limit", None), kwargs.pop("offset", 0)) + filter_fn, limit, offset = (kwargs.pop("filter_fn", None), kwargs.pop("limit", None), kwargs.pop("offset", 0)) line_provider = FilteredLineDataProvider(source, **kwargs) super().__init__(line_provider, filter_fn=filter_fn, limit=limit, offset=offset) diff --git a/lib/galaxy/datatypes/media.py b/lib/galaxy/datatypes/media.py index a695e119de9..ba5d39156a8 100644 --- a/lib/galaxy/datatypes/media.py +++ b/lib/galaxy/datatypes/media.py @@ -257,7 +257,7 @@ class Video(Binary): def set_meta(self, dataset: DatasetProtocol, overwrite: bool = True, **kwd) -> None: if which("ffprobe"): metadata, streams = ffprobe(dataset.get_file_name()) - (w, h, fps) = self._get_resolution(streams) + w, h, fps = self._get_resolution(streams) dataset.metadata.resolution_w = w dataset.metadata.resolution_h = h dataset.metadata.fps = fps diff --git a/lib/galaxy/datatypes/neo4j.py b/lib/galaxy/datatypes/neo4j.py index 0d6fec174de..29a53f6face 100644 --- a/lib/galaxy/datatypes/neo4j.py +++ b/lib/galaxy/datatypes/neo4j.py @@ -29,10 +29,8 @@ class Neo4j(Html): cannot rename the datasets here - they come with the default unfortunately """ # self.regenerate_primary_file(dataset) - rval = [ - f"Files for Composite Dataset ({self.file_ext})

\ - This composite dataset is composed of the following files:

    " - ] + rval = [f"Files for Composite Dataset ({self.file_ext})

    \ + This composite dataset is composed of the following files:

      "] for composite_name, composite_file in self.get_composite_files(dataset=dataset).items(): opt_text = "" if composite_file.optional: diff --git a/lib/galaxy/datatypes/registry.py b/lib/galaxy/datatypes/registry.py index 80bdae7b66e..d6f6811e74e 100644 --- a/lib/galaxy/datatypes/registry.py +++ b/lib/galaxy/datatypes/registry.py @@ -992,8 +992,7 @@ class Registry: def to_xml_file(self, path): if not self._registry_xml_string: - registry_string_template = Template( - """ + registry_string_template = Template(""" $datatype_elems @@ -1002,8 +1001,7 @@ class Registry: $sniffer_elems - """ - ) + """) converters_path = self.converters_path_attr or "" display_path = self.display_path_attr or "" datatype_elems = "".join(galaxy.util.xml_to_string(elem) for elem in self.datatype_elems) diff --git a/lib/galaxy/datatypes/tracks.py b/lib/galaxy/datatypes/tracks.py index e32b035abd4..c1436345c46 100644 --- a/lib/galaxy/datatypes/tracks.py +++ b/lib/galaxy/datatypes/tracks.py @@ -35,10 +35,8 @@ class UCSCTrackHub(Html): This is called only at upload to write the html file cannot rename the datasets here - they come with the default unfortunately """ - rval = [ - f"Files for Composite Dataset ({self.file_ext})

      \ - This composite dataset is composed of the following files:

        " - ] + rval = [f"Files for Composite Dataset ({self.file_ext})

        \ + This composite dataset is composed of the following files:

          "] for composite_name, composite_file in self.get_composite_files(dataset=dataset).items(): opt_text = "" if composite_file.optional: diff --git a/lib/galaxy/datatypes/util/maf_utilities.py b/lib/galaxy/datatypes/util/maf_utilities.py index eba48f71aa7..d7595bafcc0 100644 --- a/lib/galaxy/datatypes/util/maf_utilities.py +++ b/lib/galaxy/datatypes/util/maf_utilities.py @@ -2,6 +2,7 @@ """ Provides wrappers and utilities for working with MAF files and alignments. """ + # Dan Blankenberg import functools diff --git a/lib/galaxy/job_metrics/instrumenters/cgroup.py b/lib/galaxy/job_metrics/instrumenters/cgroup.py index 406dcf0da0b..4f1796c9da8 100644 --- a/lib/galaxy/job_metrics/instrumenters/cgroup.py +++ b/lib/galaxy/job_metrics/instrumenters/cgroup.py @@ -93,9 +93,7 @@ if [ -e "/proc/$$/cgroup" -a -d "{cgroup_mount}" -a ! -f "{cgroup_mount}/cgroup. echo "__$(basename $f)__" >> {metrics}; cat "$f" >> {metrics} 2>/dev/null; done; fi -""".replace( - "\n", " " -).strip() +""".replace("\n", " ").strip() CGROUPSV2_TEMPLATE = r""" if [ -e "/proc/$$/cgroup" -a -f "{cgroup_mount}/cgroup.controllers" ]; then cgroup_path=$(cat "/proc/$$/cgroup" | awk -F':' '($1=="0") {{print $3}}'); @@ -103,9 +101,7 @@ if [ -e "/proc/$$/cgroup" -a -f "{cgroup_mount}/cgroup.controllers" ]; then echo "__$(basename $f)__" >> {metrics}; cat "$f" >> {metrics} 2>/dev/null; done; fi -""".replace( - "\n", " " -).strip() +""".replace("\n", " ").strip() Metric = namedtuple("Metric", ("key", "subkey", "value")) diff --git a/lib/galaxy/job_metrics/instrumenters/env.py b/lib/galaxy/job_metrics/instrumenters/env.py index 04608833e83..e58b4b31d8b 100644 --- a/lib/galaxy/job_metrics/instrumenters/env.py +++ b/lib/galaxy/job_metrics/instrumenters/env.py @@ -66,7 +66,7 @@ class EnvPlugin(InstrumentPlugin): message = message_template % job_id log.debug(message) break - (var, value) = m.groups() + var, value = m.groups() if not variables or var in variables: properties[var] = value env_string = env_string[m.end() :] diff --git a/lib/galaxy/jobs/runners/__init__.py b/lib/galaxy/jobs/runners/__init__.py index 7048765a0a8..df346633796 100644 --- a/lib/galaxy/jobs/runners/__init__.py +++ b/lib/galaxy/jobs/runners/__init__.py @@ -148,7 +148,7 @@ class BaseJobRunner: while self._should_stop is False: with self.app.model.session(): # Create a Session instance and ensure it's closed. try: - (method, arg) = self.work_queue.get(timeout=1) + method, arg = self.work_queue.get(timeout=1) except Empty: continue if method is STOP_SIGNAL: diff --git a/lib/galaxy/jobs/runners/cli.py b/lib/galaxy/jobs/runners/cli.py index fe72d084272..3bfe38719b3 100644 --- a/lib/galaxy/jobs/runners/cli.py +++ b/lib/galaxy/jobs/runners/cli.py @@ -236,7 +236,7 @@ class ShellJobRunner(AsynchronousJobRunner[AsynchronousJobState]): } reported_jobstate = job_interface.parse_failure_reason(cmd_out.stdout, external_job_id) if reported_jobstate in jobstate_map: - (ajs.fail_message, logmsg) = jobstate_map.get(reported_jobstate) + ajs.fail_message, logmsg = jobstate_map.get(reported_jobstate) ajs.runner_state = reported_jobstate log.info(logmsg) diff --git a/lib/galaxy/jobs/runners/pbs.py b/lib/galaxy/jobs/runners/pbs.py index abd21cd2f0d..065f389b508 100644 --- a/lib/galaxy/jobs/runners/pbs.py +++ b/lib/galaxy/jobs/runners/pbs.py @@ -355,7 +355,7 @@ class PBSJobRunner(AsynchronousJobRunner[AsynchronousJobState]): """ new_watched = [] # reduce pbs load by batching status queries - (failures, statuses) = self.check_all_jobs() + failures, statuses = self.check_all_jobs() for pbs_job_state in self.watched: job_id = pbs_job_state.job_id galaxy_job_id = pbs_job_state.job_wrapper.get_id_tag() diff --git a/lib/galaxy/jobs/runners/util/cli/job/slurm.py b/lib/galaxy/jobs/runners/util/cli/job/slurm.py index 78432c397b4..0f4fd1f8563 100644 --- a/lib/galaxy/jobs/runners/util/cli/job/slurm.py +++ b/lib/galaxy/jobs/runners/util/cli/job/slurm.py @@ -115,7 +115,7 @@ class Slurm(BaseJobExec): splitjobdata = jobline.split("|") if len(splitjobdata) >= 2: - (s_jobid, s_jobstate) = splitjobdata + s_jobid, s_jobstate = splitjobdata if " " in s_jobstate: s_jobstate, s_jobotherinfo = s_jobstate.split(" ", 1) state = self.slurm_longjobstate_to_shortjobstate.get(s_jobstate, "UN") @@ -158,7 +158,7 @@ class Slurm(BaseJobExec): splitjobdata = line.split("|") log.debug(f"State split line: {len(splitjobdata)}") if len(splitjobdata) >= 2: - (s_jobid, s_jobstate) = splitjobdata + s_jobid, s_jobstate = splitjobdata if " " in s_jobstate: s_jobstate, s_jobotherinfo = s_jobstate.split(" ", 1) log.debug(f"Found space in jobstate, split into: {s_jobstate} - {s_jobotherinfo}") diff --git a/lib/galaxy/jobs/runners/util/process_groups.py b/lib/galaxy/jobs/runners/util/process_groups.py index 35a10392ce6..9a530785d51 100644 --- a/lib/galaxy/jobs/runners/util/process_groups.py +++ b/lib/galaxy/jobs/runners/util/process_groups.py @@ -10,7 +10,7 @@ log = logging.getLogger(__name__) def check_pg(pgid): """Check whether processes in process group pgid are still alive.""" try: - (pid, exit_status) = os.waitpid(-pgid, os.WNOHANG) + pid, exit_status = os.waitpid(-pgid, os.WNOHANG) except OSError as e: if e.errno == errno.ECHILD: log.debug("check_pg(): No process found in process group %d", pgid) diff --git a/lib/galaxy/managers/collections.py b/lib/galaxy/managers/collections.py index 26ab331775b..7740a1fdbef 100644 --- a/lib/galaxy/managers/collections.py +++ b/lib/galaxy/managers/collections.py @@ -916,7 +916,7 @@ class DatasetCollectionManager: def _get_collection_contents_qry(self, parent_id, limit=None, offset=None): """Build query to find first level of collection contents by containing collection parent_id""" DCE = model.DatasetCollectionElement - qry = Query(DCE).filter(DCE.dataset_collection_id == parent_id) # type:ignore[var-annotated] + qry = Query(DCE).filter(DCE.dataset_collection_id == parent_id) # type: ignore[var-annotated] qry = qry.order_by(DCE.element_index) qry = qry.options( joinedload(model.DatasetCollectionElement.child_collection), joinedload(model.DatasetCollectionElement.hda) diff --git a/lib/galaxy/managers/export_tracker.py b/lib/galaxy/managers/export_tracker.py index 14dd67dfe41..e6b4f2fba5c 100644 --- a/lib/galaxy/managers/export_tracker.py +++ b/lib/galaxy/managers/export_tracker.py @@ -41,7 +41,7 @@ class StoreExportTracker: export_association: StoreExportAssociation = self.session.execute(stmt).scalars().one() except NoResultFound: raise ObjectNotFound("Cannot set export metadata. Reason: Export association not found") - export_association.export_metadata = export_metadata.model_dump_json() # type:ignore[assignment] + export_association.export_metadata = export_metadata.model_dump_json() # type: ignore[assignment] self.session.commit() def get_export_association(self, export_association_id: int) -> StoreExportAssociation: @@ -72,4 +72,4 @@ class StoreExportTracker: stmt = stmt.offset(offset) if limit: stmt = stmt.limit(limit) - return self.session.execute(stmt).scalars() # type:ignore[return-value] + return self.session.execute(stmt).scalars() # type: ignore[return-value] diff --git a/lib/galaxy/managers/genomes.py b/lib/galaxy/managers/genomes.py index 1934bfa820f..847364e9df6 100644 --- a/lib/galaxy/managers/genomes.py +++ b/lib/galaxy/managers/genomes.py @@ -97,7 +97,7 @@ class GenomeFilterMixin: if is_postgres(self.app.config.database_connection): column = text("convert_from(metadata, 'UTF8')::json ->> 'dbkey'") else: - column = func.json_extract(model_class.table.c._metadata, "$.dbkey") # type:ignore[assignment] + column = func.json_extract(model_class.table.c._metadata, "$.dbkey") # type: ignore[assignment] lower_val = val.lower() # Ignore case # dbkey can either be "hg38" or '["hg38"]', so we need to check both if op == "eq": diff --git a/lib/galaxy/managers/history_contents.py b/lib/galaxy/managers/history_contents.py index f4c8e8e1640..5e6e77f958d 100644 --- a/lib/galaxy/managers/history_contents.py +++ b/lib/galaxy/managers/history_contents.py @@ -171,7 +171,7 @@ class HistoryContentsManager(base.SortableManager): select(sql.column("state"), func.count()).select_from(contents_subquery).group_by(sql.column("state")) ) counts = self.app.model.session.execute(statement).fetchall() - return dict(counts) # type:ignore[arg-type] + return dict(counts) # type: ignore[arg-type] def active_counts(self, history): """ diff --git a/lib/galaxy/managers/job_connections.py b/lib/galaxy/managers/job_connections.py index f90f3c7c849..0fbe0468879 100644 --- a/lib/galaxy/managers/job_connections.py +++ b/lib/galaxy/managers/job_connections.py @@ -58,7 +58,7 @@ class JobConnectionsManager: for val in graph["outputs"] + graph["inputs"]: item_class = get_class(val["src"]) item_hid = self.sa_session.execute(select(item_class.hid).where(item_class.id == val["id"])).scalar() - result.append(item_hid) # type:ignore[arg-type] + result.append(item_hid) # type: ignore[arg-type] return result def _get_union_results(self, *selects): diff --git a/lib/galaxy/managers/markdown_util.py b/lib/galaxy/managers/markdown_util.py index c0e70aa5a71..6e1f2a59a04 100644 --- a/lib/galaxy/managers/markdown_util.py +++ b/lib/galaxy/managers/markdown_util.py @@ -1283,7 +1283,7 @@ def _remap_galaxy_markdown_containers(func, markdown): match = re.search(GALAXY_FENCED_BLOCK, from_markdown) if match is not None: replace = match.group(1) - (replacement, whole_block) = func(replace) + replacement, whole_block = func(replace) if whole_block: start_pos = match.start() end_pos = match.end() diff --git a/lib/galaxy/managers/notification.py b/lib/galaxy/managers/notification.py index 35584274b4f..6891ae4f6a5 100644 --- a/lib/galaxy/managers/notification.py +++ b/lib/galaxy/managers/notification.py @@ -213,7 +213,7 @@ class NotificationManager: for user in users: try: if self._is_user_subscribed_to_notification(user, notification): - settings = self._get_user_category_settings(user, notification.category) # type:ignore[arg-type] + settings = self._get_user_category_settings(user, notification.category) # type: ignore[arg-type] self._send_via_channels(notification, user, settings.channels) except Exception as e: log.error(f"Error sending notification to user {user.id}. Reason: {util.unicodify(e)}") @@ -236,7 +236,7 @@ class NotificationManager: if self._is_urgent(notification): # Urgent notifications are always sent return True - category_settings = self._get_user_category_settings(user, notification.category) # type:ignore[arg-type] + category_settings = self._get_user_category_settings(user, notification.category) # type: ignore[arg-type] return self._is_subscribed_to_category(category_settings) def _send_via_channels(self, notification: Notification, user: User, channel_settings: NotificationChannelSettings): @@ -560,7 +560,7 @@ class DefaultStrategy(NotificationRecipientResolverStrategy): unique_user_ids.update(user_ids_from_groups_and_roles) stmt = select(User).where(User.id.in_(unique_user_ids)) - return self.sa_session.scalars(stmt).all() # type:ignore[return-value] + return self.sa_session.scalars(stmt).all() # type: ignore[return-value] def _get_all_user_ids_from_roles_query(self, role_ids: set[int]) -> Select: stmt = ( @@ -724,7 +724,7 @@ class MessageEmailNotificationTemplateBuilder(EmailNotificationTemplateBuilder): } def get_content(self, template_format: TemplateFormats) -> AnyNotificationContent: - content = MessageNotificationContent.model_construct(**self.notification.content) # type:ignore[arg-type] + content = MessageNotificationContent.model_construct(**self.notification.content) # type: ignore[arg-type] content.message = self.markdown_to[template_format](content.message) return content @@ -736,7 +736,7 @@ class MessageEmailNotificationTemplateBuilder(EmailNotificationTemplateBuilder): class NewSharedItemEmailNotificationTemplateBuilder(EmailNotificationTemplateBuilder): def get_content(self, template_format: TemplateFormats) -> AnyNotificationContent: - content = NewSharedItemNotificationContent.model_construct(**self.notification.content) # type:ignore[arg-type] + content = NewSharedItemNotificationContent.model_construct(**self.notification.content) # type: ignore[arg-type] return content def get_subject(self) -> str: diff --git a/lib/galaxy/managers/sharable.py b/lib/galaxy/managers/sharable.py index f84ab15f30f..a9f6625b32a 100644 --- a/lib/galaxy/managers/sharable.py +++ b/lib/galaxy/managers/sharable.py @@ -96,7 +96,7 @@ class SharableModelManager( # ... effectively a good fit to have this here, but not semantically if self.user_manager.is_admin(user, trans=kwargs.get("trans", None)): return True - return item.user == user # type:ignore[attr-defined] + return item.user == user # type: ignore[attr-defined] def is_accessible(self, item, user: Optional[User], **kwargs: Any) -> bool: """ diff --git a/lib/galaxy/managers/users.py b/lib/galaxy/managers/users.py index b7a6ff61221..79119941b8e 100644 --- a/lib/galaxy/managers/users.py +++ b/lib/galaxy/managers/users.py @@ -174,7 +174,7 @@ class UserManager(base.ModelManager, deletable.PurgableManagerMixin): """Get all jobs that are not ready yet and belong to the given user.""" stmt = select(Job).where(and_(Job.user_id == user.id, Job.state.in_(Job.non_ready_states))) jobs = self.session().scalars(stmt) - return jobs # type:ignore[return-value] + return jobs # type: ignore[return-value] def undelete(self, user, flush=True): """Remove the deleted flag for the given user.""" diff --git a/lib/galaxy/managers/workflows.py b/lib/galaxy/managers/workflows.py index 0582c2c9236..1a9b40e416b 100644 --- a/lib/galaxy/managers/workflows.py +++ b/lib/galaxy/managers/workflows.py @@ -202,7 +202,7 @@ class WorkflowsManager(sharable.SharableModelManager[model.StoredWorkflow], dele latest_workflow_load = joinedload(StoredWorkflow.latest_workflow) if not payload.skip_step_counts: - latest_workflow_load = latest_workflow_load.undefer(Workflow.step_count) # type:ignore[arg-type] + latest_workflow_load = latest_workflow_load.undefer(Workflow.step_count) # type: ignore[arg-type] latest_workflow_load = latest_workflow_load.lazyload(Workflow.steps) stmt = stmt.options(joinedload(StoredWorkflow.annotations)) @@ -1985,7 +1985,7 @@ class WorkflowContentsManager(UsesAnnotations): for step in steps: # Input connections if step.temp_input_connections: # populated by __module_from_dict - for input_name, conn_list in step.temp_input_connections.items(): # type:ignore[unreachable] + for input_name, conn_list in step.temp_input_connections.items(): # type: ignore[unreachable] if not conn_list: continue if not isinstance(conn_list, list): # Older style singleton connection diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index c70972861e5..6b8921ce353 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -2301,13 +2301,11 @@ class Job(Base, JobLike, UsesCreateAndUpdateTime, Dictifiable, Serializable): def set_final_state(self, final_state): self.set_state(final_state) # TODO: migrate to where-in subqueries? - statement = text( - """ + statement = text(""" UPDATE workflow_invocation_step SET update_time = :update_time WHERE job_id = :job_id; - """ - ) + """) sa_session = required_object_session(self) update_time = now() self.update_hdca_update_time_for_job(update_time=update_time, sa_session=sa_session) @@ -2337,18 +2335,15 @@ class Job(Base, JobLike, UsesCreateAndUpdateTime, Dictifiable, Serializable): def update_output_states(self, supports_skip_locked): # TODO: migrate to where-in subqueries? statements = [ - text( - """ + text(""" UPDATE dataset SET state = :state, update_time = :update_time WHERE dataset.job_id = :job_id - """ - ), - text( - """ + """), + text(""" UPDATE history_dataset_association SET info = :info, @@ -2357,10 +2352,8 @@ class Job(Base, JobLike, UsesCreateAndUpdateTime, Dictifiable, Serializable): WHERE history_dataset_association.dataset_id = dataset.id AND dataset.job_id = :job_id; - """ - ), - text( - """ + """), + text(""" UPDATE library_dataset_dataset_association SET info = :info, @@ -2369,8 +2362,7 @@ class Job(Base, JobLike, UsesCreateAndUpdateTime, Dictifiable, Serializable): WHERE library_dataset_dataset_association.dataset_id = dataset.id AND dataset.job_id = :job_id; - """ - ), + """), ] sa_session = required_object_session(self) update_time = now() @@ -6456,10 +6448,8 @@ class LibraryDataset(Base, Serializable): ) expired_datasets: Mapped[list["LibraryDatasetDatasetAssociation"]] = relationship( foreign_keys=[id, library_dataset_dataset_association_id], - primaryjoin=( - "and_(LibraryDataset.id == LibraryDatasetDatasetAssociation.library_dataset_id, \ - not_(LibraryDataset.library_dataset_dataset_association_id == LibraryDatasetDatasetAssociation.id))" - ), + primaryjoin=("and_(LibraryDataset.id == LibraryDatasetDatasetAssociation.library_dataset_id, \ + not_(LibraryDataset.library_dataset_dataset_association_id == LibraryDatasetDatasetAssociation.id))"), viewonly=True, uselist=True, ) @@ -6710,8 +6700,7 @@ class LibraryDatasetDatasetAssociation(DatasetInstance, HasName, Serializable): # sets the update_time for all continaing folders up the tree ldda = self - sql = text( - """ + sql = text(""" WITH RECURSIVE parent_folders_of(folder_id) AS (SELECT folder_id FROM library_dataset @@ -6727,8 +6716,7 @@ class LibraryDatasetDatasetAssociation(DatasetInstance, HasName, Serializable): WHERE id = :ldda_id) WHERE exists (SELECT 1 FROM parent_folders_of WHERE library_folder.id = parent_folders_of.folder_id) - """ - ) + """) with required_object_session(self).bind.connect() as conn, conn.begin(): ret = conn.execute(sql, {"library_dataset_id": ldda.library_dataset_id, "ldda_id": ldda.id}) @@ -6779,7 +6767,7 @@ class LibraryInfoAssociation(Base, RepresentById): primaryjoin=( lambda: and_( LibraryInfoAssociation.library_id == Library.id, - not_(LibraryInfoAssociation.deleted), # type:ignore[arg-type] + not_(LibraryInfoAssociation.deleted), # type: ignore[arg-type] ) ), ) @@ -7826,7 +7814,7 @@ class HistoryDatasetCollectionAssociation( def to_dict(self, view="collection"): original_dict_value = super().to_dict(view=view) if view == "dbkeysandextensions": - (dbkeys, extensions, *_) = self.dataset_dbkeys_and_extensions_summary + dbkeys, extensions, *_ = self.dataset_dbkeys_and_extensions_summary dict_value = dict( dbkey=dbkeys.pop() if len(dbkeys) == 1 else "?", extension=extensions.pop() if len(extensions) == 1 else "auto", @@ -8472,7 +8460,7 @@ class StoredWorkflow(Base, HasTags, Dictifiable, RepresentById, UsesCreateAndUpd .where(StoredWorkflow.id == self.id) ) rows = sa_session.execute(stmt).all() - rows_as_dict = dict(r for r in rows if r[0] is not None) # type:ignore[arg-type, var-annotated] + rows_as_dict = dict(r for r in rows if r[0] is not None) # type: ignore[arg-type, var-annotated] return InvocationsStateCounts(rows_as_dict) def to_dict(self, view="collection", value_mapper=None): @@ -9902,7 +9890,7 @@ class WorkflowInvocation(Base, UsesCreateAndUpdateTime, Dictifiable, Serializabl if "workflow_step_index_path" in message_dict and message_dict["workflow_step_index_path"] is not None: message_dict["workflow_step_index_path"] = message_dict["workflow_step_index_path"] self.messages.append( - WorkflowInvocationMessage( # type:ignore[abstract] + WorkflowInvocationMessage( # type: ignore[abstract] workflow_invocation_id=self.id, **message_dict, ) @@ -10604,7 +10592,7 @@ class MetadataFile(Base, StorableObject, Serializable): object_store = da.dataset.object_store store_by = object_store.get_store_by(da.dataset) if store_by == "id" and self.id is None: - self.flush() # type:ignore[unreachable] + self.flush() # type: ignore[unreachable] identifier = getattr(self, store_by) alt_name = f"metadata_{identifier}.dat" if not object_store.exists(self, extra_dir="_metadata_files", extra_dir_at_root=True, alt_name=alt_name): @@ -10788,11 +10776,11 @@ class PSAAssociation(Base, AssociationMixin, RepresentById): id: Mapped[int] = mapped_column(primary_key=True) server_url: Mapped[Optional[str]] = mapped_column(VARCHAR(255)) # type: ignore[assignment] # needed for social-auth-core Mixin class attributes - handle: Mapped[Optional[str]] = mapped_column(VARCHAR(255)) # type:ignore[assignment] - secret: Mapped[Optional[str]] = mapped_column(VARCHAR(255)) # type:ignore[assignment] - issued: Mapped[Optional[int]] # type:ignore[assignment] - lifetime: Mapped[Optional[int]] # type:ignore[assignment] - assoc_type: Mapped[Optional[str]] = mapped_column(VARCHAR(64)) # type:ignore[assignment] + handle: Mapped[Optional[str]] = mapped_column(VARCHAR(255)) # type: ignore[assignment] + secret: Mapped[Optional[str]] = mapped_column(VARCHAR(255)) # type: ignore[assignment] + issued: Mapped[Optional[int]] # type: ignore[assignment] + lifetime: Mapped[Optional[int]] # type: ignore[assignment] + assoc_type: Mapped[Optional[str]] = mapped_column(VARCHAR(64)) # type: ignore[assignment] # This static property is set at: galaxy.authnz.psa_authnz.PSAAuthnz sa_session = None @@ -10849,8 +10837,8 @@ class PSACode(Base, CodeMixin, RepresentById): __table_args__ = (UniqueConstraint("code", "email"),) id: Mapped[int] = mapped_column(primary_key=True) - email: Mapped[Optional[str]] = mapped_column(VARCHAR(200)) # type:ignore[assignment] - code: Mapped[Optional[str]] = mapped_column(VARCHAR(32)) # type:ignore[assignment] + email: Mapped[Optional[str]] = mapped_column(VARCHAR(200)) # type: ignore[assignment] + code: Mapped[Optional[str]] = mapped_column(VARCHAR(32)) # type: ignore[assignment] # This static property is set at: galaxy.authnz.psa_authnz.PSAAuthnz sa_session = None @@ -10876,9 +10864,9 @@ class PSANonce(Base, NonceMixin, RepresentById): __tablename__ = "psa_nonce" id: Mapped[int] = mapped_column(primary_key=True) - server_url: Mapped[Optional[str]] = mapped_column(VARCHAR(255)) # type:ignore[assignment] - timestamp: Mapped[Optional[int]] # type:ignore[assignment] - salt: Mapped[Optional[str]] = mapped_column(VARCHAR(40)) # type:ignore[assignment] + server_url: Mapped[Optional[str]] = mapped_column(VARCHAR(255)) # type: ignore[assignment] + timestamp: Mapped[Optional[int]] # type: ignore[assignment] + salt: Mapped[Optional[str]] = mapped_column(VARCHAR(40)) # type: ignore[assignment] # This static property is set at: galaxy.authnz.psa_authnz.PSAAuthnz sa_session = None @@ -10912,10 +10900,10 @@ class PSAPartial(Base, PartialMixin, RepresentById): __tablename__ = "psa_partial" id: Mapped[int] = mapped_column(primary_key=True) - token: Mapped[Optional[str]] = mapped_column(VARCHAR(32)) # type:ignore[assignment] - data: Mapped[Optional[str]] = mapped_column(TEXT) # type:ignore[assignment] - next_step: Mapped[Optional[int]] # type:ignore[assignment] - backend: Mapped[Optional[str]] = mapped_column(VARCHAR(32)) # type:ignore[assignment] + token: Mapped[Optional[str]] = mapped_column(VARCHAR(32)) # type: ignore[assignment] + data: Mapped[Optional[str]] = mapped_column(TEXT) # type: ignore[assignment] + next_step: Mapped[Optional[int]] # type: ignore[assignment] + backend: Mapped[Optional[str]] = mapped_column(VARCHAR(32)) # type: ignore[assignment] # This static property is set at: galaxy.authnz.psa_authnz.PSAAuthnz sa_session = None @@ -10955,14 +10943,14 @@ class UserAuthnzToken(Base, UserMixin, RepresentById): id: Mapped[int] = mapped_column(primary_key=True) user_id: Mapped[Optional[int]] = mapped_column(ForeignKey("galaxy_user.id"), index=True) - uid: Mapped[Optional[str]] = mapped_column(VARCHAR(255)) # type:ignore[assignment] - provider: Mapped[Optional[str]] = mapped_column(VARCHAR(32)) # type:ignore[assignment] - extra_data: Mapped[Optional[dict[str, Any]]] = mapped_column( # type:ignore[assignment, unused-ignore] + uid: Mapped[Optional[str]] = mapped_column(VARCHAR(255)) # type: ignore[assignment] + provider: Mapped[Optional[str]] = mapped_column(VARCHAR(32)) # type: ignore[assignment] + extra_data: Mapped[Optional[dict[str, Any]]] = mapped_column( # type: ignore[assignment, unused-ignore] MutableJSONType ) lifetime: Mapped[Optional[int]] assoc_type: Mapped[Optional[str]] = mapped_column(VARCHAR(64)) - user: Mapped[Optional["User"]] = relationship( # type:ignore[assignment, unused-ignore] + user: Mapped[Optional["User"]] = relationship( # type: ignore[assignment, unused-ignore] back_populates="social_auth" ) @@ -12606,14 +12594,14 @@ mapper_registry.map_imperatively( # ---------------------------------------------------------------------------------------- # The following statements must not precede the mapped models defined above. -History.average_rating = column_property( # type:ignore[assignment] +History.average_rating = column_property( # type: ignore[assignment] select(func.avg(HistoryRatingAssociation.rating)) .where(HistoryRatingAssociation.history_id == History.id) .scalar_subquery(), deferred=True, ) -History.users_shared_with_count = column_property( # type:ignore[assignment] +History.users_shared_with_count = column_property( # type: ignore[assignment] select(func.count(HistoryUserShareAssociation.id)) .where(History.id == HistoryUserShareAssociation.history_id) .scalar_subquery(), @@ -12625,21 +12613,21 @@ Page.average_rating = column_property( deferred=True, ) -StoredWorkflow.average_rating = column_property( # type:ignore[assignment] +StoredWorkflow.average_rating = column_property( # type: ignore[assignment] select(func.avg(StoredWorkflowRatingAssociation.rating)) .where(StoredWorkflowRatingAssociation.stored_workflow_id == StoredWorkflow.id) .scalar_subquery(), deferred=True, ) -Visualization.average_rating = column_property( # type:ignore[assignment] +Visualization.average_rating = column_property( # type: ignore[assignment] select(func.avg(VisualizationRatingAssociation.rating)) .where(VisualizationRatingAssociation.visualization_id == Visualization.id) .scalar_subquery(), deferred=True, ) -Workflow.step_count = column_property( # type:ignore[assignment] +Workflow.step_count = column_property( # type: ignore[assignment] select(func.count(WorkflowStep.id)).where(Workflow.id == WorkflowStep.workflow_id).scalar_subquery(), deferred=True ) diff --git a/lib/galaxy/model/database_utils.py b/lib/galaxy/model/database_utils.py index 15fdf283a7b..c4615f24ca9 100644 --- a/lib/galaxy/model/database_utils.py +++ b/lib/galaxy/model/database_utils.py @@ -192,6 +192,6 @@ def ensure_object_added_to_session(object_to_add, *, object_in_session=None, ses session.add(object_to_add) return True if object_in_session and object_session(object_in_session): - object_session(object_in_session).add(object_to_add) # type:ignore[union-attr] + object_session(object_in_session).add(object_to_add) # type: ignore[union-attr] return True return False diff --git a/lib/galaxy/model/migrations/alembic/versions_gxy/04288b6a5b25_make_dataset_uuids_unique.py b/lib/galaxy/model/migrations/alembic/versions_gxy/04288b6a5b25_make_dataset_uuids_unique.py index a0572676503..fd9a7fbb986 100644 --- a/lib/galaxy/model/migrations/alembic/versions_gxy/04288b6a5b25_make_dataset_uuids_unique.py +++ b/lib/galaxy/model/migrations/alembic/versions_gxy/04288b6a5b25_make_dataset_uuids_unique.py @@ -103,110 +103,92 @@ def downgrade(): def _restore_old_mappings(connection): - restore_hda_dataset_ids = text( - """ + restore_hda_dataset_ids = text(""" UPDATE history_dataset_association SET dataset_id=mapping.old_dataset_id FROM hda_dataset_mapping_pre_uuid_condense AS mapping WHERE mapping.id = history_dataset_association.id - """ - ) + """) connection.execute(restore_hda_dataset_ids) - restore_ldda_dataset_ids = text( - """ + restore_ldda_dataset_ids = text(""" UPDATE library_dataset_dataset_association SET dataset_id=mapping.old_dataset_id FROM ldda_dataset_mapping_pre_uuid_condense as mapping WHERE mapping.id = library_dataset_dataset_association.id - """ - ) + """) connection.execute(restore_ldda_dataset_ids) def _restore_dataset_uuids(connection): - restore_ldda_dataset_ids = text( - f""" + restore_ldda_dataset_ids = text(f""" UPDATE {dataset_table_name} SET {uuid_column}=backup_datasets.{uuid_column} FROM duplicate_datasets_by_uuid as backup_datasets WHERE backup_datasets.id = {dataset_table_name}.id - """ - ) + """) connection.execute(restore_ldda_dataset_ids) def _setup_duplicate_counts(connection): - duplicate_counts_query = text( - f""" + duplicate_counts_query = text(f""" CREATE TEMP TABLE temp_duplicates_counts AS SELECT {uuid_column}, COUNT(*) FROM {dataset_table_name} GROUP BY {uuid_column} HAVING COUNT(*) > 1 - """ - ) + """) connection.execute(duplicate_counts_query) def _setup_backup_datasets_for_duplicated_uuids(connection): - duplicate_datasets = text( - f""" + duplicate_datasets = text(f""" CREATE TABLE duplicate_datasets_by_uuid AS SELECT * FROM {dataset_table_name} WHERE {uuid_column} IN (select {uuid_column} from temp_duplicates_counts) - """ - ) + """) connection.execute(duplicate_datasets) def _setup_duplicated_dataset_views_by_purged_status(connection): - duplicate_purged_datasets_query = text( - """ + duplicate_purged_datasets_query = text(""" CREATE TEMP VIEW temp_duplicate_datasets_purged AS SELECT * FROM duplicate_datasets_by_uuid WHERE purged = true - """ - ) + """) connection.execute(duplicate_purged_datasets_query) - duplicate_active_datasets_query = text( - """ + duplicate_active_datasets_query = text(""" CREATE TEMP VIEW temp_duplicate_datasets_active AS SELECT * FROM duplicate_datasets_by_uuid WHERE purged = false - """ - ) + """) connection.execute(duplicate_active_datasets_query) _debug(connection, "purged duplicated", text("select count(*) from temp_duplicate_datasets_purged")) _debug(connection, "active duplicated", text("select count(*) from temp_duplicate_datasets_active")) def _find_latest_active_dataset_for_each_uuid(connection): - latest_active_duplicate_query = text( - f""" + latest_active_duplicate_query = text(f""" CREATE TEMP TABLE temp_latest_active_duplicate AS SELECT {uuid_column}, MIN(id) as latest_dataset_id FROM temp_duplicate_datasets_active GROUP BY {uuid_column} - """ - ) + """) connection.execute(latest_active_duplicate_query) debug_query = text("select * from temp_latest_active_duplicate") _debug(connection, "latest active table", debug_query) def _map_active_uuids_to_latest(connection): - active_mapping_query = text( - f""" + active_mapping_query = text(f""" CREATE TEMP TABLE temp_active_mapping AS SELECT d.id as from_dataset_id, l.latest_dataset_id as to_dataset_id, l.{uuid_column} as uuid FROM temp_duplicate_datasets_active as d LEFT JOIN temp_latest_active_duplicate l ON d.{uuid_column} = l.{uuid_column} - """ - ) + """) connection.execute(active_mapping_query) debug_query = text("select * from temp_active_mapping") _debug(connection, "temp active mapping", debug_query) @@ -215,35 +197,30 @@ def _map_active_uuids_to_latest(connection): def _randomize_uuids_for_purged_datasets_with_duplicated_uuids(connection): - updated_purged_uuids = text( - f""" + updated_purged_uuids = text(f""" UPDATE {dataset_table_name} SET uuid={new_uuid()} WHERE {uuid_column} IN (SELECT {uuid_column} FROM temp_duplicate_datasets_purged) AND purged = true - """ - ) + """) connection.execute(updated_purged_uuids) def _randomize_uuids_for_older_active_datasets_with_duplicated_uuids(connection): # sanity check... - duplicate_datasets_with_uuid_of_latest_active_uuid = text( - f""" + duplicate_datasets_with_uuid_of_latest_active_uuid = text(f""" SELECT COUNT(*) FROM {dataset_table_name} as d INNER JOIN temp_active_mapping AS a ON d.uuid = a.uuid GROUP BY d.{uuid_column} HAVING COUNT(*) > 1 - """ - ) + """) _debug( connection, "(before) duplicate_datasets_with_uuid_of_latest_active_uuid", duplicate_datasets_with_uuid_of_latest_active_uuid, ) - update_older_datasets = text( - f""" + update_older_datasets = text(f""" UPDATE {dataset_table_name} SET uuid={new_uuid()} WHERE EXISTS @@ -252,8 +229,7 @@ def _randomize_uuids_for_older_active_datasets_with_duplicated_uuids(connection) FROM temp_active_mapping as m where m.from_dataset_id = {dataset_table_name}.id and m.from_dataset_id != m.to_dataset_id ) - """ - ) + """) connection.execute(update_older_datasets) _debug( @@ -262,65 +238,53 @@ def _randomize_uuids_for_older_active_datasets_with_duplicated_uuids(connection) duplicate_datasets_with_uuid_of_latest_active_uuid, ) - duplicate_active_count = text( - """ + duplicate_active_count = text(""" SELECT COUNT(*) FROM temp_active_mapping - """ - ) + """) _debug(connection, "(after) duplicate_active_count", duplicate_active_count) - datasets_with_originally_duplicated_uuids = text( - f""" + datasets_with_originally_duplicated_uuids = text(f""" SELECT COUNT(*) FROM {dataset_table_name} as d INNER JOIN temp_active_mapping AS a ON d.uuid = a.uuid - """ - ) + """) _debug(connection, "(after) datasets_with_originally_duplicated_uuids", datasets_with_originally_duplicated_uuids) def _update_dataset_associations_to_point_to_latest_active_datasets(connection): # for others select one dataset to represent the dataset in HDAs/LDDAs - update_hda_links = text( - """ + update_hda_links = text(""" UPDATE history_dataset_association SET dataset_id=t.to_dataset_id FROM temp_active_mapping t WHERE t.from_dataset_id = dataset_id - """ - ) + """) connection.execute(update_hda_links) - update_ldda_links = text( - """ + update_ldda_links = text(""" UPDATE library_dataset_dataset_association SET dataset_id=t.to_dataset_id FROM temp_active_mapping t WHERE t.from_dataset_id = dataset_id - """ - ) + """) connection.execute(update_ldda_links) def _preserve_old_dataset_association_mappings(connection): - old_hda_mappings = text( - f""" + old_hda_mappings = text(f""" CREATE TABLE hda_dataset_mapping_pre_uuid_condense AS SELECT DISTINCT h.id as id, d.id as old_dataset_id FROM history_dataset_association AS h INNER JOIN dataset AS d ON h.dataset_id = d.id INNER JOIN duplicate_datasets_by_uuid AS duplicates ON d.{uuid_column} = duplicates.{uuid_column} - """ - ) + """) connection.execute(old_hda_mappings) - old_ldda_mappings = text( - f""" + old_ldda_mappings = text(f""" CREATE TABLE ldda_dataset_mapping_pre_uuid_condense AS SELECT l.id as id, d.id as old_dataset_id FROM library_dataset_dataset_association aS l INNER JOIN dataset AS d ON l.dataset_id = d.id INNER JOIN duplicate_datasets_by_uuid AS duplicates ON d.{uuid_column} = duplicates.{uuid_column} - """ - ) + """) connection.execute(old_ldda_mappings) diff --git a/lib/galaxy/model/migrations/data_fixes/user_table_fixer.py b/lib/galaxy/model/migrations/data_fixes/user_table_fixer.py index 4b9054872cd..61feb7646f1 100644 --- a/lib/galaxy/model/migrations/data_fixes/user_table_fixer.py +++ b/lib/galaxy/model/migrations/data_fixes/user_table_fixer.py @@ -72,14 +72,12 @@ class EmailDeduplicator: self._deduplicate_users(email, duplicates) def _get_users_with_same_email(self, email: str): - sql = text( - """ + sql = text(""" SELECT u.id, EXISTS(SELECT h.id FROM history h WHERE h.user_id = u.id) FROM galaxy_user u WHERE u.email = :email ORDER BY u.create_time - """ - ) + """) params = {"email": email} return self.connection.execute(sql, params).all() diff --git a/lib/galaxy/model/migrations/exceptions.py b/lib/galaxy/model/migrations/exceptions.py index 039bfe79d94..c1fbd2d700e 100644 --- a/lib/galaxy/model/migrations/exceptions.py +++ b/lib/galaxy/model/migrations/exceptions.py @@ -53,20 +53,16 @@ class RevisionNotFoundError(Exception): class DatabaseDoesNotExistError(Exception): def __init__(self, db_url: str) -> None: - super().__init__( - f"""The database at {db_url} does not exist. You must + super().__init__(f"""The database at {db_url} does not exist. You must create and initialize the database before running this script. You can do so by (a) running `create_db.sh`; or by (b) starting Galaxy, in which case Galaxy will create and initialize the database - automatically.""" - ) + automatically.""") class DatabaseNotInitializedError(Exception): def __init__(self, db_url: str) -> None: - super().__init__( - f"""The database at {db_url} is empty. You must + super().__init__(f"""The database at {db_url} is empty. You must initialize the database before running this script. You can do so by (a) running `create_db.sh`; or by (b) starting Galaxy, in which case - Galaxy will initialize the database automatically.""" - ) + Galaxy will initialize the database automatically.""") diff --git a/lib/galaxy/model/scripts/delete_job_metrics.py b/lib/galaxy/model/scripts/delete_job_metrics.py index eb50b9f24c4..005392a2062 100644 --- a/lib/galaxy/model/scripts/delete_job_metrics.py +++ b/lib/galaxy/model/scripts/delete_job_metrics.py @@ -42,11 +42,9 @@ def _get_parser(): def run(engine, max_update_time): """Delete galaxy_session records which were updated prior to `max_update_time`.""" - confirm = input( - f""" + confirm = input(f""" WARNING: Executing this script will permanently delete all text and numeric job metrics up to {max_update_time.strftime("%B %d, %Y")}. -Are your sure you want to proceed? Type "yes" to confirm: """ - ) +Are your sure you want to proceed? Type "yes" to confirm: """) if confirm.lower() == "yes": _delete_metrics(engine, max_update_time, "job_metric_text") _delete_metrics(engine, max_update_time, "job_metric_numeric") diff --git a/lib/galaxy/model/scripts/history_table_pruner.py b/lib/galaxy/model/scripts/history_table_pruner.py index ebd60ba063f..396e2865d1a 100644 --- a/lib/galaxy/model/scripts/history_table_pruner.py +++ b/lib/galaxy/model/scripts/history_table_pruner.py @@ -119,13 +119,11 @@ class HistoryTablePruner: def _mark_histories_as_deleted_and_purged(self, low, high): """Mark target histories as deleted and purged to prevent their further usage.""" log.info(" Marking histories as deleted and purged") - stmt = text( - """ + stmt = text(""" UPDATE history SET deleted = TRUE, purged = TRUE WHERE user_id IS NULL AND hid_counter = 1 AND create_time < :create_time AND id >= :low AND id < :high - """ - ) + """) params = self._get_stmt_params(low, high) with self.engine.begin() as conn: return conn.execute(stmt, params) diff --git a/lib/galaxy/model/security.py b/lib/galaxy/model/security.py index 2ce7863a16d..7f0bfc2095e 100644 --- a/lib/galaxy/model/security.py +++ b/lib/galaxy/model/security.py @@ -625,15 +625,13 @@ class GalaxyRBACAgent(RBACAgent): if dataset.library_associations: return False else: - query = text( - """ + query = text(""" SELECT COUNT(*) FROM history INNER JOIN history_dataset_association on history_dataset_association.history_id = history.id WHERE history.user_id != :user_id and history_dataset_association.dataset_id = :dataset_id -""" - ).bindparams(dataset_id=dataset.id, user_id=user.id if user else None) +""").bindparams(dataset_id=dataset.id, user_id=user.id if user else None) return self.sa_session.scalars(query).first() == 0 def get_item_actions(self, action, item): diff --git a/lib/galaxy/model/unittest_utils/model_testing_utils.py b/lib/galaxy/model/unittest_utils/model_testing_utils.py index a1af8dd23ba..73374290704 100644 --- a/lib/galaxy/model/unittest_utils/model_testing_utils.py +++ b/lib/galaxy/model/unittest_utils/model_testing_utils.py @@ -147,7 +147,7 @@ def drop_database(db_url, database): _drop_database(db_url, database) else: url = make_url(db_url) - os.remove(url.database) # type:ignore[arg-type] + os.remove(url.database) # type: ignore[arg-type] def dbcleanup_wrapper(session, obj, where_clause=None): diff --git a/lib/galaxy/objectstore/rucio.py b/lib/galaxy/objectstore/rucio.py index f68a33c40a3..56cb6c16a48 100644 --- a/lib/galaxy/objectstore/rucio.py +++ b/lib/galaxy/objectstore/rucio.py @@ -161,16 +161,14 @@ class RucioBroker: self.rucio_config_path = os.path.join(temp_directory, "rucio.cfg") key_for_pass = "password" with open(self.rucio_config_path, "w") as f: - f.write( - f"""[client] + f.write(f"""[client] rucio_host = {self.config['host']} auth_host = {self.config['auth_host']} account = {self.config['account']} auth_type = {self.config['auth_type']} username = {self.config['username']} {key_for_pass} = {self.config[key_for_pass]} -""" - ) +""") # We may have crossed a forkpool boundary. No harm setting the env var again. # Fixes rucio integration tests os.environ["RUCIO_CONFIG"] = self.rucio_config_path diff --git a/lib/galaxy/quota/__init__.py b/lib/galaxy/quota/__init__.py index fa223d5c590..083ac524d94 100644 --- a/lib/galaxy/quota/__init__.py +++ b/lib/galaxy/quota/__init__.py @@ -121,8 +121,7 @@ class DatabaseQuotaAgent(QuotaAgent): """ if not user: return self._default_unregistered_quota(quota_source_label) - query = text( - """ + query = text(""" SELECT ( COALESCE(MAX(CASE WHEN union_quota.operation = '=' THEN union_quota.bytes @@ -167,10 +166,7 @@ FROM ( AND group_quota.quota_source_label {label_cond} AND guser.id = :user_id ) as union_quota -""".format( - label_cond="IS NULL" if quota_source_label is None else " = :label" - ) - ) +""".format(label_cond="IS NULL" if quota_source_label is None else " = :label")) engine = self.sa_session.get_bind() with engine.connect() as conn: res = conn.execute(query, {"is_true": True, "user_id": user.id, "label": quota_source_label}).fetchone() @@ -275,16 +271,14 @@ ON CONFLICT def _default_quota(self, default_type, quota_source_label): label_condition = "IS NULL" if quota_source_label is None else "= :label" - query = text( - f""" + query = text(f""" SELECT bytes FROM quota as default_quota LEFT JOIN default_quota_association on default_quota.id = default_quota_association.quota_id WHERE default_quota_association.type = :default_type AND default_quota.deleted != :is_true AND default_quota.quota_source_label {label_condition} -""" - ) +""") engine = self.sa_session.get_bind() with engine.connect() as conn: res = conn.execute( diff --git a/lib/galaxy/tool_shed/galaxy_install/installed_repository_manager.py b/lib/galaxy/tool_shed/galaxy_install/installed_repository_manager.py index 67cbfc6e07c..0e53c48051f 100644 --- a/lib/galaxy/tool_shed/galaxy_install/installed_repository_manager.py +++ b/lib/galaxy/tool_shed/galaxy_install/installed_repository_manager.py @@ -113,7 +113,7 @@ class InstalledRepositoryManager: tpm=tpm, repository=repository, changeset_revision=repository.changeset_revision, - metadata_dict=repository.metadata_, # type:ignore[arg-type] + metadata_dict=repository.metadata_, # type: ignore[arg-type] ) repository_tools_tups = irmm.get_repository_tools_tups() # Reload tools into the appropriate tool panel section. @@ -135,7 +135,7 @@ class InstalledRepositoryManager: dmh = data_manager.DataManagerHandler(self.app) dmh.install_data_managers( self.app.config.shed_data_manager_config_file, - repository.metadata_, # type:ignore[arg-type] + repository.metadata_, # type: ignore[arg-type] repository.get_shed_config_dict(self.app), data_manager_relative_install_dir, repository, diff --git a/lib/galaxy/tool_shed/galaxy_install/metadata/installed_repository_metadata_manager.py b/lib/galaxy/tool_shed/galaxy_install/metadata/installed_repository_metadata_manager.py index f25bd46de48..11a185a8808 100644 --- a/lib/galaxy/tool_shed/galaxy_install/metadata/installed_repository_metadata_manager.py +++ b/lib/galaxy/tool_shed/galaxy_install/metadata/installed_repository_metadata_manager.py @@ -128,7 +128,7 @@ class InstalledRepositoryMetadataManager(GalaxyMetadataGenerator): original_metadata_dict = self.repository.metadata_ self.generate_metadata_for_changeset_revision() if self.metadata_dict != original_metadata_dict: - self.repository.metadata_ = self.metadata_dict # type:ignore[assignment] + self.repository.metadata_ = self.metadata_dict # type: ignore[assignment] self.update_in_shed_tool_config() session = self.app.install_model.context diff --git a/lib/galaxy/tool_shed/galaxy_install/update_repository_manager.py b/lib/galaxy/tool_shed/galaxy_install/update_repository_manager.py index f579c6ad205..c4a749f1236 100644 --- a/lib/galaxy/tool_shed/galaxy_install/update_repository_manager.py +++ b/lib/galaxy/tool_shed/galaxy_install/update_repository_manager.py @@ -113,7 +113,7 @@ class UpdateRepositoryManager: if tool_shed_status_dict: repository.tool_shed_status = tool_shed_status_dict else: - repository.tool_shed_status = None # type:ignore[assignment] + repository.tool_shed_status = None # type: ignore[assignment] session = self.app.install_model.context session.add(repository) session.commit() diff --git a/lib/galaxy/tool_shed/metadata/metadata_generator.py b/lib/galaxy/tool_shed/metadata/metadata_generator.py index 6422639bc3f..0ad9a8e6abb 100644 --- a/lib/galaxy/tool_shed/metadata/metadata_generator.py +++ b/lib/galaxy/tool_shed/metadata/metadata_generator.py @@ -870,7 +870,7 @@ class GalaxyMetadataGenerator(BaseMetadataGenerator): """A MetadataGenerator building on Galaxy's app and repository constructs.""" app: InstallationTarget - repository: Optional[ToolShedRepository] # type:ignore[assignment] + repository: Optional[ToolShedRepository] # type: ignore[assignment] def __init__( self, diff --git a/lib/galaxy/tool_shed/util/repository_util.py b/lib/galaxy/tool_shed/util/repository_util.py index d12a7fc890c..6da054d11cb 100644 --- a/lib/galaxy/tool_shed/util/repository_util.py +++ b/lib/galaxy/tool_shed/util/repository_util.py @@ -64,7 +64,7 @@ def check_for_updates( message += "Unable to retrieve status from the tool shed for the following repositories:\n" message += ", ".join(repository_names_not_updated) else: - repository = install_model_context.get(ToolShedRepository, repository_id) # type:ignore[assignment] + repository = install_model_context.get(ToolShedRepository, repository_id) # type: ignore[assignment] assert repository ok, updated = _check_or_update_tool_shed_status_for_installed_repository( tool_shed_registry, install_model_context, repository diff --git a/lib/galaxy/tool_util/deps/mulled/get_tests.py b/lib/galaxy/tool_util/deps/mulled/get_tests.py index 7ff662856d1..367d691b22b 100644 --- a/lib/galaxy/tool_util/deps/mulled/get_tests.py +++ b/lib/galaxy/tool_util/deps/mulled/get_tests.py @@ -5,6 +5,7 @@ searches for tests for packages in the bioconda-recipes repo and on Anaconda, lo A shallow search (default for singularity and conda generation scripts) just checks once on Anaconda for the specified version. """ + import json import logging from glob import glob diff --git a/lib/galaxy/tool_util/deps/mulled/mulled_build_tool.py b/lib/galaxy/tool_util/deps/mulled/mulled_build_tool.py index c5f1ccc6a88..c3064f570a4 100644 --- a/lib/galaxy/tool_util/deps/mulled/mulled_build_tool.py +++ b/lib/galaxy/tool_util/deps/mulled/mulled_build_tool.py @@ -8,6 +8,7 @@ Build mulled images for requirements defined in a tool: mulled-build-tool build path/to/tool_file.xml """ + from typing import ( List, TYPE_CHECKING, diff --git a/lib/galaxy/tool_util/deps/mulled/mulled_hash.py b/lib/galaxy/tool_util/deps/mulled/mulled_hash.py index 1cd87d5a3d0..f847c4914f5 100644 --- a/lib/galaxy/tool_util/deps/mulled/mulled_hash.py +++ b/lib/galaxy/tool_util/deps/mulled/mulled_hash.py @@ -7,6 +7,7 @@ Produce a mulled hash with: mulled-hash samtools=1.3.1,bedtools=2.22 """ + from typing_extensions import Literal from ._cli import arg_parser diff --git a/lib/galaxy/tool_util/toolbox/filters/__init__.py b/lib/galaxy/tool_util/toolbox/filters/__init__.py index aec7574b9e6..d2e1175043d 100644 --- a/lib/galaxy/tool_util/toolbox/filters/__init__.py +++ b/lib/galaxy/tool_util/toolbox/filters/__init__.py @@ -66,7 +66,7 @@ class FilterFactory: """ if ":" in filter_name: # Should be a submodule of filters (e.g. examples:restrict_development_tools) - (module_name, function_name) = filter_name.rsplit(":", 1) + module_name, function_name = filter_name.rsplit(":", 1) function = self._import_filter(module_name, function_name) else: # No module found, just load a function from this file or diff --git a/lib/galaxy/tool_util/toolbox/integrated_panel.py b/lib/galaxy/tool_util/toolbox/integrated_panel.py index 4ceb8a5ae24..d68ce96e5f2 100644 --- a/lib/galaxy/tool_util/toolbox/integrated_panel.py +++ b/lib/galaxy/tool_util/toolbox/integrated_panel.py @@ -69,16 +69,14 @@ class ManagesIntegratedToolPanelMixin: filename = os.path.join(tracking_directory, name) else: filename = destination - template = string.Template( - """ + template = string.Template(""" $INTEGRATED_TOOL_PANEL -""" - ) +""") integrated_tool_panel = [] for _, item_type, item in self._integrated_tool_panel.panel_items_iter(): if item: diff --git a/lib/galaxy/tool_util/toolbox/watcher.py b/lib/galaxy/tool_util/toolbox/watcher.py index 05db57fd304..270a4d47fdc 100644 --- a/lib/galaxy/tool_util/toolbox/watcher.py +++ b/lib/galaxy/tool_util/toolbox/watcher.py @@ -5,7 +5,7 @@ import threading try: from watchdog.events import FileSystemEventHandler except ImportError: - FileSystemEventHandler = object # type:ignore[assignment, misc, unused-ignore] + FileSystemEventHandler = object # type: ignore[assignment, misc, unused-ignore] from galaxy.util.hash_util import md5_hash_file from galaxy.util.watcher import ( diff --git a/lib/galaxy/tool_util/unittest_utils/sample_data.py b/lib/galaxy/tool_util/unittest_utils/sample_data.py index e9b19283401..6fe816a15e9 100644 --- a/lib/galaxy/tool_util/unittest_utils/sample_data.py +++ b/lib/galaxy/tool_util/unittest_utils/sample_data.py @@ -7,16 +7,14 @@ SIMPLE_TOOL_WITH_MACRO = """ """ -SIMPLE_MACRO = Template( - """ +SIMPLE_MACRO = Template(""" $tool_version -""" -) +""") VALID_XML_VALIDATORS = [ """""", diff --git a/lib/galaxy/tool_util_models/parameter_validators.py b/lib/galaxy/tool_util_models/parameter_validators.py index 7a685461f43..20eebaad333 100644 --- a/lib/galaxy/tool_util_models/parameter_validators.py +++ b/lib/galaxy/tool_util_models/parameter_validators.py @@ -475,8 +475,8 @@ AnySafeValidatorModel = Annotated[ Field(discriminator="type"), ] -DiscriminatedAnyValidatorModel = TypeAdapter(AnyValidatorModel) # type:ignore[var-annotated] -DiscriminatedAnySafeValidatorModel = TypeAdapter(AnySafeValidatorModel) # type:ignore[var-annotated] +DiscriminatedAnyValidatorModel = TypeAdapter(AnyValidatorModel) # type: ignore[var-annotated] +DiscriminatedAnySafeValidatorModel = TypeAdapter(AnySafeValidatorModel) # type: ignore[var-annotated] def raise_error_if_validation_fails( diff --git a/lib/galaxy/tool_util_models/parameters.py b/lib/galaxy/tool_util_models/parameters.py index 135f04af196..692d78e7960 100644 --- a/lib/galaxy/tool_util_models/parameters.py +++ b/lib/galaxy/tool_util_models/parameters.py @@ -816,7 +816,7 @@ AdaptedDataCollectionRequest = Annotated[ ], Field(discriminator="adapter_type"), ] -AdaptedDataCollectionRequestTypeAdapter = TypeAdapter(AdaptedDataCollectionRequest) # type:ignore[var-annotated] +AdaptedDataCollectionRequestTypeAdapter = TypeAdapter(AdaptedDataCollectionRequest) # type: ignore[var-annotated] class DatasetCollectionElementReference(StrictModel): @@ -856,7 +856,7 @@ AdaptedDataCollectionRequestInternal = Annotated[ ] AdaptedDataCollectionRequestInternalTypeAdapter = TypeAdapter( AdaptedDataCollectionRequestInternal -) # type:ignore[var-annotated] +) # type: ignore[var-annotated] class DataCollectionParameterModel(BaseGalaxyToolParameterModelDefinition): diff --git a/lib/galaxy/tool_util_models/tool_source.py b/lib/galaxy/tool_util_models/tool_source.py index b4c2fbeea61..f03109c721b 100644 --- a/lib/galaxy/tool_util_models/tool_source.py +++ b/lib/galaxy/tool_util_models/tool_source.py @@ -82,15 +82,13 @@ class JavascriptRequirement(ToolSourceBaseModel): Field( title="expression_lib", description="Provide Javascript/ECMAScript 5.1 code here that will be available for expressions inside the `shell_command` field.", - examples=[ - r"""function pickValue() { + examples=[r"""function pickValue() { if (inputs.conditional_parameter.test_parameter == "a") { return inputs.conditional_parameter.integer_parameter } else { return inputs.conditional_parameter.boolean_parameter } -}""" - ], +}"""], ), ] ] diff --git a/lib/galaxy/tools/actions/__init__.py b/lib/galaxy/tools/actions/__init__.py index 6a28b0760b1..33ff3a020c4 100644 --- a/lib/galaxy/tools/actions/__init__.py +++ b/lib/galaxy/tools/actions/__init__.py @@ -503,7 +503,7 @@ class DefaultToolAction(ToolAction): incoming[f"{name}|__identifier__"] = identifier # Collect chromInfo dataset and add as parameters to incoming - (chrom_info, db_dataset) = execution_cache.get_chrom_info(tool.id, input_dbkey) + chrom_info, db_dataset = execution_cache.get_chrom_info(tool.id, input_dbkey) if db_dataset: inp_data.update({"chromInfo": db_dataset}) diff --git a/lib/galaxy/tools/actions/upload_common.py b/lib/galaxy/tools/actions/upload_common.py index 388ca7d47a1..556167c74c8 100644 --- a/lib/galaxy/tools/actions/upload_common.py +++ b/lib/galaxy/tools/actions/upload_common.py @@ -108,7 +108,7 @@ def handle_library_params( template = session.get(FormDefinition, template_id) if template and template.fields: for field in template.fields: - field_name = field["name"] # type:ignore[index] + field_name = field["name"] # type: ignore[index] if params.get(field_name, False): field_value = util.restore_text(params.get(field_name, "")) template_field_contents[field_name] = field_value diff --git a/lib/galaxy/tools/expressions/evaluation.py b/lib/galaxy/tools/expressions/evaluation.py index f6f4786dd3b..58acd0a51db 100644 --- a/lib/galaxy/tools/expressions/evaluation.py +++ b/lib/galaxy/tools/expressions/evaluation.py @@ -66,7 +66,7 @@ def evaluate(config, input): ) input_str = f"{json.dumps(new_input)}\n\n" input_bytes = input_str.encode("utf-8") - (stdoutdata, stderrdata) = sp.communicate(input_bytes) + stdoutdata, stderrdata = sp.communicate(input_bytes) if sp.returncode != 0: message = f"Expression engine returned non-zero exit code on evaluation of\n{json.dumps(new_input, indent=4)}{stdoutdata}{stderrdata}" raise Exception(message) diff --git a/lib/galaxy/tools/imp_exp/export_history.py b/lib/galaxy/tools/imp_exp/export_history.py index c16c4768db5..c2ad1f38697 100644 --- a/lib/galaxy/tools/imp_exp/export_history.py +++ b/lib/galaxy/tools/imp_exp/export_history.py @@ -39,7 +39,7 @@ def main(argv=None): "--galaxy-version", dest="galaxy_version", help="Galaxy version that initiated the command.", default=None ) parser.add_option("--file-sources", type=str, help="file sources json") - (options, args) = parser.parse_args(argv) + options, args = parser.parse_args(argv) gzip = bool(options.gzip) assert len(args) >= 2 diff --git a/lib/galaxy/tools/imp_exp/unpack_tar_gz_archive.py b/lib/galaxy/tools/imp_exp/unpack_tar_gz_archive.py index d9aab095fba..a87c6497e4c 100644 --- a/lib/galaxy/tools/imp_exp/unpack_tar_gz_archive.py +++ b/lib/galaxy/tools/imp_exp/unpack_tar_gz_archive.py @@ -90,5 +90,5 @@ if __name__ == "__main__": help="Source and destination dir values are base64 encoded.", ) parser.add_option("--file-sources", type=str, help="file sources json") - (options, args) = parser.parse_args() + options, args = parser.parse_args() main(options, args) diff --git a/lib/galaxy/tools/parameters/basic.py b/lib/galaxy/tools/parameters/basic.py index d0a0a2c8a52..e75c813bdf2 100644 --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -2257,7 +2257,7 @@ class DataToolParameter(BaseDataToolParameter): ) match = dataset_matcher.hda_match(value_to_check) if match and match.implicit_conversion: - value_to_check.implicit_conversion = True # type:ignore[attr-defined] + value_to_check.implicit_conversion = True # type: ignore[attr-defined] elif isinstance(value_to_check, HistoryDatasetCollectionAssociation): if value_to_check.deleted: raise ParameterValueError("the previously selected dataset collection has been deleted.", self.name) diff --git a/lib/galaxy/tools/wrappers.py b/lib/galaxy/tools/wrappers.py index 9b276694b36..7f87a08fcff 100644 --- a/lib/galaxy/tools/wrappers.py +++ b/lib/galaxy/tools/wrappers.py @@ -391,7 +391,7 @@ class DatasetFilenameWrapper(ToolParameterValueWrapper): if isinstance(dataset_instance, HasTags): self.groups = { tag.user_value.lower() - for tag in dataset_instance.tags # type:ignore[unused-ignore, attr-defined] + for tag in dataset_instance.tags # type: ignore[unused-ignore, attr-defined] if tag.user_tname == "group" } else: diff --git a/lib/galaxy/util/config_templates.py b/lib/galaxy/util/config_templates.py index b0b35e2df8a..6ff34c03471 100644 --- a/lib/galaxy/util/config_templates.py +++ b/lib/galaxy/util/config_templates.py @@ -47,9 +47,9 @@ try: ) from jinja2.nativetypes import NativeEnvironment except ImportError: - NativeEnvironment = None # type:ignore[assignment, misc, unused-ignore] - StrictUndefined = None # type:ignore[assignment, misc, unused-ignore] - UndefinedError = None # type:ignore[assignment, misc, unused-ignore] + NativeEnvironment = None # type: ignore[assignment, misc, unused-ignore] + StrictUndefined = None # type: ignore[assignment, misc, unused-ignore] + UndefinedError = None # type: ignore[assignment, misc, unused-ignore] from galaxy.exceptions import ( ObjectNotFound, diff --git a/lib/galaxy/util/watcher.py b/lib/galaxy/util/watcher.py index d57188280c7..141fd8136e0 100644 --- a/lib/galaxy/util/watcher.py +++ b/lib/galaxy/util/watcher.py @@ -13,9 +13,9 @@ try: can_watch = True except ImportError: - Observer = None # type:ignore[assignment, unused-ignore] - FileSystemEventHandler = object # type:ignore[assignment,misc, unused-ignore] - PollingObserver = None # type:ignore[assignment, misc, unused-ignore] + Observer = None # type: ignore[assignment, unused-ignore] + FileSystemEventHandler = object # type: ignore[assignment,misc, unused-ignore] + PollingObserver = None # type: ignore[assignment, misc, unused-ignore] can_watch = False from galaxy.util.hash_util import md5_hash_file diff --git a/lib/galaxy/web/framework/middleware/error.py b/lib/galaxy/web/framework/middleware/error.py index df5ad74efe0..86e1738efe7 100644 --- a/lib/galaxy/web/framework/middleware/error.py +++ b/lib/galaxy/web/framework/middleware/error.py @@ -9,6 +9,7 @@ Error handler middleware When an exception is thrown from the wrapper application, this logs the exception and displays an error page. """ + import logging import sys import traceback @@ -421,12 +422,9 @@ def handle_exception( extra_data = "" reported = True else: - msg = ( - error_message - or """ + msg = error_message or """ An error occurred. """ - ) extra = "

          The error has been logged to our team." if "sentry_event_id" in environ: extra += " If you want to contact us about this error, please reference the following

          " diff --git a/lib/galaxy/web/framework/middleware/translogger.py b/lib/galaxy/web/framework/middleware/translogger.py index cd988621dfa..1d41ccd1b67 100644 --- a/lib/galaxy/web/framework/middleware/translogger.py +++ b/lib/galaxy/web/framework/middleware/translogger.py @@ -3,6 +3,7 @@ """ Middleware for logging requests, using Apache combined log format """ + import logging import time from urllib.parse import quote diff --git a/lib/galaxy/web/proxy/__init__.py b/lib/galaxy/web/proxy/__init__.py index e11d80d5949..eedcfb720c6 100644 --- a/lib/galaxy/web/proxy/__init__.py +++ b/lib/galaxy/web/proxy/__init__.py @@ -275,14 +275,12 @@ class SqliteProxyIpc: c = conn.cursor() try: # Create table - c.execute( - """CREATE TABLE gxproxy2 + c.execute("""CREATE TABLE gxproxy2 (key text PRIMARY KEY, host text, port integer, container_ids text, - container_interface text)""" - ) + container_interface text)""") except Exception: pass delete = """DELETE FROM gxproxy2 WHERE key=?""" diff --git a/lib/galaxy/webapps/galaxy/api/__init__.py b/lib/galaxy/webapps/galaxy/api/__init__.py index fcc32ac9650..2e236757f51 100644 --- a/lib/galaxy/webapps/galaxy/api/__init__.py +++ b/lib/galaxy/webapps/galaxy/api/__init__.py @@ -657,8 +657,7 @@ async def try_get_request_body_as_json(request: Request) -> Optional[Any]: return None -search_description_template = Template( - """A mix of free text and GitHub-style tags used to filter the index operation. +search_description_template = Template("""A mix of free text and GitHub-style tags used to filter the index operation. ## Query Structure @@ -683,8 +682,7 @@ ${tags} Free text search terms will be searched against the following attributes of the ${model_name}s: ${freetext}. -""" -) +""") class IndexQueryTag(NamedTuple): diff --git a/lib/galaxy/webapps/galaxy/api/jobs.py b/lib/galaxy/webapps/galaxy/api/jobs.py index aee0c277f45..96547c0d28c 100644 --- a/lib/galaxy/webapps/galaxy/api/jobs.py +++ b/lib/galaxy/webapps/galaxy/api/jobs.py @@ -338,7 +338,7 @@ class FastAPIJobs: for job_input_assoc in job.input_datasets: input_dataset_instance = job_input_assoc.dataset if input_dataset_instance is None: - continue # type:ignore[unreachable] # TODO if job_input_assoc.dataset is indeed never None, remove the above check + continue # type: ignore[unreachable] # TODO if job_input_assoc.dataset is indeed never None, remove the above check if input_dataset_instance.get_total_size() == 0: has_empty_inputs = True input_instance_id = input_dataset_instance.id diff --git a/lib/galaxy/webapps/galaxy/api/workflows.py b/lib/galaxy/webapps/galaxy/api/workflows.py index e0211e4de78..9208653ae79 100644 --- a/lib/galaxy/webapps/galaxy/api/workflows.py +++ b/lib/galaxy/webapps/galaxy/api/workflows.py @@ -1202,12 +1202,10 @@ LegacyJobStateQueryParam = Annotated[ bool, Query( title="Replace with job state", - description=( - """Populate the invocation step state with the job state instead of the invocation step state. + description=("""Populate the invocation step state with the job state instead of the invocation step state. This will also produce one step per job in mapping jobs to mimic the older behavior with respect to collections. Partially scheduled steps may provide incomplete information and the listed steps outputs - are not the mapped over step outputs but the individual job outputs.""" - ), + are not the mapped over step outputs but the individual job outputs."""), ), ] diff --git a/lib/galaxy/webapps/galaxy/services/tool_shed_repositories.py b/lib/galaxy/webapps/galaxy/services/tool_shed_repositories.py index f02c51977cc..6f2be4ed2b3 100644 --- a/lib/galaxy/webapps/galaxy/services/tool_shed_repositories.py +++ b/lib/galaxy/webapps/galaxy/services/tool_shed_repositories.py @@ -74,7 +74,7 @@ class ToolShedRepositoriesService: stmt = select(ToolShedRepository) for key, value in kwd.items(): if value is not None: - column = ToolShedRepository.__table__.c[key] # type:ignore[attr-defined] + column = ToolShedRepository.__table__.c[key] # type: ignore[attr-defined] stmt = stmt.filter(column == value) stmt = stmt.order_by(ToolShedRepository.name).order_by(cast(ToolShedRepository.ctx_rev, Integer).desc()) session = self._install_model_context diff --git a/lib/galaxy_test/api/test_datasets.py b/lib/galaxy_test/api/test_datasets.py index ab2f65a2202..a97cfe5885b 100644 --- a/lib/galaxy_test/api/test_datasets.py +++ b/lib/galaxy_test/api/test_datasets.py @@ -331,13 +331,11 @@ class TestDatasetsApi(ApiTestCase): assert input_hda["id"] == query_hda["id"] def test_display(self, history_id): - contents = textwrap.dedent( - """\ + contents = textwrap.dedent("""\ 1 2 3 4 A B C D 10 20 30 40 - """ - ) + """) hda1 = self.dataset_populator.new_dataset(history_id, content=contents, wait=True) display_response = self._get(f"histories/{history_id}/contents/{hda1['id']}/display", {"raw": "True"}) self._assert_status_code_is(display_response, 200) @@ -376,13 +374,11 @@ class TestDatasetsApi(ApiTestCase): ) def test_get_content_as_text(self, history_id): - contents = textwrap.dedent( - """\ + contents = textwrap.dedent("""\ 1 2 3 4 A B C D 10 20 30 40 - """ - ) + """) hda1 = self.dataset_populator.new_dataset(history_id, content=contents, wait=True) get_content_as_text_response = self._get(f"datasets/{hda1['id']}/get_content_as_text") self._assert_status_code_is(get_content_as_text_response, 200) @@ -414,13 +410,11 @@ class TestDatasetsApi(ApiTestCase): self._assert_status_code_is(get_content_as_text_response, 403) def test_dataprovider_chunk(self, history_id): - contents = textwrap.dedent( - """\ + contents = textwrap.dedent("""\ 1 2 3 4 A B C D 10 20 30 40 - """ - ) + """) # test first chunk hda1 = self.dataset_populator.new_dataset(history_id, content=contents, wait=True) kwds = { @@ -488,13 +482,11 @@ class TestDatasetsApi(ApiTestCase): return self.dataset_populator.display_chunk(dataset_id, offset, ck_size) def test_tabular_chunking_through_display_endpoint(self, history_id): - contents = textwrap.dedent( - """\ + contents = textwrap.dedent("""\ 1 2 3 4 A B C D 10 20 30 40 - """ - ) + """) # test first chunk hda1 = self.dataset_populator.new_dataset(history_id, content=contents, wait=True, file_type="tabular") dataset_id = hda1["id"] diff --git a/lib/galaxy_test/api/test_jobs.py b/lib/galaxy_test/api/test_jobs.py index b7fe5a2854f..ff2fcdb2a04 100644 --- a/lib/galaxy_test/api/test_jobs.py +++ b/lib/galaxy_test/api/test_jobs.py @@ -169,8 +169,7 @@ steps: @pytest.mark.require_new_history @skip_without_tool("multi_data_optional") def test_index_workflow_filter_implicit_jobs(self, history_id): - workflow_id = self.workflow_populator.upload_yaml_workflow( - """ + workflow_id = self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow inputs: input_datasets: collection @@ -179,8 +178,7 @@ steps: tool_id: multi_data_optional in: input1: input_datasets -""" - ) +""") hdca_id = self.dataset_collection_populator.create_list_of_list_in_history(history_id).json() self.dataset_populator.wait_for_history(history_id, assert_ok=True) inputs = { diff --git a/lib/galaxy_test/api/test_landing.py b/lib/galaxy_test/api/test_landing.py index 24f73af9c01..a9e4c12dd42 100644 --- a/lib/galaxy_test/api/test_landing.py +++ b/lib/galaxy_test/api/test_landing.py @@ -475,8 +475,7 @@ class TestLandingApi(ApiTestCase): """Test that executing a workflow from landing request preserves sample sheet metadata in output.""" with self.dataset_populator.test_history() as history_id: # Create a simple workflow that maps cat1 over a collection input - workflow_id = self.workflow_populator.upload_yaml_workflow( - """ + workflow_id = self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow inputs: input_collection: @@ -487,8 +486,7 @@ steps: tool_id: cat1 in: input1: input_collection -""" - ) +""") # Create request state with sample sheet collection input_b64_1 = b64encode(b"sample1 data").decode("utf-8") @@ -599,8 +597,7 @@ steps: "sample2": [2, "treatment"], } - workflow_id = self.workflow_populator.upload_yaml_workflow( - """ + workflow_id = self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow inputs: input_collection: @@ -611,8 +608,7 @@ steps: tool_id: cat1 in: input1: input_collection -""" - ) +""") # Create paired elements (forward/reverse for each sample) forward_b64_1 = b64encode(b"sample1 forward data").decode("utf-8") diff --git a/lib/galaxy_test/api/test_workflows.py b/lib/galaxy_test/api/test_workflows.py index 974d7f61e16..68221a21847 100644 --- a/lib/galaxy_test/api/test_workflows.py +++ b/lib/galaxy_test/api/test_workflows.py @@ -834,8 +834,7 @@ class TestWorkflowsApi(BaseWorkflowsApiTestCase, ChangeDatatypeTests): assert initial_instance_download["name"] == original_name def test_workflow_run_input_extension_restriction_applied(self): - workflow_id = self.workflow_populator.upload_yaml_workflow( - """ + workflow_id = self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow inputs: tabular_input: @@ -847,8 +846,7 @@ steps: tool_id: cat1 in: input1: tabular_input -""" - ) +""") with self.dataset_populator.test_history() as history_id: # Upload a txt file that should NOT be available for the tabular input self.dataset_populator.new_dataset(history_id, content="hello world", file_type="txt", wait=True) @@ -951,8 +949,7 @@ steps: assert workflow_dict["license"] == "AAL" def test_update_name_for_workflow_with_subworkflows(self): - workflow_id = self.workflow_populator.upload_yaml_workflow( - """ + workflow_id = self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow label: old name inputs: @@ -978,8 +975,7 @@ steps: tool_id: cat1 in: input1: subworkflow/output -""" - ) +""") self.workflow_populator.download_workflow(workflow_id) new_name = "my cool new name" data = {"name": new_name} @@ -1007,8 +1003,7 @@ steps: @skip_without_tool("select_from_dataset_in_conditional") def test_workflow_run_form_with_broken_dataset(self): - workflow_id = self.workflow_populator.upload_yaml_workflow( - """ + workflow_id = self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow inputs: dataset: data @@ -1024,8 +1019,7 @@ steps: inner_cond: inner_cond: single select_single: abc -""" - ) +""") with self.dataset_populator.test_history() as history_id: self.dataset_populator.new_dataset(history_id, content="a", file_type="tabular", wait=True) workflow = self._download_workflow(workflow_id, style="run", history_id=history_id) @@ -1033,8 +1027,7 @@ steps: assert workflow["steps"][1]["inputs"][0]["value"] == {"__class__": "ConnectedValue"} def test_refactor(self): - workflow_id = self.workflow_populator.upload_yaml_workflow( - """ + workflow_id = self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow inputs: test_input: data @@ -1043,8 +1036,7 @@ steps: tool_id: cat in: input1: test_input -""" - ) +""") actions = [ {"action_type": "update_step_label", "step": {"order_index": 0}, "label": "new_label"}, ] @@ -1073,8 +1065,7 @@ steps: assert workflow_dict["steps"]["0"]["label"] == "new_label" def test_refactor_tool_state_upgrade(self): - workflow_id = self.workflow_populator.upload_yaml_workflow( - """ + workflow_id = self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow inputs: {} steps: @@ -1085,8 +1076,7 @@ steps: inttest: 1 cond: bool_to_select: false -""" - ) +""") actions = [{"action_type": "upgrade_all_steps"}] refactor_response = self.workflow_populator.refactor_workflow(workflow_id, actions, dry_run=True) refactor_response.raise_for_status() @@ -1187,8 +1177,7 @@ steps: self._assert_user_has_workflow_with_name("imported: test_import_published_deprecated") def test_import_export_dynamic(self): - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow steps: - type: input @@ -1216,8 +1205,7 @@ steps: $link: embed1/output1 test_data: input1: "hello world" -""" - ) +""") downloaded_workflow = self._download_workflow(workflow_id) # The _upload_yaml_workflow entry point uses an admin key, but if we try to # do the raw re-import as a regular user we expect a 403 error. @@ -1263,8 +1251,7 @@ test_data: assert subworkflow_content_id != imported_subworkflow_content_id def test_subworkflow_inputs_optional_editor(self): - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow steps: nested_workflow: @@ -1276,8 +1263,7 @@ steps: outputs: - outputSource: inner_input/output steps: [] -""" - ) +""") workflow_contents = self._download_workflow(workflow_id, style="editor") assert workflow_contents["steps"]["0"]["inputs"][0]["optional"] @@ -1573,13 +1559,11 @@ steps: @skip_without_tool("output_filter_exception_1") def test_export_editor_filtered_outputs_exception_handling(self): - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow steps: - tool_id: output_filter_exception_1 -""" - ) +""") downloaded_workflow = self._download_workflow(workflow_id, style="editor") outputs = downloaded_workflow["steps"]["0"]["outputs"] assert len(outputs) == 2 @@ -1598,8 +1582,7 @@ steps: @skip_without_tool("collection_type_source") def test_export_editor_subworkflow_collection_type_source(self): - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow inputs: outer_input: data @@ -1621,8 +1604,7 @@ steps: input_collect: inner_input in: inner_input: outer_input -""" - ) +""") downloaded_workflow = self._download_workflow(workflow_id, style="editor") steps = downloaded_workflow["steps"] assert len(steps) == 2 @@ -1868,8 +1850,7 @@ steps: assert message["reason"] == "dataset_failed" def _run_multi_data_workflow(self, history_id, invalid_hash=False): - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow inputs: input: @@ -1880,8 +1861,7 @@ steps: tool_id: multi_data_optional in: input1: input - """ - ) + """) input_b64_1 = base64.b64encode(b"1 2 3").decode("utf-8") deferred = False hashes_1 = [ @@ -1916,8 +1896,7 @@ steps: @skip_without_tool("collection_paired_default") def test_run_workflow_with_url_paired_collection(self): with self.dataset_populator.test_history() as history_id: - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow inputs: input: @@ -1928,8 +1907,7 @@ steps: tool_id: collection_paired_default in: f1: input - """ - ) + """) forward_b64_1 = base64.b64encode(b"1 2 3").decode("utf-8") reverse_b64_2 = base64.b64encode(b"4 5 6").decode("utf-8") deferred = False @@ -2002,8 +1980,7 @@ steps: @skip_without_tool("implicit_conversion_format_input") def test_run_workflow_from_url_with_implicit_conversion_on_collection(self): with self.dataset_populator.test_history() as history_id: - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow inputs: input_fastq_gz: collection @@ -2015,8 +1992,7 @@ steps: tool_id: implicit_conversion_format_input in: input1: input_fastq_gz - """ - ) + """) base64_url = self.dataset_populator.base64_url_for_test_file("1.fasta.gz") deferred = False inputs = { @@ -2050,8 +2026,7 @@ steps: @skip_without_tool("implicit_conversion_format_input") def test_run_workflow_from_urls_with_implicit_conversion_on_collection(self): with self.dataset_populator.test_history() as history_id: - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow inputs: input_fastq_gz: File @@ -2063,8 +2038,7 @@ steps: tool_id: implicit_conversion_format_input in: input1: input_fastq_gz - """ - ) + """) base64_url = self.dataset_populator.base64_url_for_test_file("1.fasta.gz") deferred = False inputs = { @@ -2143,8 +2117,7 @@ steps: @skip_without_tool("job_properties") @skip_without_tool("identifier_multiple_in_conditional") def test_workflow_resume_from_failed_step(self): - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow steps: job_props: @@ -2167,8 +2140,7 @@ steps: in: input1: identifier/output1 queries_0|input2: identifier/output1 -""" - ) +""") with self.dataset_populator.test_history() as history_id: invocation_response = self.workflow_populator.invoke_workflow(workflow_id, history_id=history_id) invocation_id = invocation_response.json()["id"] @@ -2200,8 +2172,7 @@ steps: @skip_without_tool("job_properties") @skip_without_tool("collection_creates_list") def test_workflow_resume_from_failed_step_with_hdca_input(self): - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow steps: job_props: @@ -2217,8 +2188,7 @@ steps: tool_id: identifier_collection in: input1: list_in_list_out/list_output -""" - ) +""") with self.dataset_populator.test_history() as history_id: invocation_id = self.__invoke_workflow(workflow_id, history_id=history_id) self.workflow_populator.wait_for_invocation_and_jobs( @@ -2392,8 +2362,7 @@ test_data: @skip_without_tool("multi_data_optional") def test_workflow_list_list_multi_data_map_over(self): # Test that a list:list is reduced to list with a multiple="true" data input - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow inputs: input_datasets: collection @@ -2402,8 +2371,7 @@ steps: tool_id: multi_data_optional in: input1: input_datasets -""" - ) +""") with self.dataset_populator.test_history() as history_id: hdca_id = self.dataset_collection_populator.create_list_of_list_in_history(history_id).json() self.dataset_populator.wait_for_history(history_id, assert_ok=True) @@ -2450,8 +2418,7 @@ steps: # A more advanced output collection workflow, testing regression of # https://github.com/galaxyproject/galaxy/issues/776 with self.dataset_populator.test_history() as history_id: - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow inputs: test_input_1: data @@ -2467,8 +2434,7 @@ steps: in: queries_0|input: test_input_1 queries2_0|input2: split_up/split_output -""" - ) +""") hda1 = self.dataset_populator.new_dataset(history_id, content="samp1\t10.0\nsamp2\t20.0\n") hda2 = self.dataset_populator.new_dataset(history_id, content="samp1\t20.0\nsamp2\t40.0\n") hda3 = self.dataset_populator.new_dataset(history_id, content="samp1\t30.0\nsamp2\t60.0\n") @@ -2490,8 +2456,7 @@ steps: def test_workflow_run_dynamic_output_collections_3(self): # Test a workflow that create a list:list:list followed by a mapping step. with self.dataset_populator.test_history() as history_id: - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow inputs: text_input1: data @@ -2514,8 +2479,7 @@ steps: tool_id: cat in: input1: split_up_2/split_output -""" - ) +""") hda1 = self.dataset_populator.new_dataset(history_id, content="samp1\t10.0\nsamp2\t20.0\n") hda2 = self.dataset_populator.new_dataset(history_id, content="samp1\t30.0\nsamp2\t40.0\n") self.dataset_populator.wait_for_history(history_id, assert_ok=True) @@ -5604,8 +5568,7 @@ test_data: def _deleted_inputs_workflow(self, purge): # We run a workflow on a collection with a deleted element. with self.dataset_populator.test_history() as history_id: - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow inputs: input1: @@ -5620,8 +5583,7 @@ steps: tool_id: cat in: input1: first_cat/out_file1 -""" - ) +""") DELETED = 0 PAUSED_1 = 1 PAUSED_2 = 2 @@ -5741,8 +5703,7 @@ input1: def test_run_subworkflow_with_optional_data_unspecified(self): with self.dataset_populator.test_history() as history_id: - subworkflow = yaml.safe_load( - """ + subworkflow = yaml.safe_load(""" class: GalaxyWorkflow inputs: required: data @@ -5754,8 +5715,7 @@ test_data: required: value: 1.bed type: File -""" - ) +""") subworkflow["steps"]["nested_workflow"]["run"] = yaml.safe_load(WORKFLOW_OPTIONAL_INPUT_DELAYED_SCHEDULING) self._run_workflow( subworkflow, @@ -6237,8 +6197,7 @@ input_collection: assert "null" in filter_content, f"Expected 'null' in filter output, got: {filter_content}" def test_conditional_flat_crossproduct_subworkflow(self): - parent = yaml.safe_load( - """ + parent = yaml.safe_load(""" class: GalaxyWorkflow inputs: collection_a: collection @@ -6299,8 +6258,7 @@ test_data: content: fallbackC - identifier: fallbackD content: fallbackD -""" - ) +""") parent["steps"]["subworkflow_step"]["run"] = yaml.safe_load(WORKFLOW_FLAT_CROSS_PRODUCT) with self.dataset_populator.test_history() as history_id: summary = self._run_workflow( @@ -7809,8 +7767,7 @@ steps: @skip_without_tool("dbkey_filter_input") def test_value_restriction_with_data_meta_filter(self): - workflow_id = self.workflow_populator.upload_yaml_workflow( - """ + workflow_id = self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow inputs: select_text: @@ -7821,8 +7778,7 @@ steps: tool_id: dbkey_filter_input in: index: select_text -""" - ) +""") with self.dataset_populator.test_history() as history_id: run_workflow = self._download_workflow(workflow_id, style="run", history_id=history_id) options = run_workflow["steps"][0]["inputs"][0]["options"] @@ -7830,8 +7786,7 @@ steps: @skip_without_tool("filter_param_value") def test_value_restriction_with_filter_param_value(self): - workflow_id = self.workflow_populator.upload_yaml_workflow( - """ + workflow_id = self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow inputs: select_text: @@ -7844,8 +7799,7 @@ steps: select1: "hg19_value" in: select3: select_text -""" - ) +""") with self.dataset_populator.test_history() as history_id: run_workflow = self._download_workflow(workflow_id, style="run", history_id=history_id) options = run_workflow["steps"][0]["inputs"][0]["options"] @@ -7853,8 +7807,7 @@ steps: assert options[0] == ["hg19", "hg19_value", False] def test_value_restriction_with_select_and_text_param(self): - workflow_id = self.workflow_populator.upload_yaml_workflow( - """ + workflow_id = self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow inputs: select_text: @@ -7869,8 +7822,7 @@ steps: tool_id: param_text_option in: text_param: select_text -""" - ) +""") with self.dataset_populator.test_history() as history_id: run_workflow = self._download_workflow(workflow_id, style="run", history_id=history_id) options = run_workflow["steps"][0]["inputs"][0]["options"] @@ -7878,8 +7830,7 @@ steps: assert options[0] == ["Ex1", "--ex1", False] def test_value_restriction_with_select_from_subworkflow_input(self): - workflow_id = self.workflow_populator.upload_yaml_workflow( - """ + workflow_id = self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow inputs: Outer input parameter: @@ -7903,8 +7854,7 @@ steps: in: select_ex: source: inner input parameter -""" - ) +""") with self.dataset_populator.test_history() as history_id: run_workflow = self._download_workflow(workflow_id, style="run", history_id=history_id) options = run_workflow["steps"][0]["inputs"][0]["options"] @@ -8047,8 +7997,7 @@ steps: @skip_without_tool("validation_repeat") def test_parameter_substitution_validation_value_errors_0(self): with self.dataset_populator.test_history() as history_id: - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow steps: validation: @@ -8056,8 +8005,7 @@ steps: state: r2: - text: "abd" -""" - ) +""") workflow_request = dict( history=f"hist_id={history_id}", parameters=dumps(dict(validation_repeat={"r2_0|text": ""})) ) @@ -8071,8 +8019,7 @@ steps: # Tests what the legacy run form submits with self.dataset_populator.test_history() as history_id: hdca = self.dataset_collection_populator.create_list_of_pairs_in_history(history_id).json()["outputs"][0] - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow steps: "0": @@ -8081,8 +8028,7 @@ steps: cond: input1: __class__: RuntimeValue -""" - ) +""") workflow_request = { "history": f"hist_id={history_id}", "parameters": dumps({"0": {"cond|input1": {"values": [{"id": hdca["id"], "src": "hdca"}]}}}), @@ -8592,8 +8538,7 @@ steps: [] assert invocation_steps[1]["state"] == "ok" def test_data_input_recovery_on_delayed_input(self): - self.workflow_populator.run_workflow( - """ + self.workflow_populator.run_workflow(""" class: GalaxyWorkflow inputs: {} outputs: @@ -8628,8 +8573,7 @@ steps: in: input1: input_dataset when: - source: run_step""" - ) + source: run_step""") def test_subworkflow_output_not_found_fails(self): # This test might start failing if we ever validate connections before attempting to schedule @@ -9106,8 +9050,7 @@ class TestAdminWorkflowsApi(BaseWorkflowsApiTestCase): require_admin_user = True def test_import_export_dynamic_tools(self, history_id): - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow steps: - type: input @@ -9135,8 +9078,7 @@ steps: $link: embed1/output1 test_data: input1: "hello world" -""" - ) +""") downloaded_workflow = self._download_workflow(workflow_id) response = self.workflow_populator.create_workflow_response(downloaded_workflow) workflow_id = response.json()["id"] diff --git a/lib/galaxy_test/api/test_workflows_from_yaml.py b/lib/galaxy_test/api/test_workflows_from_yaml.py index 8aaf98c964e..6f7cbdcfa32 100644 --- a/lib/galaxy_test/api/test_workflows_from_yaml.py +++ b/lib/galaxy_test/api/test_workflows_from_yaml.py @@ -208,8 +208,7 @@ $graph: assert content == "hello world\nhello world\nhello world\nhello world\n" def test_pause(self): - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow steps: test_input: @@ -227,13 +226,11 @@ steps: tool_id: cat1 in: input1: the_pause -""" - ) +""") self.workflow_populator.dump_workflow(workflow_id) def test_implicit_connections(self): - workflow_id = self._upload_yaml_workflow( - """ + workflow_id = self._upload_yaml_workflow(""" class: GalaxyWorkflow inputs: test_input: data @@ -257,8 +254,7 @@ steps: state: input1: $link: test_input -""" - ) +""") self.workflow_populator.dump_workflow(workflow_id) def test_conditional_ints(self, history_id): diff --git a/lib/galaxy_test/driver/uses_shed.py b/lib/galaxy_test/driver/uses_shed.py index 0b1165785f6..55b4fb1333d 100644 --- a/lib/galaxy_test/driver/uses_shed.py +++ b/lib/galaxy_test/driver/uses_shed.py @@ -22,11 +22,9 @@ CONDA_AUTO_INSTALL_JOB_TIMEOUT = DEFAULT_TIMEOUT * 3 SCRIPT_DIRECTORY = os.path.abspath(os.path.dirname(__file__)) TOOL_SHEDS_CONF = os.path.join(SCRIPT_DIRECTORY, "tool_sheds_conf.xml") -SHED_TOOL_CONF = string.Template( - """ +SHED_TOOL_CONF = string.Template(""" -""" -) +""") SHED_DATA_MANAGER_CONF = """ diff --git a/lib/galaxy_test/selenium/test_custom_tools.py b/lib/galaxy_test/selenium/test_custom_tools.py index a0ef8cc84da..4aed15638a2 100644 --- a/lib/galaxy_test/selenium/test_custom_tools.py +++ b/lib/galaxy_test/selenium/test_custom_tools.py @@ -88,16 +88,13 @@ inputs: type: data """ - tool_yaml_three = ( - """ + tool_yaml_three = """ outputs: - name: output1 type: data format_source: datasets from_work_dir: output.txt """ - "" - ) # Try finding Monaco editor and replace skeleton content self.sleep_for(self.wait_types.UX_RENDER) # Allow editor to initialize # Use the stable .monaco-editor container, not .view-line which gets re-rendered diff --git a/lib/galaxy_test/selenium/test_workflow_editor.py b/lib/galaxy_test/selenium/test_workflow_editor.py index 2bcfbe60ebb..fc9cdfa68d6 100644 --- a/lib/galaxy_test/selenium/test_workflow_editor.py +++ b/lib/galaxy_test/selenium/test_workflow_editor.py @@ -329,8 +329,7 @@ class TestWorkflowEditor(SeleniumTestCase, RunsWorkflows): @selenium_only("Not yet migrated to support Playwright backend") @selenium_test def test_data_column_input_editing(self): - self.open_in_workflow_editor( - """ + self.open_in_workflow_editor(""" class: GalaxyWorkflow steps: column_param_list: @@ -338,8 +337,7 @@ steps: state: col: ["1","2","3"] col_names: ["a", "b", "c"] - """ - ) + """) editor = self.components.workflow_editor node = editor.node._(label="column_param_list") node.title.wait_for_and_click() @@ -387,8 +385,7 @@ steps: @selenium_only("Not yet migrated to support Playwright backend") @selenium_test def test_non_data_connections(self): - self.open_in_workflow_editor( - """ + self.open_in_workflow_editor(""" class: GalaxyWorkflow inputs: input_int: integer @@ -401,8 +398,7 @@ steps: cat1: # regression test, ensures connecting works in the presence of data input terminals tool_id: cat1 -""" - ) +""") self.screenshot("workflow_editor_parameter_connection_simple") self.assert_connected("input_int#output", "tool_exec#inttest") @@ -473,16 +469,14 @@ steps: @selenium_only("Not yet migrated to support Playwright backend") @selenium_test def test_connecting_display_in_upload_false_connections(self): - self.open_in_workflow_editor( - """ + self.open_in_workflow_editor(""" class: GalaxyWorkflow steps: step1: tool_id: test_sam_to_bam_conversions step2: tool_id: test_sam_to_bam_conversions - """ - ) + """) self.workflow_editor_connect("step1#qname_input_sorted_bam_output", "step2#input5") self.assert_connected("step1#qname_input_sorted_bam_output", "step2#input5") @@ -809,8 +803,7 @@ steps: embedded_workflow = yaml.safe_load(WORKFLOW_WITH_OLD_TOOL_VERSION) # Create invalid tool state embedded_workflow["steps"]["mul_versions"]["state"]["inttest"] = "Invalid" - outer_workflow = yaml.safe_load( - """ + outer_workflow = yaml.safe_load(""" class: GalaxyWorkflow inputs: outer_input: data @@ -819,8 +812,7 @@ steps: run: {} in: input1: outer_input - """ - ) + """) outer_workflow["steps"]["nested_workflow"]["run"] = embedded_workflow workflow_populator.upload_yaml_workflow(json.dumps(outer_workflow), exact_tools=True) self.workflow_index_open() @@ -843,8 +835,7 @@ steps: @selenium_only("Not yet migrated to support Playwright backend") @selenium_test def test_change_datatype(self): - self.open_in_workflow_editor( - """ + self.open_in_workflow_editor(""" class: GalaxyWorkflow inputs: [] steps: @@ -854,8 +845,7 @@ steps: label: checksum in: input: create_2/out_file1 -""" - ) +""") editor = self.components.workflow_editor self.assert_connected("create_2#out_file1", "checksum#input") node = editor.node._(label="create_2") @@ -881,8 +871,7 @@ steps: @selenium_only("Not yet migrated to support Playwright backend") @selenium_test def test_change_datatype_post_job_action_lost_regression(self): - self.open_in_workflow_editor( - """ + self.open_in_workflow_editor(""" class: GalaxyWorkflow inputs: [] steps: @@ -895,8 +884,7 @@ steps: label: metadata_bam in: input_bam: create_2/out_file1 -""" - ) +""") self.assert_connected("create_2#out_file1", "metadata_bam#input_bam") editor = self.components.workflow_editor node = editor.node._(label="create_2") @@ -906,8 +894,7 @@ steps: @selenium_only("Not yet migrated to support Playwright backend") @selenium_test def test_change_datatype_in_subworkflow(self): - self.open_in_workflow_editor( - """ + self.open_in_workflow_editor(""" class: GalaxyWorkflow inputs: [] steps: @@ -926,8 +913,7 @@ steps: outputSource: create_2/out_file1 metadata_bam: tool_id: metadata_bam -""" - ) +""") editor = self.components.workflow_editor node = editor.node._(label="nested_workflow") node.wait_for_and_click() @@ -941,8 +927,7 @@ steps: @selenium_only("Not yet migrated to support Playwright backend") @selenium_test def test_edit_subworkflow(self): - self.open_in_workflow_editor( - """ + self.open_in_workflow_editor(""" class: GalaxyWorkflow inputs: [] steps: @@ -953,8 +938,7 @@ steps: steps: - tool_id: create_2 label: create_2 -""" - ) +""") editor = self.components.workflow_editor node = editor.node._(label="nested_workflow") node.wait_for_and_click() @@ -1014,8 +998,7 @@ steps: workflow_populator = self.workflow_populator child_workflow_name = self._get_random_name() workflow_populator.upload_yaml_workflow(WORKFLOW_OPTIONAL_TRUE_INPUT_COLLECTION, name=child_workflow_name) - parent_workflow_id = workflow_populator.upload_yaml_workflow( - """class: GalaxyWorkflow + parent_workflow_id = workflow_populator.upload_yaml_workflow("""class: GalaxyWorkflow inputs: input_collection: type: collection @@ -1026,8 +1009,7 @@ steps: label: multiple_versions state: foo: bar - """ - ) + """) self.workflow_index_open() self.components.workflows.edit_button.wait_for_and_click() editor = self.components.workflow_editor @@ -1170,8 +1152,7 @@ steps: @selenium_test def test_missing_tools(self): workflow_populator = self.workflow_populator - workflow_populator.upload_yaml_workflow( - """ + workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow inputs: - id: input1 @@ -1180,8 +1161,7 @@ steps: label: first_cat state: foo: bar -""" - ) +""") self.workflow_index_open() self.components.workflows.edit_button.wait_for_and_click() self.assert_modal_has_text("Tool is not installed") @@ -1245,14 +1225,12 @@ steps: @selenium_only("Not yet migrated to support Playwright backend") @selenium_test def test_insert_input_handling(self): - self.open_in_workflow_editor( - """class: GalaxyWorkflow + self.open_in_workflow_editor("""class: GalaxyWorkflow inputs: [] steps: build_list: tool_id: __BUILD_LIST__ - """ - ) + """) editor = self.components.workflow_editor node = editor.node._(label="build_list") node.wait_for_and_click() @@ -1338,8 +1316,7 @@ steps: @selenium_only("Not yet migrated to support Playwright backend") @selenium_test def test_map_over_output_indicator(self): - self.open_in_workflow_editor( - """ + self.open_in_workflow_editor(""" class: GalaxyWorkflow inputs: list: @@ -1351,8 +1328,7 @@ inputs: steps: filter: tool_id: __FILTER_FROM_FILE__ -""" - ) +""") self.assert_node_output_is("filter#output_filtered", "any") self.workflow_editor_connect("list#output", "filter#input") self.assert_node_output_is("filter#output_filtered", "list") diff --git a/lib/galaxy_test/selenium/test_workflow_run.py b/lib/galaxy_test/selenium/test_workflow_run.py index 31334e166ad..863689ce1c7 100644 --- a/lib/galaxy_test/selenium/test_workflow_run.py +++ b/lib/galaxy_test/selenium/test_workflow_run.py @@ -399,8 +399,7 @@ SRR5681005\tinput\t\t @selenium_test @managed_history def test_runtime_parameters_simple_optional(self): - self.workflow_run_open_workflow( - """ + self.workflow_run_open_workflow(""" class: GalaxyWorkflow inputs: {} steps: @@ -408,8 +407,7 @@ steps: tool_id: expression_null_handling_integer runtime_inputs: - int_input -""" - ) +""") self.tool_parameter_div("int_input") self._set_num_lines_to_3("int_input") self.screenshot("workflow_run_optional_runtime_parameters_modified") @@ -473,8 +471,7 @@ steps: def test_step_parameter_inputs(self): self.perform_upload(self.get_filename("1.txt")) self.wait_for_history() - self.workflow_run_open_workflow( - """ + self.workflow_run_open_workflow(""" class: GalaxyWorkflow inputs: input_int: integer @@ -486,8 +483,7 @@ steps: in: inttest: input_int files_0|file: input_data -""" - ) +""") self.workflow_run_ensure_expanded() workflow_run = self.components.workflow_run input_div_element = workflow_run.input_div(label="input_int").wait_for_visible() @@ -569,8 +565,7 @@ steps: @selenium_test @managed_history def test_execution_with_text_default_value_connected_to_restricted_select(self): - self.workflow_run_open_workflow( - """ + self.workflow_run_open_workflow(""" class: GalaxyWorkflow inputs: text_param: @@ -584,8 +579,7 @@ steps: in: select_ex: source: text_param -""" - ) +""") element = self.components.workflow_run.input_select_field(label="text_param").wait_for_present() assert element.text == "Ex2" self.workflow_run_submit() @@ -634,8 +628,7 @@ steps: @selenium_test @managed_history def test_workflow_run_button_disabled_when_required_input_missing(self): - self.workflow_run_open_workflow( - """ + self.workflow_run_open_workflow(""" class: GalaxyWorkflow inputs: text_param: @@ -646,8 +639,7 @@ inputs: collection_param: type: data_collection steps: {} -""" - ) +""") workflow_run = self.components.workflow_run # None of the required parameters are present workflow_run.run_workflow_disabled.wait_for_present() diff --git a/lib/tool_shed/metadata/repository_metadata_manager.py b/lib/tool_shed/metadata/repository_metadata_manager.py index 5c26eb70f10..b475d56a41c 100644 --- a/lib/tool_shed/metadata/repository_metadata_manager.py +++ b/lib/tool_shed/metadata/repository_metadata_manager.py @@ -46,7 +46,7 @@ class ToolShedMetadataGenerator(BaseMetadataGenerator): """A MetadataGenerator building on ToolShed's app and repository constructs.""" app: ToolShedApp - repository: Optional[Repository] # type:ignore[assignment] + repository: Optional[Repository] # type: ignore[assignment] # why is mypy making me re-annotate these things from the base class, it didn't # when they were in the same file diff --git a/lib/tool_shed/test/base/playwrightbrowser.py b/lib/tool_shed/test/base/playwrightbrowser.py index 62c55917eee..e4726cf7b92 100644 --- a/lib/tool_shed/test/base/playwrightbrowser.py +++ b/lib/tool_shed/test/base/playwrightbrowser.py @@ -131,7 +131,7 @@ class PlaywrightShedBrowser(ShedBrowser): input_s = form.locator(f"select[name='{control_name}']") if input_i.count(): if control_name in ["redirect"]: - input_i.input_value = value # type:ignore[assignment, unused-ignore] + input_i.input_value = value # type: ignore[assignment, unused-ignore] else: if isinstance(value, bool): if value and not input_i.is_checked(): @@ -141,9 +141,9 @@ class PlaywrightShedBrowser(ShedBrowser): else: input_i.fill(value) if input_t.count(): - input_t.fill(value) # type:ignore[arg-type, unused-ignore] + input_t.fill(value) # type: ignore[arg-type, unused-ignore] if input_s.count(): - input_s.select_option(value) # type:ignore[arg-type, unused-ignore] + input_s.select_option(value) # type: ignore[arg-type, unused-ignore] def edit_repository_categories(self, categories_to_add: list[str], categories_to_remove: list[str]) -> None: multi_select = "form[name='categories'] select[name='category_id']" diff --git a/lib/tool_shed/test/base/twillbrowser.py b/lib/tool_shed/test/base/twillbrowser.py index 2630c7b6145..6b294914423 100644 --- a/lib/tool_shed/test/base/twillbrowser.py +++ b/lib/tool_shed/test/base/twillbrowser.py @@ -1,7 +1,7 @@ import tempfile import twill.commands as tc -from twill.browser import FormElement # type:ignore[attr-defined, unused-ignore] +from twill.browser import FormElement # type: ignore[attr-defined, unused-ignore] from galaxy.util import smart_str from .browser import ( diff --git a/lib/tool_shed/test/base/twilltestcase.py b/lib/tool_shed/test/base/twilltestcase.py index bf6bfd3bc5f..6cd16a055bb 100644 --- a/lib/tool_shed/test/base/twilltestcase.py +++ b/lib/tool_shed/test/base/twilltestcase.py @@ -1295,7 +1295,7 @@ class ShedTwillTestCase(ShedApiTestCase): # assert original_information[input_elem_name] for input_elem_name in ["repo_name", "description", "long_description"]: self._browser.fill_form_value( - "edit_repository", input_elem_name, original_information[input_elem_name] # type:ignore[arg-type] + "edit_repository", input_elem_name, original_information[input_elem_name] # type: ignore[arg-type] ) strings_displayed.append(self.escape_html(original_information[input_elem_name])) self._browser.submit_form_with_name("edit_repository", "edit_repository_button") @@ -2046,7 +2046,7 @@ class ShedTwillTestCase(ShedApiTestCase): assert "tools" in installed_repository.metadata_, f"No valid tools were defined in {installed_repository.name}." tools = installed_repository.metadata_["tools"] found_it = False - for tool in tools: # type:ignore[attr-defined] + for tool in tools: # type: ignore[attr-defined] if "id" not in tool: continue if tool["id"] == tool_id: diff --git a/lib/tool_shed/util/shed_util_common.py b/lib/tool_shed/util/shed_util_common.py index d1629622c2b..d739ac568d1 100644 --- a/lib/tool_shed/util/shed_util_common.py +++ b/lib/tool_shed/util/shed_util_common.py @@ -283,7 +283,7 @@ def handle_email_alerts( email_alerts.append(user.email) else: subject = f"Galaxy tool shed update alert for repository named {str(repository.name)}" - email_alerts = json.loads(repository.email_alerts) # type:ignore[arg-type] + email_alerts = json.loads(repository.email_alerts) # type: ignore[arg-type] for email in email_alerts: to = email.strip() # Send it diff --git a/scripts/api/copy_hda_to_library_folder.py b/scripts/api/copy_hda_to_library_folder.py index e997c330e6f..b491aa9928a 100755 --- a/scripts/api/copy_hda_to_library_folder.py +++ b/scripts/api/copy_hda_to_library_folder.py @@ -26,7 +26,7 @@ if __name__ == "__main__": print(usage, file=sys.stderr) sys.exit(1) - (base_url, key, hda_id, library_id, folder_id) = sys.argv[1:6] + base_url, key, hda_id, library_id, folder_id = sys.argv[1:6] message = "" if num_args >= 7: diff --git a/scripts/api/create.py b/scripts/api/create.py index 378d3cb52fa..209f688ca62 100644 --- a/scripts/api/create.py +++ b/scripts/api/create.py @@ -4,6 +4,7 @@ Generic POST/create script usage: create.py key url [key=value ...] """ + import sys from common import submit diff --git a/scripts/api/data_manager_example_execute.py b/scripts/api/data_manager_example_execute.py index 3bac2833da9..df55c4ee933 100644 --- a/scripts/api/data_manager_example_execute.py +++ b/scripts/api/data_manager_example_execute.py @@ -87,7 +87,7 @@ if __name__ == "__main__": default=DEFAULT_SLEEP_TIME, help="How long to sleep between check loops", ) - (options, args) = parser.parse_args() + options, args = parser.parse_args() # check options assert options.api_key is not None, ValueError("You must specify an API key.") diff --git a/scripts/api/delete.py b/scripts/api/delete.py index 5780f3f723d..ec1f9efc478 100644 --- a/scripts/api/delete.py +++ b/scripts/api/delete.py @@ -4,6 +4,7 @@ Generic DELETE/delete script usage: delete.py key url """ + import sys from common import delete diff --git a/scripts/api/library_upload_dir.py b/scripts/api/library_upload_dir.py index a85a1b550a7..0b8af9a9898 100644 --- a/scripts/api/library_upload_dir.py +++ b/scripts/api/library_upload_dir.py @@ -115,7 +115,7 @@ class Uploader: all_files = [x.strip() for x in list(sys.stdin.readlines())] for idx, path in enumerate(all_files): - (dirName, fname) = path.rsplit(os.path.sep, 1) + dirName, fname = path.rsplit(os.path.sep, 1) if not os.path.exists(os.path.join(dirName, fname)): continue # Figure out what the memo key will be early diff --git a/scripts/api/reset_metadata_on_installed_repositories.py b/scripts/api/reset_metadata_on_installed_repositories.py index 69cdd09d8cb..6dbe9641ba9 100644 --- a/scripts/api/reset_metadata_on_installed_repositories.py +++ b/scripts/api/reset_metadata_on_installed_repositories.py @@ -8,6 +8,7 @@ usage: reset_metadata_on_installed_repositories.py key Here is a working example of how to use this script. python ./reset_metadata_on_installed_repositories.py -a 22be3b -u http://localhost:8763/ """ + import argparse from common import submit diff --git a/scripts/api/update.py b/scripts/api/update.py index cd21e139298..a7333350c04 100644 --- a/scripts/api/update.py +++ b/scripts/api/update.py @@ -4,6 +4,7 @@ Generic PUT/update script usage: create.py key url [key=value ...] """ + import sys from common import update diff --git a/scripts/cwl_conformance_to_test_cases.py b/scripts/cwl_conformance_to_test_cases.py index 1a440c00ab5..4ee3f2ff15e 100644 --- a/scripts/cwl_conformance_to_test_cases.py +++ b/scripts/cwl_conformance_to_test_cases.py @@ -8,8 +8,7 @@ THIS_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) GALAXY_ROOT_DIR = os.path.abspath(os.path.join(THIS_DIRECTORY, os.pardir)) CWL_API_TESTS_DIRECTORY = os.path.join(GALAXY_ROOT_DIR, "lib", "galaxy_test", "api", "cwl") -TEST_FILE_TEMPLATE = string.Template( - '''"""Test CWL conformance for version ${version}.""" +TEST_FILE_TEMPLATE = string.Template('''"""Test CWL conformance for version ${version}.""" import pytest @@ -18,11 +17,9 @@ from ..test_workflows_cwl import BaseCwlWorkflowsApiTestCase class TestCwlConformance(BaseCwlWorkflowsApiTestCase): """Test case mapping to CWL conformance tests for version ${version}.""" -$tests''' -) +$tests''') -TEST_TEMPLATE = string.Template( - ''' +TEST_TEMPLATE = string.Template(''' ${marks} def test_conformance_${version_simple}_${id_}(self): """${doc} @@ -31,8 +28,7 @@ ${marks} def test_conformance_${version_simple}_${id_}(self): ${cwl_test_def} """ # noqa: W293 self.cwl_populator.run_conformance_test("""${version}""", """${doc}""") -''' -) +''') RED_TESTS = { "v1.0": [ diff --git a/scripts/external_chown_script.py b/scripts/external_chown_script.py index a08116b94a4..015d449d1cb 100755 --- a/scripts/external_chown_script.py +++ b/scripts/external_chown_script.py @@ -41,7 +41,7 @@ def main(): path, galaxy_user_name, gid = validate_parameters() for cmd in [["chown", "-Rh", galaxy_user_name, path], ["chgrp", "-Rh", gid, path]]: p = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stdoutdata, stderrdata) = p.communicate() + stdoutdata, stderrdata = p.communicate() exitcode = p.returncode if exitcode != 0: sys.exit("external_chown_script: could not chown\ncmd was {}\n".format(" ".join(cmd))) diff --git a/scripts/galaxy_main.py b/scripts/galaxy_main.py index 855e1f81253..e1aedda216d 100755 --- a/scripts/galaxy_main.py +++ b/scripts/galaxy_main.py @@ -17,6 +17,7 @@ defaults logging to a single file with the following: galaxy-main -d --server-name handler0 --daemon-log-file=handler0-daemon.log --pid-file handler0.pid --log-file handler0.log """ + import functools import logging import os diff --git a/scripts/grt/export.py b/scripts/grt/export.py index 795b1717882..311eda2c1cb 100644 --- a/scripts/grt/export.py +++ b/scripts/grt/export.py @@ -3,6 +3,7 @@ See doc/source/admin/grt.rst for more detailed usage information. """ + import argparse import json import logging diff --git a/scripts/grt/upload.py b/scripts/grt/upload.py index 5f227b99cec..50d86754132 100644 --- a/scripts/grt/upload.py +++ b/scripts/grt/upload.py @@ -3,6 +3,7 @@ See doc/source/admin/grt.rst for more detailed usage information. """ + import argparse import logging import os diff --git a/scripts/loc_files/create_all_fasta_loc.py b/scripts/loc_files/create_all_fasta_loc.py index cf891e081ac..10c82eab553 100644 --- a/scripts/loc_files/create_all_fasta_loc.py +++ b/scripts/loc_files/create_all_fasta_loc.py @@ -245,7 +245,7 @@ def __main__(): default="True", help="Copy over text from all_fasta.loc.sample file (false if set to append)", ) - (options, args) = parser.parse_args() + options, args = parser.parse_args() exemptions = [e.strip() for e in options.exemptions.split(",")] fasta_exts = [x.strip() for x in options.fasta_exts.split(",")] diff --git a/scripts/release-diff.py b/scripts/release-diff.py index 10e69a620af..1c44e69a7af 100644 --- a/scripts/release-diff.py +++ b/scripts/release-diff.py @@ -152,7 +152,7 @@ def main(old_revision, new_revision=None): old_contents = yaml.load(load_at_time(real_path, old_revision), Loader=MockOrderedLoader) new_contents = yaml.load(load_at_time(real_path, new_revision), Loader=MockOrderedLoader) - (a, r, c) = diff_files(old_contents, new_contents) + a, r, c = diff_files(old_contents, new_contents) if a: added[filename] = sorted(a) diff --git a/scripts/secret_decoder_ring.py b/scripts/secret_decoder_ring.py index 5bb09a330b1..a0aff6ea60e 100644 --- a/scripts/secret_decoder_ring.py +++ b/scripts/secret_decoder_ring.py @@ -2,6 +2,7 @@ """ Script to encode/decode the IDs that galaxy exposes to users and admins. """ + import argparse import logging import os diff --git a/scripts/tool_shed/deprecate_repositories_without_metadata.py b/scripts/tool_shed/deprecate_repositories_without_metadata.py index 993122c7713..706b4a69e8a 100644 --- a/scripts/tool_shed/deprecate_repositories_without_metadata.py +++ b/scripts/tool_shed/deprecate_repositories_without_metadata.py @@ -67,7 +67,7 @@ def main(): help="verbose mode, print the name of each repository", default=False, ) - (options, args) = parser.parse_args() + options, args = parser.parse_args() try: ini_file = args[0] except IndexError: diff --git a/scripts/tools/re_escape_output.py b/scripts/tools/re_escape_output.py index 0ec3ee1e1ed..3240602452b 100644 --- a/scripts/tools/re_escape_output.py +++ b/scripts/tools/re_escape_output.py @@ -5,6 +5,7 @@ Escapes a file into a form suitable for use with tool tests using re_match or re usage: re_escape_output.py [options] input_file [output_file] -m: Use Multiline Matching """ + import optparse import re @@ -14,7 +15,7 @@ def __main__(): parser.add_option( "-m", "--multiline", action="store_true", dest="multiline", default=False, help="Use Multiline Matching" ) - (options, args) = parser.parse_args() + options, args = parser.parse_args() input = open(args[0], "rb") if len(args) > 1: output = open(args[1], "wb") diff --git a/test/integration/objectstore/_base.py b/test/integration/objectstore/_base.py index df94dbb00a5..76a77058501 100644 --- a/test/integration/objectstore/_base.py +++ b/test/integration/objectstore/_base.py @@ -22,8 +22,7 @@ OBJECT_STORE_RUCIO_USERNAME = os.environ.get("GALAXY_INTEGRATION_OBJECT_STORE_RU OBJECT_STORE_RUCIO_RSE_NAME = "TEST" OBJECT_STORE_RUCIO_ACCESS = os.environ.get("GALAXY_INTEGRATION_OBJECT_STORE_RUCIO_ACCESS", "rucio") -OBJECT_STORE_CONFIG = string.Template( - """ +OBJECT_STORE_CONFIG = string.Template(""" @@ -36,10 +35,8 @@ OBJECT_STORE_CONFIG = string.Template( -""" -) -RUCIO_OBJECT_STORE_CONFIG = string.Template( - """ +""") +RUCIO_OBJECT_STORE_CONFIG = string.Template(""" type: rucio upload_rse_name: ${rucio_rse} upload_scheme: file @@ -59,10 +56,8 @@ RUCIO_OBJECT_STORE_CONFIG = string.Template( path: ${temp_directory}/object_store_cache size: 1000 cache_updated_data: ${cache_updated_data} -""" -) -AZURE_OBJECT_STORE_CONFIG = string.Template( - """ +""") +AZURE_OBJECT_STORE_CONFIG = string.Template(""" type: distributed backends: - type: azure_blob @@ -99,14 +94,12 @@ backends: path: "${temp_directory}/database/job_working_directory_azure_2" - type: temp path: "${temp_directory}/database/tmp_azure_2" -""" -) +""") # Onedata setup for the test is done according to this documentation: # https://onedata.org/#/home/documentation/topic/stable/demo-mode ONEDATA_DEMO_SPACE_NAME = "demo-space" -ONEDATA_OBJECT_STORE_CONFIG = string.Template( - """ +ONEDATA_OBJECT_STORE_CONFIG = string.Template(""" @@ -115,8 +108,7 @@ ONEDATA_OBJECT_STORE_CONFIG = string.Template( -""" -) +""") def wait_rucio_ready(container_name): diff --git a/test/integration/objectstore/test_changing_objectstore.py b/test/integration/objectstore/test_changing_objectstore.py index a0f63f63d7c..62e8d80b6ce 100644 --- a/test/integration/objectstore/test_changing_objectstore.py +++ b/test/integration/objectstore/test_changing_objectstore.py @@ -4,8 +4,7 @@ import string from ._base import BaseObjectStoreIntegrationTestCase -DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template( - """ +DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template(""" @@ -27,8 +26,7 @@ DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template( -""" -) +""") TEST_INPUT_FILES_CONTENT = "1 2 3" diff --git a/test/integration/objectstore/test_jobs.py b/test/integration/objectstore/test_jobs.py index 3d1bab41e37..845893ff046 100644 --- a/test/integration/objectstore/test_jobs.py +++ b/test/integration/objectstore/test_jobs.py @@ -13,8 +13,7 @@ from ._base import ( ) from .test_selection_with_resource_parameters import DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE -HIERARCHICAL_OBJECT_STORE_CONFIG_TEMPLATE = string.Template( - """ +HIERARCHICAL_OBJECT_STORE_CONFIG_TEMPLATE = string.Template(""" @@ -38,8 +37,7 @@ HIERARCHICAL_OBJECT_STORE_CONFIG_TEMPLATE = string.Template( -""" -) +""") TEST_INPUT_FILES_CONTENT = "1 2 3" diff --git a/test/integration/objectstore/test_mixed_store_by.py b/test/integration/objectstore/test_mixed_store_by.py index ccabc6afc2d..f100376f197 100644 --- a/test/integration/objectstore/test_mixed_store_by.py +++ b/test/integration/objectstore/test_mixed_store_by.py @@ -10,8 +10,7 @@ from ._base import ( files_count, ) -DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template( - """ +DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template(""" @@ -26,8 +25,7 @@ DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template( -""" -) +""") TEST_INPUT_FILES_CONTENT = "1 2 3" diff --git a/test/integration/objectstore/test_objectstore_datatype_upload.py b/test/integration/objectstore/test_objectstore_datatype_upload.py index a383e43edaa..96abef84c51 100644 --- a/test/integration/objectstore/test_objectstore_datatype_upload.py +++ b/test/integration/objectstore/test_objectstore_datatype_upload.py @@ -38,8 +38,7 @@ IRODS_OBJECT_STORE_ZONE = os.environ.get("GALAXY_INTEGRATION_IRODS_OBJECT_STORE_ # Run test for only the first 10 test files TEST_CASES = dict(list(TEST_CASES.items())[0:10]) SINGLE_TEST_CASE = dict(list(TEST_CASES.items())[0:1]) -DISTRIBUTED_OBJECT_STORE_CONFIG = string.Template( - """ +DISTRIBUTED_OBJECT_STORE_CONFIG = string.Template(""" @@ -54,10 +53,8 @@ DISTRIBUTED_OBJECT_STORE_CONFIG = string.Template( -""" -) -DISTRIBUTED_IRODS_OBJECT_STORE_CONFIG = string.Template( - """ +""") +DISTRIBUTED_IRODS_OBJECT_STORE_CONFIG = string.Template(""" @@ -76,10 +73,8 @@ DISTRIBUTED_IRODS_OBJECT_STORE_CONFIG = string.Template( -""" -) -IRODS_OBJECT_STORE_CONFIG = string.Template( - """ +""") +IRODS_OBJECT_STORE_CONFIG = string.Template(""" @@ -88,8 +83,7 @@ IRODS_OBJECT_STORE_CONFIG = string.Template( -""" -) +""") def check_container_active(container_name): diff --git a/test/integration/objectstore/test_private_handling.py b/test/integration/objectstore/test_private_handling.py index 66ec63f0671..37d5e088696 100644 --- a/test/integration/objectstore/test_private_handling.py +++ b/test/integration/objectstore/test_private_handling.py @@ -5,15 +5,13 @@ import string from galaxy_test.base import api_asserts from ._base import BaseObjectStoreIntegrationTestCase -PRIVATE_OBJECT_STORE_CONFIG_TEMPLATE = string.Template( - """ +PRIVATE_OBJECT_STORE_CONFIG_TEMPLATE = string.Template(""" -""" -) +""") TEST_INPUT_FILES_CONTENT = "1 2 3" diff --git a/test/integration/objectstore/test_selection_with_resource_parameters.py b/test/integration/objectstore/test_selection_with_resource_parameters.py index 19550075b31..4bbbf957bf4 100644 --- a/test/integration/objectstore/test_selection_with_resource_parameters.py +++ b/test/integration/objectstore/test_selection_with_resource_parameters.py @@ -19,8 +19,7 @@ SCRIPT_DIRECTORY = os.path.abspath(os.path.dirname(__file__)) JOB_CONFIG_FILE = os.path.join(SCRIPT_DIRECTORY, "selection_job_conf.xml") JOB_RESOURCE_PARAMETERS_CONFIG_FILE = os.path.join(SCRIPT_DIRECTORY, "selection_job_resource_parameters_conf.xml") -DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template( - """ +DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template(""" @@ -48,8 +47,7 @@ DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template( -""" -) +""") class TestObjectStoreSelectionWithResourceParameterIntegration(BaseObjectStoreIntegrationTestCase): diff --git a/test/integration/objectstore/test_selection_with_user_preferred_object_store.py b/test/integration/objectstore/test_selection_with_user_preferred_object_store.py index 9d64ada0eff..145a1c63412 100644 --- a/test/integration/objectstore/test_selection_with_user_preferred_object_store.py +++ b/test/integration/objectstore/test_selection_with_user_preferred_object_store.py @@ -20,8 +20,7 @@ from ._base import BaseObjectStoreIntegrationTestCase SCRIPT_DIRECTORY = os.path.abspath(os.path.dirname(__file__)) -DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template( - """ +DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template(""" @@ -49,8 +48,7 @@ DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template( -""" -) +""") TEST_WORKFLOW = """ diff --git a/test/integration/test_cli_runners.py b/test/integration/test_cli_runners.py index 4cdd5177c24..6e9548f8b6c 100644 --- a/test/integration/test_cli_runners.py +++ b/test/integration/test_cli_runners.py @@ -68,8 +68,7 @@ def stop_ssh_docker(container_name, remote_connection): def cli_job_config(remote_connection, shell_plugin="ParamikoShell", job_plugin="Slurm"): - job_conf_template = string.Template( - """ + job_conf_template = string.Template(""" @@ -87,8 +86,7 @@ def cli_job_config(remote_connection, shell_plugin="ParamikoShell", job_plugin=" -""" - ) +""") job_conf_str = job_conf_template.substitute( shell_plugin=shell_plugin, job_plugin=job_plugin, **remote_connection._asdict() ) diff --git a/test/integration/test_containerized_jobs.py b/test/integration/test_containerized_jobs.py index 15fbe486eac..913821bcba5 100644 --- a/test/integration/test_containerized_jobs.py +++ b/test/integration/test_containerized_jobs.py @@ -251,15 +251,13 @@ class TestMappingContainerResolver(IntegrationTestCase): disable_dependency_resolution(config) container_resolvers_config_path = os.path.join(cls.jobs_directory, "container_resolvers.yml") with open(container_resolvers_config_path, "w") as f: - f.write( - """ + f.write(""" - type: mapping mappings: - container_type: docker tool_id: mulled_example_broken_no_requirements identifier: 'quay.io/biocontainers/bwa:0.7.15--0' -""" - ) +""") config["container_resolvers_config_file"] = container_resolvers_config_path @classmethod diff --git a/test/integration/test_kubernetes_runner.py b/test/integration/test_kubernetes_runner.py index 43507c45545..0b9dbbe119f 100644 --- a/test/integration/test_kubernetes_runner.py +++ b/test/integration/test_kubernetes_runner.py @@ -46,8 +46,7 @@ class KubeSetupConfigTuple(Config): def persistent_volume(path: str, persistent_volume_name: str) -> KubeSetupConfigTuple: - volume_yaml = string.Template( - """ + volume_yaml = string.Template(""" kind: PersistentVolume apiVersion: v1 metadata: @@ -71,16 +70,14 @@ spec: operator: NotIn values: - 'i-do-not-exist' - """ - ).substitute(path=path, persistent_volume_name=persistent_volume_name) + """).substitute(path=path, persistent_volume_name=persistent_volume_name) with tempfile.NamedTemporaryFile(suffix="_persistent_volume.yml", mode="w", delete=False) as volume: volume.write(volume_yaml) return KubeSetupConfigTuple(path=volume.name) def persistent_volume_claim(persistent_volume_name: str, persistent_volum_claim_name: str) -> KubeSetupConfigTuple: - peristent_volume_claim_yaml = string.Template( - """ + peristent_volume_claim_yaml = string.Template(""" kind: PersistentVolumeClaim apiVersion: v1 metadata: @@ -93,18 +90,14 @@ spec: requests: storage: 2Gi storageClassName: manual -""" - ).substitute( - persistent_volume_name=persistent_volume_name, persistent_volume_claim_name=persistent_volum_claim_name - ) +""").substitute(persistent_volume_name=persistent_volume_name, persistent_volume_claim_name=persistent_volum_claim_name) with tempfile.NamedTemporaryFile(suffix="_persistent_volume_claim.yml", mode="w", delete=False) as volume_claim: volume_claim.write(peristent_volume_claim_yaml) return KubeSetupConfigTuple(path=volume_claim.name) def job_config(jobs_directory: str) -> Config: - job_conf_template = string.Template( - """ + job_conf_template = string.Template(""" @@ -144,8 +137,7 @@ def job_config(jobs_directory: str) -> Config: -""" - ) +""") job_conf_str = job_conf_template.substitute( jobs_directory=jobs_directory, tool_directory=TOOL_DIR, diff --git a/test/integration/test_page_revision_json_encoding.py b/test/integration/test_page_revision_json_encoding.py index 596291e9062..9a3f13ef7c0 100644 --- a/test/integration/test_page_revision_json_encoding.py +++ b/test/integration/test_page_revision_json_encoding.py @@ -51,9 +51,7 @@ class TestPageJsonEncodingIntegration(integration_util.IntegrationTestCase): title="MY PAGE", content="""```galaxy history_dataset_display(history_dataset_id={}) -```""".format( - dataset["id"] - ), +```""".format(dataset["id"]), content_format="markdown", ) page_response = self._post("pages", request, json=True) @@ -61,12 +59,9 @@ history_dataset_display(history_dataset_id={}) sa_session = self._app.model.session page_revision = sa_session.scalars(select(model.PageRevision).filter_by(content_format="markdown")).all()[0] assert page_revision.content is not None - assert ( - """```galaxy + assert """```galaxy history_dataset_display(history_dataset_id=1) -```""" - in page_revision.content - ), page_revision.content +```""" in page_revision.content, page_revision.content assert ( f"""::: history_dataset_display history_dataset_id={dataset_id}""" not in page_revision.content ), page_revision.content @@ -74,15 +69,9 @@ history_dataset_display(history_dataset_id=1) show_page_response = self._get("pages/{}".format(page_response.json()["id"])) api_asserts.assert_status_code_is_ok(show_page_response) content = show_page_response.json()["content"] - assert ( - """```galaxy + assert """```galaxy history_dataset_display(history_dataset_id=1) -```""" - not in content - ), content - assert ( - f"""```galaxy +```""" not in content, content + assert f"""```galaxy history_dataset_display(history_dataset_id={dataset_id}) -```""" - in content - ), content +```""" in content, content diff --git a/test/integration/test_recalculate_user_disk_usage.py b/test/integration/test_recalculate_user_disk_usage.py index c23d12c7775..806fc8992da 100644 --- a/test/integration/test_recalculate_user_disk_usage.py +++ b/test/integration/test_recalculate_user_disk_usage.py @@ -6,8 +6,7 @@ from galaxy_test.driver.integration_util import IntegrationTestCase from .objectstore._base import BaseObjectStoreIntegrationTestCase from .objectstore.test_selection_with_resource_parameters import DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE -SIMPLE_DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template( - """ +SIMPLE_DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template(""" @@ -23,8 +22,7 @@ SIMPLE_DISTRIBUTED_OBJECT_STORE_CONFIG_TEMPLATE = string.Template( -""" -) +""") class RecalculateDiskUsage: diff --git a/test/integration/test_user_defined_tool_job_conf.py b/test/integration/test_user_defined_tool_job_conf.py index 3794eeb0aab..19c5423c786 100644 --- a/test/integration/test_user_defined_tool_job_conf.py +++ b/test/integration/test_user_defined_tool_job_conf.py @@ -15,8 +15,7 @@ from galaxy_test.driver import integration_util SCRIPT_DIRECTORY = os.path.abspath(os.path.dirname(__file__)) EMBEDDED_PULSAR_JOB_CONFIG_FILE = os.path.join(SCRIPT_DIRECTORY, "embedded_pulsar_job_conf.yml") EMBEDDED_PULSAR_TPV_JOB_CONFIG_FILE = os.path.join(SCRIPT_DIRECTORY, "embedded_pulsar_tpv_job_conf.yml") -TOOL_WITH_RESOURCE_SPECIFICATION = yaml.safe_load( - """class: GalaxyUserTool +TOOL_WITH_RESOURCE_SPECIFICATION = yaml.safe_load("""class: GalaxyUserTool id: resource_requirement version: "0.1" name: resource_requirement @@ -32,8 +31,7 @@ outputs: type: data format: txt from_work_dir: galaxy_cores.txt -""" -) +""") class TestUserDefinedToolRecommendedJobSetup(integration_util.IntegrationTestCase, TestsTools): diff --git a/test/integration/test_workflow_handler_configuration.py b/test/integration/test_workflow_handler_configuration.py index ed8df0937e0..11e3db488d7 100644 --- a/test/integration/test_workflow_handler_configuration.py +++ b/test/integration/test_workflow_handler_configuration.py @@ -17,8 +17,7 @@ from galaxy_test.driver import integration_util SCRIPT_DIRECTORY = os.path.abspath(os.path.dirname(__file__)) WORKFLOW_HANDLER_CONFIGURATION_JOB_CONF = os.path.join(SCRIPT_DIRECTORY, "workflow_handler_configuration_job_conf.xml") -WORKFLOW_HANDLER_JOB_CONFIG_TEMPLATE = string.Template( - """ +WORKFLOW_HANDLER_JOB_CONFIG_TEMPLATE = string.Template(""" @@ -42,11 +41,9 @@ WORKFLOW_HANDLER_JOB_CONFIG_TEMPLATE = string.Template( -""" -) +""") -POOL_JOB_CONFIG_TEMPLATE = string.Template( - """ +POOL_JOB_CONFIG_TEMPLATE = string.Template(""" @@ -57,11 +54,9 @@ POOL_JOB_CONFIG_TEMPLATE = string.Template( -""" -) +""") -WORKFLOW_SCHEDULERS_CONFIG_TEMPLATE = string.Template( - """ +WORKFLOW_SCHEDULERS_CONFIG_TEMPLATE = string.Template(""" @@ -69,8 +64,7 @@ WORKFLOW_SCHEDULERS_CONFIG_TEMPLATE = string.Template( -""" -) +""") JOB_HANDLER_PATTERN = re.compile(r"handler\d") WORKFLOW_SCHEDULER_HANDLER_PATTERN = re.compile(r"work\d") diff --git a/test/integration/test_workflow_invocation.py b/test/integration/test_workflow_invocation.py index 3ef39b06779..b73fbcf9a94 100644 --- a/test/integration/test_workflow_invocation.py +++ b/test/integration/test_workflow_invocation.py @@ -140,8 +140,7 @@ test_data: def test_run_workflow_with_missing_tool(self): self.install_repository("iuc", "compose_text_param", "feb3acba1e0a") # 0.1.0 with self.dataset_populator.test_history() as history_id: - workflow_id = self.workflow_populator.upload_yaml_workflow( - """ + workflow_id = self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow steps: nonexistent: @@ -152,8 +151,7 @@ steps: tool_id: compose_text_param tool_version: "0.0.1" label: compose_text_param -""" - ) +""") # should fail and return both tool ids since version 0.0.1 of compose_text_param does not exist invocation_response = self.workflow_populator.invoke_workflow( workflow_id, history_id=history_id, request={"require_exact_tool_versions": True} diff --git a/test/integration/test_workflow_refactoring.py b/test/integration/test_workflow_refactoring.py index 7d5a4da15ee..89e39edcda5 100644 --- a/test/integration/test_workflow_refactoring.py +++ b/test/integration/test_workflow_refactoring.py @@ -294,8 +294,7 @@ class TestWorkflowRefactoringIntegration(integration_util.IntegrationTestCase, U # test parameters used in PJA without being used in tool state. # These will work fine with the simplified workflow UI, but should probably # be formalized and assigned a unique label and informative annotation. - self.workflow_populator.upload_yaml_workflow( - """ + self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow inputs: test_input: data @@ -307,8 +306,7 @@ steps: outputs: out_file1: rename: "${pja_only_param} name" -""" - ) +""") actions: ActionsJson = [ {"action_type": "extract_untyped_parameter", "name": "pja_only_param"}, ] @@ -317,8 +315,7 @@ steps: def test_refactoring_legacy_parameters_without_tool_state_dry_run(self): # same as above but dry run... - self.workflow_populator.upload_yaml_workflow( - """ + self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow inputs: test_input: data @@ -330,8 +327,7 @@ steps: outputs: out_file1: rename: "${pja_only_param} name" -""" - ) +""") actions: ActionsJson = [ {"action_type": "extract_untyped_parameter", "name": "pja_only_param"}, ] @@ -343,8 +339,7 @@ steps: def test_refactoring_legacy_parameters_without_tool_state_relabel(self): # same thing as above, but apply relabeling and ensure PJA gets updated. - self.workflow_populator.upload_yaml_workflow( - """ + self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow inputs: test_input: data @@ -356,8 +351,7 @@ steps: outputs: out_file1: rename: "${pja_only_param} name" -""" - ) +""") actions: ActionsJson = [ {"action_type": "extract_untyped_parameter", "name": "pja_only_param", "label": "new_label"}, ] @@ -511,8 +505,7 @@ steps: assert message.input_name == "num_lines" def test_tool_version_upgrade_no_state_change(self): - self.workflow_populator.upload_yaml_workflow( - """ + self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow steps: the_step: @@ -520,8 +513,7 @@ steps: tool_version: '0.1' state: inttest: 0 -""" - ) +""") assert self._latest_workflow.step_by_label("the_step").tool_version == "0.1" actions: ActionsJson = [ {"action_type": "upgrade_tool", "step": {"label": "the_step"}}, @@ -535,8 +527,7 @@ steps: assert self._latest_workflow.step_by_label("the_step").tool_version == "0.2" def test_tool_version_upgrade_keeps_when_expression(self): - self.workflow_populator.upload_yaml_workflow( - """ + self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow inputs: the_bool: @@ -550,8 +541,7 @@ steps: state: inttest: 0 when: $(inputs.when) -""" - ) +""") assert self._latest_workflow.step_by_label("the_step").tool_version == "0.1" actions: ActionsJson = [ {"action_type": "upgrade_tool", "step": {"label": "the_step"}}, @@ -564,8 +554,7 @@ steps: assert step.when_expression def test_tool_version_upgrade_state_added(self): - self.workflow_populator.upload_yaml_workflow( - """ + self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow steps: the_step: @@ -573,8 +562,7 @@ steps: tool_version: '0.1' state: inttest: 0 -""" - ) +""") assert self._latest_workflow.step_by_label("the_step").tool_version == "0.1" actions: ActionsJson = [ {"action_type": "upgrade_tool", "step": {"label": "the_step"}, "tool_version": "0.2"}, diff --git a/test/integration/test_workflow_scheduling_options.py b/test/integration/test_workflow_scheduling_options.py index c1757067cc7..b769dba1dcf 100644 --- a/test/integration/test_workflow_scheduling_options.py +++ b/test/integration/test_workflow_scheduling_options.py @@ -62,8 +62,7 @@ class TestMaximumWorkflowJobsPerSchedulingIteration(integration_util.Integration config["maximum_workflow_jobs_per_scheduling_iteration"] = 1 def test_collection_explicit_and_implicit(self): - workflow_id = self.workflow_populator.upload_yaml_workflow( - """ + workflow_id = self.workflow_populator.upload_yaml_workflow(""" class: GalaxyWorkflow steps: - type: input_collection @@ -79,8 +78,7 @@ steps: state: input1: $link: 2/out1 -""" - ) +""") with self.dataset_populator.test_history() as history_id: fetch_response = self.dataset_collection_populator.create_list_in_history( history_id, contents=["a\nb\nc\nd\n", "e\nf\ng\nh\n"] diff --git a/test/integration/test_workflow_tasks.py b/test/integration/test_workflow_tasks.py index 7014845fff0..5231cae6965 100644 --- a/test/integration/test_workflow_tasks.py +++ b/test/integration/test_workflow_tasks.py @@ -183,8 +183,7 @@ input_data: self.dataset_collection_populator.create_list_in_history(history_id=history_id, wait=True).json() new_history = self.dataset_populator.copy_history(history_id=history_id).json() copied_collection = self.dataset_populator.get_history_collection_details(new_history["id"]) - workflow_id = self.workflow_populator.upload_yaml_workflow( - """class: GalaxyWorkflow + workflow_id = self.workflow_populator.upload_yaml_workflow("""class: GalaxyWorkflow inputs: input: type: collection @@ -198,8 +197,7 @@ steps: outputs: extracted_dataset: outputSource: extract_dataset/output -""" - ) +""") inputs = {"input": {"src": "hdca", "id": copied_collection["id"]}} workflow_request = {"history": f"hist_id={new_history['id']}", "inputs_by": "name", "inputs": inputs} invocation = self.workflow_populator.invoke_workflow_raw( diff --git a/test/integration_selenium/test_objectstore_expiration.py b/test/integration_selenium/test_objectstore_expiration.py index 2b2f9e15651..a5b91ff911b 100644 --- a/test/integration_selenium/test_objectstore_expiration.py +++ b/test/integration_selenium/test_objectstore_expiration.py @@ -17,8 +17,7 @@ if TYPE_CHECKING: SeleniumSessionDatasetPopulator, ) -OBJECT_STORES_CONFIG = string.Template( - """ +OBJECT_STORES_CONFIG = string.Template(""" type: distributed backends: - id: default @@ -58,8 +57,7 @@ backends: - type: job_work path: "${temp_directory}/job_working_directory2" object_expires_after_days: ${mid_term_expiration_days} -""" -) +""") AvailableObjectStoreIDs = Literal["default", "short_term", "mid_term"] diff --git a/test/integration_selenium/test_objectstore_selection.py b/test/integration_selenium/test_objectstore_selection.py index aa7f28b0118..678420226d8 100644 --- a/test/integration_selenium/test_objectstore_selection.py +++ b/test/integration_selenium/test_objectstore_selection.py @@ -12,8 +12,7 @@ if TYPE_CHECKING: from galaxy_test.selenium.framework import SeleniumSessionDatasetPopulator -MSI_EXAMPLE_OBJECT_STORE_CONFIG_TEMPLATE = string.Template( - """ +MSI_EXAMPLE_OBJECT_STORE_CONFIG_TEMPLATE = string.Template(""" @@ -78,8 +77,7 @@ More information about MSI Storage can be found [here](https://www.msi.umn.edu/c -""" -) +""") class TestObjectStoreSelectionSeleniumIntegration(SeleniumIntegrationTestCase, ConfiguresObjectStores): diff --git a/test/integration_selenium/test_workflow_repository_tool_update.py b/test/integration_selenium/test_workflow_repository_tool_update.py index b81f6935beb..2f92ec56873 100644 --- a/test/integration_selenium/test_workflow_repository_tool_update.py +++ b/test/integration_selenium/test_workflow_repository_tool_update.py @@ -55,15 +55,13 @@ steps: def test_tool_shed_unmatched_version_upgrade(self): self.install_repository("iuc", "compose_text_param", "e188c9826e0f") # 0.1.1 self.login() - workflow_id = self.workflow_populator.upload_yaml_workflow( - """class: GalaxyWorkflow + workflow_id = self.workflow_populator.upload_yaml_workflow("""class: GalaxyWorkflow inputs: [] steps: - tool_id: toolshed.g2.bx.psu.edu/repos/iuc/compose_text_param/compose_text_param/0.0.0 tool_version: 0.0.0 label: compose_text_param - """ - ) + """) self.workflow_index_open() self.components.workflows.edit_button.wait_for_and_click() self.assert_modal_has_text("Using version '0.1.1' instead of version '0.0.0'") diff --git a/test/manual/workflows_scaling.py b/test/manual/workflows_scaling.py index 20c1f73a8bd..836ff979d47 100644 --- a/test/manual/workflows_scaling.py +++ b/test/manual/workflows_scaling.py @@ -5,6 +5,7 @@ $ .venv/bin/python scripts/summarize_timings.py --file /tmp//handler1.log --pattern 'Workflow step' $ .venv/bin/python scripts/summarize_timings.py --file /tmp//handler1.log --pattern 'Created step' """ + import functools import json import os diff --git a/test/unit/app/managers/test_CollectionManager.py b/test/unit/app/managers/test_CollectionManager.py index e22ce580e0a..2a3273d238c 100644 --- a/test/unit/app/managers/test_CollectionManager.py +++ b/test/unit/app/managers/test_CollectionManager.py @@ -1,5 +1,6 @@ #!/usr/bin/env python """ """ + from galaxy import model from galaxy.managers.collections import DatasetCollectionManager from galaxy.managers.datasets import DatasetManager diff --git a/test/unit/app/managers/test_markdown_export.py b/test/unit/app/managers/test_markdown_export.py index 5ab1f0c66bf..4f512a831ec 100644 --- a/test/unit/app/managers/test_markdown_export.py +++ b/test/unit/app/managers/test_markdown_export.py @@ -434,12 +434,9 @@ I ran a cool analysis with two inputs of types ${galaxy history_dataset_type(his """ self.app.hda_manager.get_accessible.side_effect = [hda, hda2] _, export_markdown, _ = self._ready_export(example) - assert ( - export_markdown - == """ + assert export_markdown == """ I ran a cool analysis with two inputs of types fasta and fastqsanger. """ - ) def test_export_replaces_embedded_history_dataset_name(self): hda = self._new_hda() @@ -452,22 +449,17 @@ I ran a cool analysis with two inputs of types ${galaxy history_dataset_name(his """ self.app.hda_manager.get_accessible.side_effect = [hda, hda2] _, export_markdown, _ = self._ready_export(example) - assert ( - export_markdown - == """ + assert export_markdown == """ I ran a cool analysis with two inputs of types foo bar and cow dog. """ - ) def test_export_replaces_embedded_generate_time(self): example = """ I ran a cool analysis at ${galaxy generate_time()}. """ _, export_markdown, _ = self._ready_export(example) - assert export_markdown.startswith( - """ -I ran a cool analysis at 2""" - ) + assert export_markdown.startswith(""" +I ran a cool analysis at 2""") def test_export_replaces_embedded_invocation_time(self): invocation = self._new_invocation() @@ -476,22 +468,17 @@ I ran a cool analysis at 2""" I ran a cool analysis at ${galaxy invocation_time(invocation_id=1)}. """ _, export_markdown, _ = self._ready_export(example) - assert export_markdown.startswith( - """ -I ran a cool analysis at 2""" - ) + assert export_markdown.startswith(""" +I ran a cool analysis at 2""") def test_export_replaces_embedded_galaxy_version(self): example = """ I ran a cool analysis with Galaxy ${galaxy generate_galaxy_version()}. """ _, export_markdown, _ = self._ready_export(example) - assert ( - export_markdown - == """ + assert export_markdown == """ I ran a cool analysis with Galaxy 19.09. """ - ) def test_export_replaces_embedded_access_link(self): self.trans.app.config.instance_access_url = "http://mycoolgalaxy.org" @@ -499,12 +486,9 @@ I ran a cool analysis with Galaxy 19.09. I ran a cool analysis at ${galaxy instance_access_link()}. """ _, export_markdown, _ = self._ready_export(example) - assert ( - export_markdown - == """ + assert export_markdown == """ I ran a cool analysis at [http://mycoolgalaxy.org](http://mycoolgalaxy.org). """ - ) def _ready_export(self, example: str): return ready_galaxy_markdown_for_export(self.trans, example) diff --git a/test/unit/app/managers/test_markdown_to_html.py b/test/unit/app/managers/test_markdown_to_html.py index 59cbc58f93e..43116c9baf2 100644 --- a/test/unit/app/managers/test_markdown_to_html.py +++ b/test/unit/app/managers/test_markdown_to_html.py @@ -9,8 +9,7 @@ from galaxy.managers.markdown_util import to_html def test_basics(): - as_html = to_html( - """ + as_html = to_html(""" # My header! My cool document. **Bold** text. @@ -18,52 +17,43 @@ My cool document. **Bold** text. ## My sub header Less important content. -""" - ) +""") assert "

          My header!

          " in as_html assert "Bold" in as_html def test_indent_code_blocks(): - as_html = to_html( - """ + as_html = to_html(""" A Code Block Follows: This is code right? Here is another line. -""" - ) +""") assert "
          This is code right?\nHere is another line." in as_html
           
           
           def test_tables():
          -    as_html = to_html(
          -        """
          +    as_html = to_html("""
           |animal|sound|
           |------|-----|
           |dog   |bark |
           |cat   |meow |
          -"""
          -    )
          +""")
               assert "" in as_html, as_html
           
           
           def test_tags_escaped():
          -    as_html = to_html(
          -        """
          +    as_html = to_html("""
           Bad block approaches 
          -""" - ) +""") assert "