Skip to content

Commit

Permalink
Fix signature override of DatabaseOperationTool.produce_outputs() m…
Browse files Browse the repository at this point in the history
…ethod

Fix the following mypy 1.11 errors:

```
lib/galaxy/tools/__init__.py:3989: error: Signature of "produce_outputs"
incompatible with supertype "DatabaseOperationTool"  [override]
        def produce_outputs(self, trans, out_data, output_collections, inc...
        ^
lib/galaxy/tools/__init__.py:3989: note:      Superclass:
lib/galaxy/tools/__init__.py:3989: note:          def produce_outputs(self, trans: Any, out_data: Any, output_collections: Any, incoming: Any, history: Any, **kwds: Any) -> Any
lib/galaxy/tools/__init__.py:3989: note:      Subclass:
lib/galaxy/tools/__init__.py:3989: note:          def produce_outputs(self, trans: Any, out_data: Any, output_collections: Any, incoming: Any, history: Any, tag_handler: Any, **kwds: Any) -> Any
lib/galaxy/tools/__init__.py:4026: error: Signature of "produce_outputs"
incompatible with supertype "DatabaseOperationTool"  [override]
        def produce_outputs(self, trans, out_data, output_collections, inc...
        ^
lib/galaxy/tools/__init__.py:4026: note:      Superclass:
lib/galaxy/tools/__init__.py:4026: note:          def produce_outputs(self, trans: Any, out_data: Any, output_collections: Any, incoming: Any, history: Any, **kwds: Any) -> Any
lib/galaxy/tools/__init__.py:4026: note:      Subclass:
lib/galaxy/tools/__init__.py:4026: note:          def produce_outputs(self, trans: Any, out_data: Any, output_collections: Any, incoming: Any, history: Any, tag_handler: Any, **kwds: Any) -> Any
```
  • Loading branch information
nsoranzo committed Sep 10, 2024
1 parent 7218a17 commit 7821a60
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 7 additions & 5 deletions lib/galaxy/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@

if TYPE_CHECKING:
from galaxy.app import UniverseApplication
from galaxy.managers.context import ProvidesUserContext
from galaxy.managers.jobs import JobSearch
from galaxy.tools.actions.metadata import SetMetadataToolAction

Expand Down Expand Up @@ -3396,7 +3397,7 @@ def _add_datasets_to_history(self, history, elements, datasets_visible=False):
element_object.visible = datasets_visible
history.stage_addition(element_object)

def produce_outputs(self, trans, out_data, output_collections, incoming, history, **kwds):
def produce_outputs(self, trans: "ProvidesUserContext", out_data, output_collections, incoming, history, **kwds):
return self._outputs_dict()

def _outputs_dict(self):
Expand Down Expand Up @@ -3573,7 +3574,7 @@ class ExtractDatasetCollectionTool(DatabaseOperationTool):
require_terminal_states = False
require_dataset_ok = False

def produce_outputs(self, trans, out_data, output_collections, incoming, history, tags=None, **kwds):
def produce_outputs(self, trans, out_data, output_collections, incoming, history, **kwds):
has_collection = incoming["input"]
if hasattr(has_collection, "element_type"):
# It is a DCE
Expand Down Expand Up @@ -3986,15 +3987,15 @@ def add_copied_value_to_new_elements(new_label, dce_object):
class ApplyRulesTool(DatabaseOperationTool):
tool_type = "apply_rules"

def produce_outputs(self, trans, out_data, output_collections, incoming, history, tag_handler, **kwds):
def produce_outputs(self, trans, out_data, output_collections, incoming, history, **kwds):
hdca = incoming["input"]
rule_set = RuleSet(incoming["rules"])
copied_datasets = []

def copy_dataset(dataset, tags):
copied_dataset = dataset.copy(copy_tags=dataset.tags, flush=False)
if tags is not None:
tag_handler.set_tags_from_list(
trans.tag_handler.set_tags_from_list(
trans.get_user(),
copied_dataset,
tags,
Expand Down Expand Up @@ -4023,14 +4024,15 @@ class TagFromFileTool(DatabaseOperationTool):
# require_terminal_states = True
# require_dataset_ok = False

def produce_outputs(self, trans, out_data, output_collections, incoming, history, tag_handler, **kwds):
def produce_outputs(self, trans, out_data, output_collections, incoming, history, **kwds):
hdca = incoming["input"]
how = incoming["how"]
new_tags_dataset_assoc = incoming["tags"]
new_elements = {}
new_datasets = []

def add_copied_value_to_new_elements(new_tags_dict, dce):
tag_handler = trans.tag_handler
if getattr(dce.element_object, "history_content_type", None) == "dataset":
copied_value = dce.element_object.copy(copy_tags=dce.element_object.tags, flush=False)
# copy should never be visible, since part of a collection
Expand Down
2 changes: 0 additions & 2 deletions lib/galaxy/tools/actions/model_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ def execute(
def _produce_outputs(
self, trans: "ProvidesUserContext", tool, out_data, output_collections, incoming, history, tags, hdca_tags, skip
):
tag_handler = trans.tag_handler
tool.produce_outputs(
trans,
out_data,
Expand All @@ -148,7 +147,6 @@ def _produce_outputs(
history=history,
tags=tags,
hdca_tags=hdca_tags,
tag_handler=tag_handler,
)
if mapped_over_elements := output_collections.dataset_collection_elements:
for name, value in out_data.items():
Expand Down

0 comments on commit 7821a60

Please sign in to comment.