diff --git a/swh/provenance/interface.py b/swh/provenance/interface.py --- a/swh/provenance/interface.py +++ b/swh/provenance/interface.py @@ -67,7 +67,7 @@ class ProvenanceStorageInterface(Protocol): @remote_api_endpoint("content_add") def content_add( - self, cnts: Union[Iterable[Sha1Git], Dict[Sha1Git, datetime]] + self, cnts: Union[Iterable[Sha1Git], Dict[Sha1Git, Optional[datetime]]] ) -> bool: """Add blobs identified by sha1 ids, with an optional associated date (as paired in `cnts`) to the provenance storage. Return a boolean stating whether the @@ -96,7 +96,7 @@ @remote_api_endpoint("directory_add") def directory_add( - self, dirs: Union[Iterable[Sha1Git], Dict[Sha1Git, datetime]] + self, dirs: Union[Iterable[Sha1Git], Dict[Sha1Git, Optional[datetime]]] ) -> bool: """Add directories identified by sha1 ids, with an optional associated date (as paired in `dirs`) to the provenance storage. Return a boolean stating if the diff --git a/swh/provenance/mongo/backend.py b/swh/provenance/mongo/backend.py --- a/swh/provenance/mongo/backend.py +++ b/swh/provenance/mongo/backend.py @@ -26,7 +26,7 @@ self.db = db def content_add( - self, cnts: Union[Iterable[Sha1Git], Dict[Sha1Git, datetime]] + self, cnts: Union[Iterable[Sha1Git], Dict[Sha1Git, Optional[datetime]]] ) -> bool: data = cnts if isinstance(cnts, dict) else dict.fromkeys(cnts) existing = { @@ -149,7 +149,7 @@ } def directory_add( - self, dirs: Union[Iterable[Sha1Git], Dict[Sha1Git, datetime]] + self, dirs: Union[Iterable[Sha1Git], Dict[Sha1Git, Optional[datetime]]] ) -> bool: data = dirs if isinstance(dirs, dict) else dict.fromkeys(dirs) existing = { diff --git a/swh/provenance/postgresql/provenance.py b/swh/provenance/postgresql/provenance.py --- a/swh/provenance/postgresql/provenance.py +++ b/swh/provenance/postgresql/provenance.py @@ -61,7 +61,7 @@ return "denormalized" in self.flavor def content_add( - self, cnts: Union[Iterable[Sha1Git], Dict[Sha1Git, datetime]] + self, cnts: Union[Iterable[Sha1Git], Dict[Sha1Git, Optional[datetime]]] ) -> bool: return self._entity_set_date("content", cnts) @@ -84,7 +84,7 @@ return self._entity_get_date("content", ids) def directory_add( - self, dirs: Union[Iterable[Sha1Git], Dict[Sha1Git, datetime]] + self, dirs: Union[Iterable[Sha1Git], Dict[Sha1Git, Optional[datetime]]] ) -> bool: return self._entity_set_date("directory", dirs) @@ -209,9 +209,7 @@ def relation_add( self, relation: RelationType, data: Dict[Sha1Git, Set[RelationData]] ) -> bool: - rows = [ - (src, rel.dst, rel.path) for src, dsts in data.items() for rel in dsts - ] + rows = [(src, rel.dst, rel.path) for src, dsts in data.items() for rel in dsts] try: if rows: rel_table = relation.value @@ -270,7 +268,7 @@ def _entity_set_date( self, entity: Literal["content", "directory"], - dates: Union[Iterable[Sha1Git], Dict[Sha1Git, datetime]], + dates: Union[Iterable[Sha1Git], Dict[Sha1Git, Optional[datetime]]], ) -> bool: data = dates if isinstance(dates, dict) else dict.fromkeys(dates) try: