Skip to content

Commit 452aad8

Browse files
committed
Metadata API: fix Key validation exception
In pr #1449 we introduced Key validation and there decided to raise "ValueError" if one of keyid, scheme, keyval or keytype is not a string. That seems like a mistake given that in the python docs it's written: "Passing arguments of the wrong type (e.g. passing a list when an int is expected) should result in a TypeError, but passing arguments with the wrong value (e.g. a number outside expected boundaries) should result in a ValueError." Signed-off-by: Martin Vrachev <[email protected]>
1 parent a91a1ab commit 452aad8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tuf/api/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def __init__(
427427
if not all(
428428
isinstance(at, str) for at in [keyid, keytype, scheme]
429429
) or not isinstance(keyval, Dict):
430-
raise ValueError("Unexpected Key attributes types!")
430+
raise TypeError("Unexpected Key attributes types!")
431431
self.keyid = keyid
432432
self.keytype = keytype
433433
self.scheme = scheme

0 commit comments

Comments
 (0)