Skip to content

Commit 916055a

Browse files
sechkovajoshuagl
authored andcommitted
tuf.api: simplify metadata.Targets.signable()
Signed-off-by: Teodora Sechkova <[email protected]>
1 parent 3e022aa commit 916055a

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

tuf/api/metadata.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -185,24 +185,13 @@ def read_from_json(self, filename: str) -> None:
185185
def signable(self):
186186
# TODO: probably want to generalise this, a @property.getter in Metadata?
187187
expires = self.expiration.replace(tzinfo=None).isoformat()+'Z'
188-
if self.delegations is not None:
189-
return tuf.formats.build_dict_conforming_to_schema(
190-
tuf.formats.TARGETS_SCHEMA,
191-
version=self.version,
192-
expires=expires,
193-
targets=self.targets,
194-
delegations=self.delegations)
195-
else:
196-
return tuf.formats.build_dict_conforming_to_schema(
197-
tuf.formats.TARGETS_SCHEMA,
198-
version=self.version,
199-
expires=expires,
200-
targets=self.targets)
201-
# TODO: As an alternative to the odd if/else above where we decide whether or
202-
# not to include the delegations argument based on whether or not it is
203-
# None, consider instead adding a check in
204-
# build_dict_conforming_to_schema that skips a keyword if that keyword
205-
# is optional in the schema and the value passed in is set to None....
188+
return tuf.formats.build_dict_conforming_to_schema(
189+
tuf.formats.TARGETS_SCHEMA,
190+
version=self.version,
191+
expires=expires,
192+
targets=self.targets,
193+
delegations=self.delegations)
194+
206195

207196
# Add or update metadata about the target.
208197
# TODO: how to handle writing consistent targets?

0 commit comments

Comments
 (0)