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 @@ -260,7 +260,7 @@ if not res: yield content[key_hash] - def content_missing_per_sha1(self, contents): + def content_missing_per_sha1(self, contents: List[bytes]) -> Iterable[bytes]: return self.content_missing([{"sha1": c for c in contents}]) def content_missing_per_sha1_git(self, contents): 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 @@ -361,7 +361,7 @@ yield content[key_hash] break - def content_missing_per_sha1(self, contents): + def content_missing_per_sha1(self, contents: List[bytes]) -> Iterable[bytes]: for content in contents: if content not in self._content_indexes["sha1"]: yield content diff --git a/swh/storage/interface.py b/swh/storage/interface.py --- a/swh/storage/interface.py +++ b/swh/storage/interface.py @@ -269,18 +269,18 @@ ... @remote_api_endpoint("content/missing/sha1") - def content_missing_per_sha1(self, contents): + def content_missing_per_sha1(self, contents: List[bytes]) -> Iterable[bytes]: """List content missing from storage based only on sha1. Args: contents: List of sha1 to check for absence. - Returns: - iterable: missing ids - Raises: TODO: an exception when we get a hash collision. + Returns: + Iterable of missing content ids (sha1) + """ ... @@ -293,6 +293,7 @@ Yields: missing contents sha1_git + """ ... diff --git a/swh/storage/storage.py b/swh/storage/storage.py --- a/swh/storage/storage.py +++ b/swh/storage/storage.py @@ -354,7 +354,9 @@ @timed @db_transaction_generator() - def content_missing_per_sha1(self, contents, db=None, cur=None): + def content_missing_per_sha1( + self, contents: List[bytes], db=None, cur=None + ) -> Iterable[bytes]: for obj in db.content_missing_per_sha1(contents, cur): yield obj[0]