Skip to content

Commit

Permalink
Fix new errors from ruff 0.0.279
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Jul 23, 2023
1 parent 46ba006 commit c7a38d0
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 27 deletions.
14 changes: 6 additions & 8 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,15 +616,13 @@ def calculate_user_disk_usage_statements(user_id, quota_source_map, for_sqlite=F
label_usage=label_usage
)
else:
statement = """
statement = f"""
INSERT INTO user_quota_source_usage(user_id, quota_source_label, disk_usage)
VALUES(:id, :label, ({label_usage}))
ON CONFLICT
ON constraint uqsu_unique_label_per_user
DO UPDATE SET disk_usage = excluded.disk_usage
""".format(
label_usage=label_usage
)
"""
statements.append(
(statement, {"id": user_id, "label": quota_source_label, "include_object_store_ids": object_store_ids})
)
Expand Down Expand Up @@ -1399,12 +1397,12 @@ def finished(self):
]

def io_dicts(self, exclude_implicit_outputs=False) -> IoDicts:
inp_data: Dict[str, Optional["DatasetInstance"]] = {da.name: da.dataset for da in self.input_datasets}
out_data: Dict[str, "DatasetInstance"] = {da.name: da.dataset for da in self.output_datasets}
inp_data: Dict[str, Optional[DatasetInstance]] = {da.name: da.dataset for da in self.input_datasets}
out_data: Dict[str, DatasetInstance] = {da.name: da.dataset for da in self.output_datasets}
inp_data.update([(da.name, da.dataset) for da in self.input_library_datasets])
out_data.update([(da.name, da.dataset) for da in self.output_library_datasets])

out_collections: Dict[str, Union["DatasetCollectionInstance", "DatasetCollection"]]
out_collections: Dict[str, Union[DatasetCollectionInstance, DatasetCollection]]
if not exclude_implicit_outputs:
out_collections = {
obj.name: obj.dataset_collection_instance for obj in self.output_dataset_collection_instances
Expand Down Expand Up @@ -8660,7 +8658,7 @@ def preferred_object_stores(self) -> WorkflowInvocationStepObjectStores:
preferred_object_store_id = None
preferred_outputs_object_store_id = None
preferred_intermediate_object_store_id = None
step_effective_outputs: Optional[List["EffectiveOutput"]] = None
step_effective_outputs: Optional[List[EffectiveOutput]] = None

workflow_invocation = self.workflow_invocation
for input_parameter in workflow_invocation.input_parameters:
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/model/store/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ def __init__(self) -> None:
self.hdca_copied_from_sinks = {}
self.jobs_by_key = {}
self.invocations_by_key: Dict[str, model.WorkflowInvocation] = {}
self.implicit_collection_jobs_by_key: Dict[str, "ImplicitCollectionJobs"] = {}
self.implicit_collection_jobs_by_key: Dict[str, ImplicitCollectionJobs] = {}
self.workflows_by_key: Dict[str, model.Workflow] = {}
self.requires_hid = []

Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tool_shed/galaxy_install/tools/data_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def install_data_managers(
repository,
repository_tools_tups,
) -> List["DataManager"]:
rval: List["DataManager"] = []
rval: List[DataManager] = []
if "data_manager" in metadata_dict:
tpm = tool_panel_manager.ToolPanelManager(self.app)
repository_tools_by_guid = {}
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tool_util/deps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def __init__(
plugin_source = self.__build_dependency_resolvers_plugin_source(conf_file)
self.dependency_resolvers = self.__parse_resolver_conf_plugins(plugin_source)
self._enabled_container_types: List[str] = []
self._destination_for_container_type: Dict[str, Dict[str, "JobDestination"]] = {}
self._destination_for_container_type: Dict[str, Dict[str, JobDestination]] = {}

def set_enabled_container_types(self, container_types_to_destinations):
"""Set the union of all enabled container types."""
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/tool_util/deps/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, app_info: "AppInfo", mulled_resolution_cache: Optional["Cache
self.app_info = app_info
self.mulled_resolution_cache = mulled_resolution_cache
self.default_container_registry = ContainerRegistry(app_info, mulled_resolution_cache=mulled_resolution_cache)
self.destination_container_registeries: Dict[str, "ContainerRegistry"] = {}
self.destination_container_registeries: Dict[str, ContainerRegistry] = {}

def _enabled_container_types(self, destination_info: Dict[str, Any]) -> List[str]:
return [t for t in ALL_CONTAINER_TYPES if self.__container_type_enabled(t, destination_info)]
Expand Down Expand Up @@ -317,7 +317,7 @@ def _parse_resolver_conf(self, plugin_source: "PluginConfigSource") -> List["Con
return plugin_config.load_plugins(self.resolver_classes, plugin_source, extra_kwds)

def __default_container_resolvers(self) -> List["ContainerResolver"]:
default_resolvers: List["ContainerResolver"] = [
default_resolvers: List[ContainerResolver] = [
ExplicitContainerResolver(self.app_info),
ExplicitSingularityContainerResolver(self.app_info),
]
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tools/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def execute(
# wrapped params are used by change_format action and by output.label; only perform this wrapping once, as needed
wrapped_params = self._wrapped_params(trans, tool, incoming, inp_data)

out_data: Dict[str, "DatasetInstance"] = {}
out_data: Dict[str, DatasetInstance] = {}
input_collections = LegacyUnprefixedDict({k: v[0][0] for k, v in inp_dataset_collections.items()})
input_collections._legacy_mapping = inp_dataset_collections._legacy_mapping
output_collections = OutputCollections(
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tools/parameters/grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ class Conditional(Group):

def __init__(self):
Group.__init__(self)
self.test_param: Optional["ToolParameter"] = None
self.test_param: Optional[ToolParameter] = None
self.cases = []
self.value_ref = None
self.value_ref_in_group = True # When our test_param is not part of the conditional Group, this is False
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tools/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def __init__(
compute_environment: Optional["ComputeEnvironment"] = None,
) -> None:
self.dataset = dataset
self.metadata: "MetadataCollection" = dataset.metadata
self.metadata: MetadataCollection = dataset.metadata
self.compute_environment = compute_environment

def __getattr__(self, name: str) -> Any:
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/webapps/galaxy/services/dataset_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def show(
"""
Returns information about a particular dataset collection.
"""
dataset_collection_instance: Union["HistoryDatasetCollectionAssociation", "LibraryDatasetCollectionAssociation"]
dataset_collection_instance: Union[HistoryDatasetCollectionAssociation, LibraryDatasetCollectionAssociation]
if instance_type == "history":
dataset_collection_instance = self.collection_manager.get_dataset_collection_instance(trans, "history", id)
parent = dataset_collection_instance.history
Expand Down Expand Up @@ -249,7 +249,7 @@ def contents(
raise exceptions.RequestParameterInvalidException(
"Parameter instance_type not being 'history' is not yet implemented."
)
hdca: "HistoryDatasetCollectionAssociation" = self.collection_manager.get_dataset_collection_instance(
hdca: HistoryDatasetCollectionAssociation = self.collection_manager.get_dataset_collection_instance(
trans, "history", hdca_id, check_ownership=True
)

Expand Down
8 changes: 3 additions & 5 deletions test/integration/test_page_revision_json_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@ def test_page_encoding_markdown(self, history_id: str):
not in content
), content
assert (
"""```galaxy
history_dataset_display(history_dataset_id={})
```""".format(
dataset_id
)
f"""```galaxy
history_dataset_display(history_dataset_id={dataset_id})
```"""
in content
), content
6 changes: 2 additions & 4 deletions test/unit/app/tools/test_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,11 @@ def selectwrapper(tool, value, multiple=False, optional=False):
optional = 'optional="true"' if optional else ""
multiple = 'multiple="true"' if multiple else ""
xml = XML(
"""<param name="blah" type="select" {} {}>
f"""<param name="blah" type="select" {multiple} {optional}>
<option value="x">I am X</option>
<option value="y" selected="true">I am Y</option>
<option value="z">I am Z</option>
</param>""".format(
multiple, optional
)
</param>"""
)
parameter = SelectToolParameter(tool, xml)
return SelectToolParameterWrapper(parameter, value)
Expand Down

0 comments on commit c7a38d0

Please sign in to comment.