diff --git a/tuf/api/metadata.py b/tuf/api/metadata.py index 9cde07e08f..716b585479 100644 --- a/tuf/api/metadata.py +++ b/tuf/api/metadata.py @@ -379,6 +379,10 @@ def __init__( self, _type: str=None, version: int=None, spec_version: str=None, expires: datetime=None, consistent_snapshot: bool=None, keys: JsonDict=None, roles: JsonDict=None) -> None: + + # TODO: Add sensible defaults when we have input validation. + # See issue https://github.com/theupdateframework/tuf/issues/1140 + # We need default values to create empty objects in Signed.from_dict() super().__init__(_type, version, spec_version, expires) # TODO: Add classes for keys and roles self.consistent_snapshot = consistent_snapshot @@ -491,6 +495,10 @@ def __init__( self, _type: str=None, version: int=None, spec_version: str=None, expires: datetime=None, meta: Dict[str, MetadataInfo]=None ) -> None: + + # TODO: Add sensible defaults when we have input validation. + # See issue https://github.com/theupdateframework/tuf/issues/1140 + # We need default values to create empty objects in Signed.from_dict() super().__init__(_type, version, spec_version, expires) self.meta = meta @@ -525,6 +533,8 @@ def update(self, version: int, length: Optional[int] = None, hashes: Optional[JsonDict] = None) -> None: """Assigns passed info about snapshot metadata to meta dict. """ + # TODO: Consider renaming this function: + # see: https://github.com/theupdateframework/tuf/issues/1230 self.meta['snapshot.json'] = MetadataInfo(version, length, hashes) @@ -546,6 +556,10 @@ def __init__( self, _type: str=None, version: int=None, spec_version: str=None, expires: datetime=None, meta: Dict[str, MetadataInfo]=None ) -> None: + + # TODO: Add sensible defaults when we have input validation. + # See issue https://github.com/theupdateframework/tuf/issues/1140 + # We need default values to create empty objects in Signed.from_dict() super().__init__(_type, version, spec_version, expires) self.meta = meta @@ -583,6 +597,9 @@ def update( self, rolename: str, version: int, length: Optional[int] = None, hashes: Optional[JsonDict] = None) -> None: """Assigns passed (delegated) targets role info to meta dict. """ + + # TODO: Consider renaming this function: + # see: https://github.com/theupdateframework/tuf/issues/1230 metadata_fn = f'{rolename}.json' self.meta[metadata_fn] = MetadataInfo(version, length, hashes) @@ -693,6 +710,10 @@ def __init__( self, _type: str=None, version: int=None, spec_version: str=None, expires: datetime=None, targets: Dict[str, TargetInfo]=None, delegations: JsonDict=None) -> None: + + # TODO: Add sensible defaults when we have input validation. + # See issue https://github.com/theupdateframework/tuf/issues/1140 + # We need default values to create empty objects in Signed.from_dict() super().__init__(_type, version, spec_version, expires) self.targets = targets @@ -732,4 +753,7 @@ def to_dict(self) -> JsonDict: # Modification. def update(self, filename: str, fileinfo: JsonDict) -> None: """Assigns passed target file info to meta dict. """ + + # TODO: Consider renaming this function: + # see: https://github.com/theupdateframework/tuf/issues/1230 self.targets[filename] = TargetInfo(**fileinfo)