Skip to content

Commit

Permalink
Mark kwargs in metadata API methods as Optional
Browse files Browse the repository at this point in the history
Use typing.Optional for optional kwargs that default to None.

Signed-off-by: Lukas Puehringer <[email protected]>
  • Loading branch information
lukpueh committed Mar 5, 2021
1 parent 8858280 commit 71a684b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tuf/api/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ class also that has a 'from_dict' factory method. (Currently this is

@classmethod
def from_file(
cls, filename: str, deserializer: MetadataDeserializer = None,
cls, filename: str,
deserializer: Optional[MetadataDeserializer] = None,
storage_backend: Optional[StorageBackendInterface] = None
) -> 'Metadata':
"""Loads TUF metadata from file storage.
Expand Down Expand Up @@ -150,8 +151,10 @@ def to_dict(self) -> JsonDict:
'signed': self.signed.to_dict()
}

def to_file(self, filename: str, serializer: MetadataSerializer = None,
storage_backend: StorageBackendInterface = None) -> None:
def to_file(
self, filename: str, serializer: Optional[MetadataSerializer] = None,
storage_backend: Optional[StorageBackendInterface] = None
) -> None:
"""Writes TUF metadata to file storage.
Arguments:
Expand Down Expand Up @@ -183,7 +186,7 @@ def to_file(self, filename: str, serializer: MetadataSerializer = None,

# Signatures.
def sign(self, key: JsonDict, append: bool = False,
serializer: SignedSerializer = None) -> JsonDict:
serializer: Optional[SignedSerializer] = None) -> JsonDict:
"""Creates signature over 'signed' and assigns it to 'signatures'.
Arguments:
Expand Down Expand Up @@ -223,7 +226,7 @@ def sign(self, key: JsonDict, append: bool = False,


def verify(self, key: JsonDict,
serializer: SignedSerializer = None) -> bool:
serializer: Optional[SignedSerializer] = None) -> bool:
"""Verifies 'signatures' over 'signed' that match the passed key by id.
Arguments:
Expand Down

0 comments on commit 71a684b

Please sign in to comment.