Skip to content

Commit

Permalink
Metadata: _common_fields_from_dict() should return Tuple
Browse files Browse the repository at this point in the history
This allows mypy to track the argument types through the constructor
calls.

Signed-off-by: Jussi Kukkonen <[email protected]>
  • Loading branch information
Jussi Kukkonen committed May 17, 2021
1 parent b379ac2 commit 3e7c057
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tuf/api/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import abc
import tempfile
from datetime import datetime, timedelta
from typing import Any, ClassVar, Dict, List, Mapping, Optional, Type
from typing import Any, ClassVar, Dict, List, Mapping, Optional, Tuple, Type

from securesystemslib.keys import verify_signature
from securesystemslib.signer import Signature, Signer
Expand Down Expand Up @@ -359,7 +359,9 @@ def from_dict(cls, signed_dict: Dict[str, Any]) -> "Signed":
raise NotImplementedError

@classmethod
def _common_fields_from_dict(cls, signed_dict: Dict[str, Any]) -> List[Any]:
def _common_fields_from_dict(
cls, signed_dict: Dict[str, Any]
) -> Tuple[int, str, datetime]:
"""Returns common fields of 'Signed' instances from the passed dict
representation, and returns an ordered list to be passed as leading
positional arguments to a subclass constructor.
Expand All @@ -378,7 +380,7 @@ def _common_fields_from_dict(cls, signed_dict: Dict[str, Any]) -> List[Any]:
# what the constructor expects and what we store. The inverse operation
# is implemented in '_common_fields_to_dict'.
expires = formats.expiry_string_to_datetime(expires_str)
return [version, spec_version, expires]
return version, spec_version, expires

def _common_fields_to_dict(self) -> Dict[str, Any]:
"""Returns dict representation of common fields of 'Signed' instances.
Expand Down

0 comments on commit 3e7c057

Please sign in to comment.