Skip to content

Commit

Permalink
Metadata API: Add type annotation to help mypy
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Jussi Kukkonen committed May 19, 2021
1 parent 2e3eb40 commit b643e5b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tuf/api/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b643e5b

Please sign in to comment.