diff --git a/swh/storage/cassandra/storage.py b/swh/storage/cassandra/storage.py --- a/swh/storage/cassandra/storage.py +++ b/swh/storage/cassandra/storage.py @@ -697,8 +697,8 @@ def snapshot_get_random(self) -> Sha1Git: return self._cql_runner.snapshot_get_random().id - def object_find_by_sha1_git(self, ids): - results = {id_: [] for id_ in ids} + def object_find_by_sha1_git(self, ids: List[Sha1Git]) -> Dict[Sha1Git, List[Dict]]: + results: Dict[Sha1Git, List[Dict]] = {id_: [] for id_ in ids} missing_ids = set(ids) # Mind the order, revision is the most likely one for a given ID, diff --git a/swh/storage/in_memory.py b/swh/storage/in_memory.py --- a/swh/storage/in_memory.py +++ b/swh/storage/in_memory.py @@ -694,8 +694,8 @@ def snapshot_get_random(self) -> Sha1Git: return random.choice(list(self._snapshots)) - def object_find_by_sha1_git(self, ids): - ret = {} + def object_find_by_sha1_git(self, ids: List[Sha1Git]) -> Dict[Sha1Git, List[Dict]]: + ret: Dict[Sha1Git, List[Dict]] = {} for id_ in ids: objs = self._objects.get(id_, []) ret[id_] = [{"sha1_git": id_, "type": obj[0],} for obj in objs] diff --git a/swh/storage/interface.py b/swh/storage/interface.py --- a/swh/storage/interface.py +++ b/swh/storage/interface.py @@ -1003,14 +1003,14 @@ ... @remote_api_endpoint("object/find_by_sha1_git") - def object_find_by_sha1_git(self, ids): + def object_find_by_sha1_git(self, ids: List[Sha1Git]) -> Dict[Sha1Git, List[Dict]]: """Return the objects found with the given ids. Args: ids: a generator of sha1_gits Returns: - dict: a mapping from id to the list of objects found. Each object + A dict from id to the list of objects found for that id. Each object found is itself a dict with keys: - sha1_git: the input id diff --git a/swh/storage/storage.py b/swh/storage/storage.py --- a/swh/storage/storage.py +++ b/swh/storage/storage.py @@ -1093,8 +1093,10 @@ @timed @db_transaction(statement_timeout=2000) - def object_find_by_sha1_git(self, ids, db=None, cur=None): - ret = {id: [] for id in ids} + def object_find_by_sha1_git( + self, ids: List[Sha1Git], db=None, cur=None + ) -> Dict[Sha1Git, List[Dict]]: + ret: Dict[Sha1Git, List[Dict]] = {id: [] for id in ids} for retval in db.object_find_by_sha1_git(ids, cur=cur): if retval[1]: