diff --git a/lib/galaxy/managers/base.py b/lib/galaxy/managers/base.py index cbeb236b11d8..3ac563cdafa7 100644 --- a/lib/galaxy/managers/base.py +++ b/lib/galaxy/managers/base.py @@ -299,14 +299,14 @@ def _apply_orm_limit_offset(self, query: Query, limit: Optional[int], offset: Op return query # .... query resolution - def one(self, **kwargs) -> Query: + def one(self, **kwargs) -> U: """ Sends kwargs to build the query and returns one and only one model. """ query = self.query(**kwargs) return self._one_with_recast_errors(query) - def _one_with_recast_errors(self, query: Query) -> Query: + def _one_with_recast_errors(self, query: Query) -> U: """ Call sqlalchemy's one and recast errors to serializable errors if any. @@ -323,7 +323,7 @@ def _one_with_recast_errors(self, query: Query) -> Query: raise exceptions.InconsistentDatabase(f"found more than one {self.model_class.__name__}") # NOTE: at this layer, all ids are expected to be decoded and in int form - def by_id(self, id: int) -> Query: + def by_id(self, id: int) -> U: """ Gets a model by primary id. """ @@ -353,7 +353,7 @@ def list(self, filters=None, order_by=None, limit=None, offset=None, **kwargs): items = self._apply_fn_filters_gen(items, fn_filters) return list(self._apply_fn_limit_offset_gen(items, limit, offset)) - def count(self, filters=None, **kwargs): + def count(self, filters=None, **kwargs) -> int: """ Returns the number of objects matching the given filters. @@ -403,7 +403,7 @@ def _split_filters(self, filters): orm_filters.append(filter_.filter) return (orm_filters, fn_filters) - def _orm_list(self, query=None, **kwargs): + def _orm_list(self, query: Optional[Query] = None, **kwargs) -> List[U]: """ Sends kwargs to build the query return all models found. """ @@ -494,13 +494,13 @@ def create(self, flush: bool = True, *args: Any, **kwargs: Any) -> U: session.commit() return item - def copy(self, item, **kwargs): + def copy(self, item, **kwargs) -> U: """ Clone or copy an item. """ raise exceptions.NotImplemented("Abstract method") - def update(self, item, new_values, flush=True, **kwargs): + def update(self, item, new_values, flush=True, **kwargs) -> U: """ Given a dictionary of new values, update `item` and return it.