Skip to content

Commit

Permalink
Fix a type error
Browse files Browse the repository at this point in the history
Signed-off-by: Mihai Maruseac <[email protected]>
  • Loading branch information
mihaimaruseac committed May 29, 2024
1 parent 3f64e25 commit a7d78ea
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions model_signing/manifest/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
from typing import Self
from typing_extensions import override

from model_signing.hashing import hashing


class ManifestItem(metaclass=ABCMeta):
"""An item that can be included in the manifest.
Expand Down Expand Up @@ -114,28 +116,21 @@ def from_str(as_str: str) -> Self:
return ManifestFileChunkItem(file, start, end)


@dataclass(frozen=True)
class ManifestDigest:
"""A computed digest (algorithm and hash) for a `ManifestItem`."""
algorithm: str
digest: bytes


class Manifest(metaclass=ABCMeta):
"""Generic manifest file to represent a model."""
objects: dict[ManifestItem, ManifestDigest] = {}
objects: dict[ManifestItem, hashing.Digest] = {}
constraints: list[set[ManifestItem]] = set()

def prepare_manifest_for_signing(self) -> Any:
"""Computes the final form of the manifest for signing in memory.
#def prepare_manifest_for_signing(self) -> Any:
# """Computes the final form of the manifest for signing in memory.

Implementations decide the output type, as this can be from an
external dependency.
# Implementations decide the output type, as this can be from an
# external dependency.

This method is optional, but implementations must define at least one
of `prepare_manifest_for_signing` and `write_manifest`.
"""
pass
# This method is optional, but implementations must define at least one
# of `prepare_manifest_for_signing` and `write_manifest`.
# """
# pass

def write_manifest(self, path: pathlib.Path) -> None:
"""Writes the manifest to a file to be signed afterwards.
Expand Down Expand Up @@ -171,7 +166,7 @@ def verify(self, only_for_objects: list[ManifestItem]) -> bool:
@abstractmethod
def update(
self,
objects: dict[ManifestItem, ManifestDigest],
objects: dict[ManifestItem, hashing.Digest],
constraints: list[set[ManifestItem]],
) -> None:
"""Updates the manifest with new integrity data."""
Expand Down

0 comments on commit a7d78ea

Please sign in to comment.