From b643e5bec7390428de98fc8227ff422a3d1b1584 Mon Sep 17 00:00:00 2001 From: Jussi Kukkonen Date: Wed, 19 May 2021 14:42:18 +0300 Subject: [PATCH] Metadata API: Add type annotation to help mypy Without this mypy figures the dict is Dict[str, str] and then promptly fails when int value is inserted Signed-off-by: Jussi Kukkonen --- tuf/api/metadata.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tuf/api/metadata.py b/tuf/api/metadata.py index 7e054ba057..c3faafbdd5 100644 --- a/tuf/api/metadata.py +++ b/tuf/api/metadata.py @@ -660,7 +660,10 @@ def from_dict(cls, meta_dict: Dict[str, Any]) -> "MetaFile": def to_dict(self) -> Dict[str, Any]: """Returns the dictionary representation of self.""" - res_dict = {"version": self.version, **self.unrecognized_fields} + res_dict: Dict[str, Any] = { + "version": self.version, + **self.unrecognized_fields, + } if self.length is not None: res_dict["length"] = self.length