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,10 +260,12 @@ 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): + def content_missing_per_sha1_git( + self, contents: List[Sha1Git] + ) -> Iterable[Sha1Git]: return self.content_missing( [{"sha1_git": c for c in contents}], key_hash="sha1_git" ) 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,12 +361,14 @@ 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 - def content_missing_per_sha1_git(self, contents): + def content_missing_per_sha1_git( + self, contents: List[Sha1Git] + ) -> Iterable[Sha1Git]: for content in contents: if content not in self._content_indexes["sha1_git"]: 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,23 +269,25 @@ ... @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) + """ ... @remote_api_endpoint("content/missing/sha1_git") - def content_missing_per_sha1_git(self, contents): + def content_missing_per_sha1_git( + self, contents: List[Sha1Git] + ) -> Iterable[Sha1Git]: """List content missing from storage based only on sha1_git. Args: @@ -293,6 +295,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,13 +354,17 @@ @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] @timed @db_transaction_generator() - def content_missing_per_sha1_git(self, contents, db=None, cur=None): + def content_missing_per_sha1_git( + self, contents: List[bytes], db=None, cur=None + ) -> Iterable[Sha1Git]: for obj in db.content_missing_per_sha1_git(contents, cur): yield obj[0]