Skip to content

Commit

Permalink
Simplify typing of SessionlessContext
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Sep 20, 2023
1 parent 9540ee3 commit 00bce2e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/galaxy/managers/history_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def _contained_id_map(self, id_list):
query = (
self._session()
.query(component_class)
.filter(component_class.id.in_(id_list))
.filter(component_class.id.in_(id_list)) # type: ignore[attr-defined]
.options(undefer(component_class._metadata))
.options(joinedload(component_class.dataset).joinedload(model.Dataset.actions))
.options(joinedload(component_class.tags))
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4277,7 +4277,7 @@ def datatype_for_extension(extension, datatypes_registry=None) -> "Data":
return ret


class DatasetInstance(UsesCreateAndUpdateTime, _HasTable):
class DatasetInstance(RepresentById, UsesCreateAndUpdateTime, _HasTable):
"""A base class for all 'dataset instances', HDAs, LDAs, etc"""

states = Dataset.states
Expand Down
12 changes: 6 additions & 6 deletions lib/galaxy/model/store/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ def commit(self) -> None:
def flush(self) -> None:
pass

def add(self, obj: Union[model.DatasetInstance, model.RepresentById]) -> None:
def add(self, obj: model.RepresentById) -> None:
self.objects[obj.__class__][obj.id] = obj

def query(self, model_class: Type) -> Bunch:
def query(self, model_class: model.RepresentById) -> Bunch:
def find(obj_id):
return self.objects.get(model_class, {}).get(obj_id) or None

Expand All @@ -218,7 +218,7 @@ def filter_by(*args, **kwargs):

return Bunch(find=find, get=find, filter_by=filter_by)

def get(self, model_class: Type, primary_key: Any): # patch for SQLAlchemy 2.0 compatibility
def get(self, model_class: model.RepresentById, primary_key: Any): # patch for SQLAlchemy 2.0 compatibility
return self.query(model_class).get(primary_key)


Expand Down Expand Up @@ -894,7 +894,7 @@ def materialize_elements(dc):

def _attach_raw_id_if_editing(
self,
obj: Union[model.DatasetInstance, model.RepresentById],
obj: model.RepresentById,
attrs: Dict[str, Any],
) -> None:
if self.sessionless and "id" in attrs and self.import_options.allow_edit:
Expand Down Expand Up @@ -1272,7 +1272,7 @@ def _import_implicit_collection_jobs(self, object_import_tracker: "ObjectImportT

self._session_add(icj)

def _session_add(self, obj: Union[model.DatasetInstance, model.RepresentById]) -> None:
def _session_add(self, obj: model.RepresentById) -> None:
self.sa_session.add(obj)

def _flush(self) -> None:
Expand Down Expand Up @@ -1961,7 +1961,7 @@ def add(src, dest):

def exported_key(
self,
obj: Union[model.DatasetInstance, model.RepresentById],
obj: model.RepresentById,
) -> Union[str, int]:
return self.serialization_options.get_identifier(self.security, obj)

Expand Down

0 comments on commit 00bce2e

Please sign in to comment.