diff --git a/swh/model/model.py b/swh/model/model.py --- a/swh/model/model.py +++ b/swh/model/model.py @@ -204,7 +204,7 @@ return hashlib.new("sha1", manifest).digest() -class HashableObject(metaclass=ABCMeta): +class BaseHashableModel(BaseModel, metaclass=ABCMeta): """Mixin to automatically compute object identifier hash when the associated model is instantiated.""" @@ -234,14 +234,14 @@ return self.id def check(self) -> None: - super().check() # type: ignore + super().check() if self.id != self.compute_hash(): raise ValueError("'id' does not match recomputed hash.") -class HashableObjectWithManifest(HashableObject): - """Derived class of HashableObject, for objects that may need to store +class HashableObjectWithManifest(BaseHashableModel): + """Derived class of BaseHashableModel, for objects that may need to store verbatim git objects as ``raw_manifest`` to preserve original hashes.""" __slots__ = () @@ -585,7 +585,7 @@ @attr.s(frozen=True, slots=True) -class Origin(HashableObject, BaseModel): +class Origin(BaseHashableModel): """Represents a software source: a VCS and an URL.""" object_type: Final = "origin" @@ -728,7 +728,7 @@ @attr.s(frozen=True, slots=True) -class Snapshot(HashableObject, BaseModel): +class Snapshot(BaseHashableModel): """Represents the full state of an origin at a given point in time.""" object_type: Final = "snapshot" @@ -1366,7 +1366,7 @@ @attr.s(frozen=True, slots=True) -class RawExtrinsicMetadata(HashableObject, BaseModel): +class RawExtrinsicMetadata(BaseHashableModel): object_type: Final = "raw_extrinsic_metadata" # target object @@ -1583,7 +1583,7 @@ @attr.s(frozen=True, slots=True) -class ExtID(HashableObject, BaseModel): +class ExtID(BaseHashableModel): object_type: Final = "extid" extid_type = attr.ib(type=str, validator=type_validator())