Skip to content

Commit 4e26995

Browse files
committed
Address Lukas comments
Signed-off-by: Martin Vrachev <[email protected]>
1 parent 2beb35d commit 4e26995

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tuf/api/metadata.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,7 @@ def from_dict(cls, signed_dict: JsonDict) -> 'Signed':
300300
signed_dict['expires'])
301301
# NOTE: Any 'from_dict'(-like) conversions of fields that correspond
302302
# to a subclass should be performed in the 'from_dict' method of that
303-
# subclass and also be written back into 'signed_dict' before calling
304-
# super().from_dict.
303+
# subclass and assigned to the below returned object.
305304

306305
# NOTE: cls might be a subclass of Signed, if 'from_dict' was called on
307306
# that subclass (see e.g. Metadata.from_dict).
@@ -380,6 +379,10 @@ def __init__(
380379
self, _type: str=None, version: int=None, spec_version: str=None,
381380
expires: datetime=None, consistent_snapshot: bool=None,
382381
keys: JsonDict=None, roles: JsonDict=None) -> None:
382+
383+
# TODO: Add sensible defaults when we have input validation.
384+
# See issue https://github.com/theupdateframework/tuf/issues/1140
385+
# We need default values to create empty objects in Signed.from_dict()
383386
super().__init__(_type, version, spec_version, expires)
384387
# TODO: Add classes for keys and roles
385388
self.consistent_snapshot = consistent_snapshot
@@ -492,6 +495,10 @@ def __init__(
492495
self, _type: str=None, version: int=None, spec_version: str=None,
493496
expires: datetime=None, meta: Dict[str, MetadataInfo]=None
494497
) -> None:
498+
499+
# TODO: Add sensible defaults when we have input validation.
500+
# See issue https://github.com/theupdateframework/tuf/issues/1140
501+
# We need default values to create empty objects in Signed.from_dict()
495502
super().__init__(_type, version, spec_version, expires)
496503
self.meta = meta
497504

@@ -536,7 +543,7 @@ class Snapshot(Signed):
536543
meta: A dictionary that contains information about targets metadata::
537544
538545
{
539-
'targets.json': <MetadataInfo INSTANCE>
546+
'targets.json': <MetadataInfo INSTANCE>,
540547
'<DELEGATED TARGETS ROLE 1>.json': <MetadataInfo INSTANCE>,
541548
'<DELEGATED TARGETS ROLE 2>.json': <MetadataInfo INSTANCE>,
542549
...
@@ -547,6 +554,10 @@ def __init__(
547554
self, _type: str=None, version: int=None, spec_version: str=None,
548555
expires: datetime=None, meta: Dict[str, MetadataInfo]=None
549556
) -> None:
557+
558+
# TODO: Add sensible defaults when we have input validation.
559+
# See issue https://github.com/theupdateframework/tuf/issues/1140
560+
# We need default values to create empty objects in Signed.from_dict()
550561
super().__init__(_type, version, spec_version, expires)
551562
self.meta = meta
552563

@@ -694,6 +705,9 @@ def __init__(
694705
self, _type: str=None, version: int=None, spec_version: str=None,
695706
expires: datetime=None, targets: Dict[str, TargetInfo]=None,
696707
delegations: JsonDict=None) -> None:
708+
# TODO: Add sensible defaults when we have input validation.
709+
# See issue https://github.com/theupdateframework/tuf/issues/1140
710+
# We need default values to create empty objects in Signed.from_dict()
697711
super().__init__(_type, version, spec_version, expires)
698712
self.targets = targets
699713

0 commit comments

Comments
 (0)