Skip to content

Commit c45aac7

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 745a8f7 commit c45aac7

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
@@ -426,7 +426,7 @@ def __init__(
426426
) -> None:
427427
val = keyval["public"]
428428
if not all(isinstance(at, str) for at in [keyid, keytype, scheme, val]):
429-
raise ValueError("Unexpected Key attributes types!")
429+
raise TypeError("Unexpected Key attributes types!")
430430
self.keyid = keyid
431431
self.keytype = keytype
432432
self.scheme = scheme

0 commit comments

Comments
 (0)