Skip to content

Commit f960d3e

Browse files
committed
Fix: is_uuid returns False for non-string inputs and catches exceptions thrown by UUID constructor
1 parent 77cf228 commit f960d3e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

jsonschema/_format.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,9 @@ def is_duration(instance: object) -> bool:
516516
)
517517
def is_uuid(instance: object) -> bool:
518518
if not isinstance(instance, str):
519-
return True
520-
UUID(instance)
519+
return False
520+
try:
521+
UUID(instance)
522+
except:
523+
return False
521524
return all(instance[position] == "-" for position in (8, 13, 18, 23))

0 commit comments

Comments
 (0)