Skip to content

Commit b643e5b

Browse files
author
Jussi Kukkonen
committed
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 <[email protected]>
1 parent 2e3eb40 commit b643e5b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tuf/api/metadata.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,10 @@ def from_dict(cls, meta_dict: Dict[str, Any]) -> "MetaFile":
660660

661661
def to_dict(self) -> Dict[str, Any]:
662662
"""Returns the dictionary representation of self."""
663-
res_dict = {"version": self.version, **self.unrecognized_fields}
663+
res_dict: Dict[str, Any] = {
664+
"version": self.version,
665+
**self.unrecognized_fields,
666+
}
664667

665668
if self.length is not None:
666669
res_dict["length"] = self.length

0 commit comments

Comments
 (0)