diff --git a/cron/build_chrom_db.py b/cron/build_chrom_db.py index 6a95366fe83..920c2dec929 100644 --- a/cron/build_chrom_db.py +++ b/cron/build_chrom_db.py @@ -17,7 +17,7 @@ import os import sys from urllib.parse import urlencode -import parse_builds # noqa: I100,I202 +import parse_builds from galaxy.util import requests diff --git a/lib/galaxy/jobs/__init__.py b/lib/galaxy/jobs/__init__.py index 0346c2d1be0..82480e12df8 100644 --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -17,6 +17,7 @@ import traceback from json import loads from typing import ( Any, + Callable, Dict, Iterable, List, @@ -1629,19 +1630,19 @@ class MinimalJobWrapper(HasResourceParameters): def set_job_destination(self, job_destination, external_id=None, flush=True, job=None): """Subclasses should implement this to persist a destination, if necessary.""" - def _set_object_store_ids(self, job): + def _set_object_store_ids(self, job: Job): if job.object_store_id: # We aren't setting this during job creation anymore, but some existing # jobs may have this set. Skip this following code if that is the case. return object_store = self.app.object_store - if not object_store.object_store_allows_id_selection: + if not object_store.object_store_allows_id_selection(): self._set_object_store_ids_basic(job) else: self._set_object_store_ids_full(job) - def _set_object_store_ids_basic(self, job): + def _set_object_store_ids_basic(self, job: Job): object_store_id = self.get_destination_configuration("object_store_id", None) object_store_populator = ObjectStorePopulator(self.app, job.user) require_shareable = job.requires_shareable_storage(self.app.security_agent) @@ -1662,11 +1663,11 @@ class MinimalJobWrapper(HasResourceParameters): job.object_store_id = object_store_populator.object_store_id self._setup_working_directory(job=job) - def _set_object_store_ids_full(self, job): + def _set_object_store_ids_full(self, job: Job): user = job.user object_store_id = self.get_destination_configuration("object_store_id", None) - split_object_stores = None - object_store_id_overrides = None + split_object_stores: Optional[Callable[[str], ObjectStorePopulator]] = None + object_store_id_overrides: Optional[Dict[str, Optional[str]]] = None if object_store_id is None: object_store_id = job.preferred_object_store_id @@ -1687,7 +1688,11 @@ class MinimalJobWrapper(HasResourceParameters): # directory? object_store_id = invocation_object_stores.preferred_outputs_object_store_id object_store_populator = intermediate_object_store_populator - output_names = [o.output_name for o in workflow_invocation_step.workflow_step.unique_workflow_outputs] + output_names = [ + o.output_name + for o in workflow_invocation_step.workflow_step.unique_workflow_outputs + if o.output_name + ] if invocation_object_stores.step_effective_outputs is not None: output_names = [ o for o in output_names if invocation_object_stores.is_output_name_an_effective_output(o) @@ -1696,9 +1701,9 @@ class MinimalJobWrapper(HasResourceParameters): # we resolve the precreated datasets here with object store populators # but for dynamically created datasets after the job we need to record # the outputs and set them accordingly - object_store_id_overrides = {o: preferred_outputs_object_store_id for o in output_names} + object_store_id_overrides = dict.fromkeys(output_names, preferred_outputs_object_store_id) - def split_object_stores(output_name): # noqa: F811 https://github.com/PyCQA/pyflakes/issues/783 + def split_object_stores(output_name: str): # noqa: F811 https://github.com/PyCQA/pyflakes/issues/783 if "|__part__|" in output_name: output_name = output_name.split("|__part__|", 1)[0] if output_name in output_names: @@ -1718,7 +1723,7 @@ class MinimalJobWrapper(HasResourceParameters): object_store_id = user.preferred_object_store_id require_shareable = job.requires_shareable_storage(self.app.security_agent) - if not split_object_stores: + if split_object_stores is None: object_store_populator = ObjectStorePopulator(self.app, user) if object_store_id: diff --git a/lib/galaxy/managers/datatypes.py b/lib/galaxy/managers/datatypes.py index 9899cf8b98a..e97db6c8d6e 100644 --- a/lib/galaxy/managers/datatypes.py +++ b/lib/galaxy/managers/datatypes.py @@ -54,7 +54,7 @@ def view_mapping(datatypes_registry: Registry) -> DatatypesMap: n = f"{c.__module__}.{c.__name__}" types = {n} visit_bases(types, c) - class_to_classes[n] = {t: True for t in types} + class_to_classes[n] = dict.fromkeys(types, True) return DatatypesMap(ext_to_class_name=ext_to_class_name, class_to_classes=class_to_classes) diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index e42d022d2a4..3af645e1536 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -1504,7 +1504,7 @@ class Job(Base, JobLike, UsesCreateAndUpdateTime, Dictifiable, Serializable): params: Mapped[Optional[str]] = mapped_column(TrimmedString(255), index=True) handler: Mapped[Optional[str]] = mapped_column(TrimmedString(255), index=True) preferred_object_store_id: Mapped[Optional[str]] = mapped_column(String(255)) - object_store_id_overrides: Mapped[Optional[STR_TO_STR_DICT]] = mapped_column(JSONType) + object_store_id_overrides: Mapped[Optional[Dict[str, Optional[str]]]] = mapped_column(JSONType) tool_request_id: Mapped[Optional[int]] = mapped_column(ForeignKey("tool_request.id"), index=True) dynamic_tool: Mapped[Optional["DynamicTool"]] = relationship() @@ -8284,7 +8284,7 @@ class WorkflowStep(Base, RepresentById, UsesCreateAndUpdateTime): # Older Galaxy workflows may have multiple WorkflowOutputs # per "output_name", when serving these back to the editor # feed only a "best" output per "output_name."" - outputs = {} + outputs: Dict[str, WorkflowOutput] = {} for workflow_output in self.workflow_outputs: output_name = workflow_output.output_name diff --git a/lib/galaxy/model/store/discover.py b/lib/galaxy/model/store/discover.py index 3f0d8941a0e..9f1f6a15347 100644 --- a/lib/galaxy/model/store/discover.py +++ b/lib/galaxy/model/store/discover.py @@ -498,7 +498,7 @@ class ModelPersistenceContext(metaclass=abc.ABCMeta): default_object_store_id = job.object_store_id if not output_name: return default_object_store_id - object_store_id_overrides: Dict[str, str] = job.object_store_id_overrides or {} + object_store_id_overrides = job.object_store_id_overrides or {} return object_store_id_overrides.get(output_name, default_object_store_id) @property diff --git a/lib/galaxy/web_stack/__init__.py b/lib/galaxy/web_stack/__init__.py index b30d7a924b5..1f202b9d84e 100644 --- a/lib/galaxy/web_stack/__init__.py +++ b/lib/galaxy/web_stack/__init__.py @@ -268,7 +268,7 @@ class WeblessApplicationStack(ApplicationStack): @property def configured_pools(self): - return {p: self.config.server_name for p in self.config.attach_to_pools} + return dict.fromkeys(self.config.attach_to_pools, self.config.server_name) def in_pool(self, pool_name): return pool_name in self.config.attach_to_pools diff --git a/scripts/api/data_manager_example_execute.py b/scripts/api/data_manager_example_execute.py index 9ece9840462..3bac2833da9 100644 --- a/scripts/api/data_manager_example_execute.py +++ b/scripts/api/data_manager_example_execute.py @@ -8,7 +8,7 @@ import optparse import time from urllib.parse import urljoin -from common import ( # noqa: I100,I202 +from common import ( get, post, ) diff --git a/scripts/api/display.py b/scripts/api/display.py index 6e3513e9d28..58c6234043f 100755 --- a/scripts/api/display.py +++ b/scripts/api/display.py @@ -4,7 +4,7 @@ import os import sys from urllib.error import URLError -from common import display # noqa: I100,I202 +from common import display try: display(*sys.argv[1:3]) diff --git a/scripts/cleanup_datasets/admin_cleanup_datasets.py b/scripts/cleanup_datasets/admin_cleanup_datasets.py index ca9e14ede85..94e1c5528a3 100755 --- a/scripts/cleanup_datasets/admin_cleanup_datasets.py +++ b/scripts/cleanup_datasets/admin_cleanup_datasets.py @@ -59,7 +59,7 @@ from sqlalchemy import ( sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, "lib"))) -from cleanup_datasets import CleanupDatasetsApplication # noqa: I100 +from cleanup_datasets import CleanupDatasetsApplication import galaxy.config import galaxy.util diff --git a/scripts/microbes/harvest_bacteria.py b/scripts/microbes/harvest_bacteria.py index 9eb5b3d1aeb..8a378371a25 100644 --- a/scripts/microbes/harvest_bacteria.py +++ b/scripts/microbes/harvest_bacteria.py @@ -18,7 +18,7 @@ try: except ImportError: raise Exception("BeautifulSoup4 library not found, please install it, e.g. with 'pip install BeautifulSoup4'") -from util import ( # noqa: I202 +from util import ( get_bed_from_genbank, get_bed_from_GeneMark, get_bed_from_GeneMarkHMM,