There was an error while loading. Please reload this page.
1 parent be24cb2 commit 50c1595Copy full SHA for 50c1595
data_diff/utils.py
@@ -43,7 +43,14 @@ def safezip(*args):
43
return zip(*args)
44
45
46
-def is_uuid(u):
+UUID_PATTERN = re.compile(r"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", re.I)
47
+
48
49
+def is_uuid(u: str) -> bool:
50
+ # E.g., hashlib.md5(b'hello') is a 32-letter hex number, but not an UUID.
51
+ # It would fail UUID-like comparison (< & >) because of casing and dashes.
52
+ if not UUID_PATTERN.fullmatch(u):
53
+ return False
54
try:
55
UUID(u)
56
except ValueError:
0 commit comments